From e4513a57ef719d3d6d1cee0ca4d9f4016aa452bb Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Tue, 28 Mar 2006 17:04:00 -0500 Subject: ACPI: fix sonypi ACPI driver registration to unregister on failure Remove the assumption that acpi_bus_register_driver() returns the number of devices claimed. Returning the count is unreliable because devices may be hot-plugged in the future (admittedly not applicable for this driver). This also fixes a bug: if sonypi_acpi_driver was registered but found no devices, sonypi_exit() did not unregister it. Signed-off-by: Bjorn Helgaas Signed-off-by: Andrew Morton Signed-off-by: Len Brown --- drivers/char/sonypi.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c index f8dd8527c6a..81ce5515b41 100644 --- a/drivers/char/sonypi.c +++ b/drivers/char/sonypi.c @@ -512,7 +512,7 @@ static struct sonypi_device { #ifdef CONFIG_ACPI static struct acpi_device *sonypi_acpi_device; -static int acpi_enabled; +static int acpi_driver_registered; #endif static int sonypi_ec_write(u8 addr, u8 value) @@ -869,7 +869,7 @@ found: sonypi_report_input_event(event); #ifdef CONFIG_ACPI - if (acpi_enabled) + if (sonypi_acpi_device) acpi_bus_generate_event(sonypi_acpi_device, 1, event); #endif @@ -1548,8 +1548,8 @@ static int __init sonypi_init(void) goto err_free_device; #ifdef CONFIG_ACPI - if (acpi_bus_register_driver(&sonypi_acpi_driver) > 0) - acpi_enabled = 1; + if (acpi_bus_register_driver(&sonypi_acpi_driver) >= 0) + acpi_driver_registered = 1; #endif return 0; @@ -1564,7 +1564,7 @@ static int __init sonypi_init(void) static void __exit sonypi_exit(void) { #ifdef CONFIG_ACPI - if (acpi_enabled) + if (acpi_driver_registered) acpi_bus_unregister_driver(&sonypi_acpi_driver); #endif platform_device_unregister(sonypi_platform_device); -- cgit v1.2.3-70-g09d2 From 9224a867c497053842dc595e594ca6d32112221f Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Tue, 28 Mar 2006 17:04:00 -0500 Subject: HPET: fix ACPI memory range length handling ACPI address space descriptors contain _MIN, _MAX, and _LEN. _MIN and _MAX are the bounds within which the region can be moved (this is clarified in Table 6-38 of the ACPI 3.0 spec). We should use _LEN to determine the size of the region, not _MAX - _MIN + 1. Signed-off-by: Bjorn Helgaas Signed-off-by: Andrew Morton Signed-off-by: Len Brown --- drivers/char/hpet.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c index ef140ebde11..07473cd8412 100644 --- a/drivers/char/hpet.c +++ b/drivers/char/hpet.c @@ -925,11 +925,8 @@ static acpi_status hpet_resources(struct acpi_resource *res, void *data) status = acpi_resource_to_address64(res, &addr); if (ACPI_SUCCESS(status)) { - unsigned long size; - - size = addr.maximum - addr.minimum + 1; hdp->hd_phys_address = addr.minimum; - hdp->hd_address = ioremap(addr.minimum, size); + hdp->hd_address = ioremap(addr.minimum, addr.address_length); if (hpet_is_known(hdp)) { printk(KERN_DEBUG "%s: 0x%lx is busy\n", -- cgit v1.2.3-70-g09d2 From 7f048801f4a6767433d1aeefd9c24372515265f8 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Sat, 1 Apr 2006 23:45:39 -0500 Subject: ACPI: ia64 buildfix Signed-off-by: Len Brown --- drivers/char/agp/hp-agp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/char') diff --git a/drivers/char/agp/hp-agp.c b/drivers/char/agp/hp-agp.c index 8c4c6ef748e..907fb66ec4a 100644 --- a/drivers/char/agp/hp-agp.c +++ b/drivers/char/agp/hp-agp.c @@ -497,7 +497,7 @@ zx1_gart_probe (acpi_handle obj, u32 depth, void *context, void **ret) info = buffer.pointer; info->hardware_id.value[sizeof(info->hardware_id)-1] = '\0'; match = (strcmp(info->hardware_id.value, "HWP0001") == 0); - ACPI_MEM_FREE(info); + kfree(info); if (match) { status = hp_acpi_csr_space(handle, &sba_hpa, &length); if (ACPI_SUCCESS(status)) -- cgit v1.2.3-70-g09d2 From 8b6a7b2ea2ab18d46bc9e0e76b614d8c155291ad Mon Sep 17 00:00:00 2001 From: Olof Johansson Date: Wed, 12 Apr 2006 15:19:50 -0500 Subject: [PATCH] powerpc: Quiet HVSI boot output There's no real need to print the number of found HVSI devices on the console at every boot. Signed-off-by: Olof Johansson Signed-off-by: Paul Mackerras --- drivers/char/hvsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/char') diff --git a/drivers/char/hvsi.c b/drivers/char/hvsi.c index a9522189fc9..a0370ed752c 100644 --- a/drivers/char/hvsi.c +++ b/drivers/char/hvsi.c @@ -1179,7 +1179,7 @@ static int __init hvsi_init(void) if (tty_register_driver(hvsi_driver)) panic("Couldn't register hvsi console driver\n"); - printk(KERN_INFO "HVSI: registered %i devices\n", hvsi_count); + printk(KERN_DEBUG "HVSI: registered %i devices\n", hvsi_count); return 0; } -- cgit v1.2.3-70-g09d2 From de0fe3b83f4bb47a0a6b47897bb3800862194016 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Mon, 15 May 2006 13:44:01 +1000 Subject: [PATCH] powerpc: update iSeries viocd and viotape device-tree Make their device_type entries more generic and their compatible entries more specific. Signed-off-by: Stephen Rothwell Signed-off-by: Paul Mackerras --- arch/powerpc/platforms/iseries/setup.c | 8 ++++---- drivers/cdrom/viocd.c | 2 +- drivers/char/viotape.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/char') diff --git a/arch/powerpc/platforms/iseries/setup.c b/arch/powerpc/platforms/iseries/setup.c index d3f94b4f28a..074d1d94970 100644 --- a/arch/powerpc/platforms/iseries/setup.c +++ b/arch/powerpc/platforms/iseries/setup.c @@ -982,8 +982,8 @@ void dt_vdevices(struct iseries_flat_dt *dt) for (i = 0; i < HVMAXARCHITECTEDVIRTUALCDROMS; i++) { snprintf(buf, 32, "viocd@%08x", reg + i); dt_start_node(dt, buf); - dt_prop_str(dt, "device_type", "viocd"); - dt_prop_str(dt, "compatible", ""); + dt_prop_str(dt, "device_type", "block"); + dt_prop_str(dt, "compatible", "IBM,iSeries-viocd"); dt_prop_u32(dt, "reg", reg + i); dt_prop_u32(dt, "linux,unit_address", i); dt_end_node(dt); @@ -992,8 +992,8 @@ void dt_vdevices(struct iseries_flat_dt *dt) for (i = 0; i < HVMAXARCHITECTEDVIRTUALTAPES; i++) { snprintf(buf, 32, "viotape@%08x", reg + i); dt_start_node(dt, buf); - dt_prop_str(dt, "device_type", "viotape"); - dt_prop_str(dt, "compatible", ""); + dt_prop_str(dt, "device_type", "byte"); + dt_prop_str(dt, "compatible", "IBM,iSeries-viotape"); dt_prop_u32(dt, "reg", reg + i); dt_prop_u32(dt, "linux,unit_address", i); dt_end_node(dt); diff --git a/drivers/cdrom/viocd.c b/drivers/cdrom/viocd.c index c0f817ba7ad..af6b3bfd169 100644 --- a/drivers/cdrom/viocd.c +++ b/drivers/cdrom/viocd.c @@ -731,7 +731,7 @@ static int viocd_remove(struct vio_dev *vdev) * support. */ static struct vio_device_id viocd_device_table[] __devinitdata = { - { "viocd", "" }, + { "block", "IBM,iSeries-viocd" }, { "", "" } }; MODULE_DEVICE_TABLE(vio, viocd_device_table); diff --git a/drivers/char/viotape.c b/drivers/char/viotape.c index 60aabdb4a04..11c7e9de595 100644 --- a/drivers/char/viotape.c +++ b/drivers/char/viotape.c @@ -989,7 +989,7 @@ static int viotape_remove(struct vio_dev *vdev) * support. */ static struct vio_device_id viotape_device_table[] __devinitdata = { - { "viotape", "" }, + { "byte", "IBM,iSeries-viotape" }, { "", "" } }; MODULE_DEVICE_TABLE(vio, viotape_device_table); -- cgit v1.2.3-70-g09d2 From d886cb586f60a5ccf156392f96a39bc52db925d0 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 27 May 2006 00:08:25 -0400 Subject: [PATCH] trivial annotations in rio Signed-off-by: Al Viro --- drivers/char/rio/daemon.h | 12 ++-- drivers/char/rio/func.h | 25 +++---- drivers/char/rio/host.h | 16 ++--- drivers/char/rio/port.h | 16 ++--- drivers/char/rio/rio.h | 4 +- drivers/char/rio/rio_linux.c | 29 ++++---- drivers/char/rio/rio_linux.h | 10 +-- drivers/char/rio/rioboot.c | 52 +++++++------- drivers/char/rio/riocmd.c | 20 +++--- drivers/char/rio/rioctrl.c | 164 +++++++++++++++++++++---------------------- drivers/char/rio/rioinit.c | 28 ++++---- drivers/char/rio/riointr.c | 18 ++--- drivers/char/rio/rioparam.c | 28 ++++---- drivers/char/rio/rioroute.c | 12 ++-- drivers/char/rio/riotable.c | 20 +++--- drivers/char/rio/riotty.c | 2 +- drivers/char/rio/unixrup.h | 2 +- 17 files changed, 228 insertions(+), 230 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/rio/daemon.h b/drivers/char/rio/daemon.h index 5818a8aa46e..6e63f8b2c47 100644 --- a/drivers/char/rio/daemon.h +++ b/drivers/char/rio/daemon.h @@ -51,7 +51,7 @@ struct Error { }; struct DownLoad { - char *DataP; + char __user *DataP; unsigned int Count; unsigned int ProductCode; }; @@ -83,18 +83,18 @@ struct PortSetup { struct LpbReq { unsigned int Host; unsigned int Link; - struct LPB *LpbP; + struct LPB __user *LpbP; }; struct RupReq { unsigned int HostNum; unsigned int RupNum; - struct RUP *RupP; + struct RUP __user *RupP; }; struct PortReq { unsigned int SysPort; - struct Port *PortP; + struct Port __user *PortP; }; struct StreamInfo { @@ -105,12 +105,12 @@ struct StreamInfo { struct HostReq { unsigned int HostNum; - struct Host *HostP; + struct Host __user *HostP; }; struct HostDpRam { unsigned int HostNum; - struct DpRam *DpRamP; + struct DpRam __user *DpRamP; }; struct DebugCtrl { diff --git a/drivers/char/rio/func.h b/drivers/char/rio/func.h index e64fe991239..0707af33f01 100644 --- a/drivers/char/rio/func.h +++ b/drivers/char/rio/func.h @@ -46,7 +46,7 @@ int RIOBootCodeRTA(struct rio_info *, struct DownLoad *); int RIOBootCodeHOST(struct rio_info *, struct DownLoad *); int RIOBootCodeUNKNOWN(struct rio_info *, struct DownLoad *); void msec_timeout(struct Host *); -int RIOBootRup(struct rio_info *, unsigned int, struct Host *, struct PKT *); +int RIOBootRup(struct rio_info *, unsigned int, struct Host *, struct PKT __iomem *); int RIOBootOk(struct rio_info *, struct Host *, unsigned long); int RIORtaBound(struct rio_info *, unsigned int); void rio_fill_host_slot(int, int, unsigned int, struct Host *); @@ -55,8 +55,8 @@ void rio_fill_host_slot(int, int, unsigned int, struct Host *); int RIOFoadRta(struct Host *, struct Map *); int RIOZombieRta(struct Host *, struct Map *); int RIOCommandRta(struct rio_info *, unsigned long, int (*func) (struct Host *, struct Map *)); -int RIOIdentifyRta(struct rio_info *, void *); -int RIOKillNeighbour(struct rio_info *, void *); +int RIOIdentifyRta(struct rio_info *, void __user *); +int RIOKillNeighbour(struct rio_info *, void __user *); int RIOSuspendBootRta(struct Host *, int, int); int RIOFoadWakeup(struct rio_info *); struct CmdBlk *RIOGetCmdBlk(void); @@ -68,7 +68,8 @@ int RIORFlushEnable(unsigned long, struct CmdBlk *); int RIOUnUse(unsigned long, struct CmdBlk *); /* rioctrl.c */ -int riocontrol(struct rio_info *, dev_t, int, caddr_t, int); +int riocontrol(struct rio_info *, dev_t, int, unsigned long, int); + int RIOPreemptiveCmd(struct rio_info *, struct Port *, unsigned char); /* rioinit.c */ @@ -77,13 +78,13 @@ void RIOInitHosts(struct rio_info *, struct RioHostInfo *); void RIOISAinit(struct rio_info *, int); int RIODoAT(struct rio_info *, int, int); caddr_t RIOCheckForATCard(int); -int RIOAssignAT(struct rio_info *, int, caddr_t, int); -int RIOBoardTest(unsigned long, caddr_t, unsigned char, int); +int RIOAssignAT(struct rio_info *, int, void __iomem *, int); +int RIOBoardTest(unsigned long, void __iomem *, unsigned char, int); void RIOAllocDataStructs(struct rio_info *); void RIOSetupDataStructs(struct rio_info *); int RIODefaultName(struct rio_info *, struct Host *, unsigned int); struct rioVersion *RIOVersid(void); -void RIOHostReset(unsigned int, struct DpRam *, unsigned int); +void RIOHostReset(unsigned int, struct DpRam __iomem *, unsigned int); /* riointr.c */ void RIOTxEnable(char *); @@ -95,14 +96,14 @@ int RIOParam(struct Port *, int, int, int); int RIODelay(struct Port *PortP, int); int RIODelay_ni(struct Port *PortP, int); void ms_timeout(struct Port *); -int can_add_transmit(struct PKT **, struct Port *); +int can_add_transmit(struct PKT __iomem **, struct Port *); void add_transmit(struct Port *); -void put_free_end(struct Host *, struct PKT *); -int can_remove_receive(struct PKT **, struct Port *); +void put_free_end(struct Host *, struct PKT __iomem *); +int can_remove_receive(struct PKT __iomem **, struct Port *); void remove_receive(struct Port *); /* rioroute.c */ -int RIORouteRup(struct rio_info *, unsigned int, struct Host *, struct PKT *); +int RIORouteRup(struct rio_info *, unsigned int, struct Host *, struct PKT __iomem *); void RIOFixPhbs(struct rio_info *, struct Host *, unsigned int); unsigned int GetUnitType(unsigned int); int RIOSetChange(struct rio_info *); @@ -139,7 +140,7 @@ int rio_isr_thread(char *); struct rio_info *rio_info_store(int cmd, struct rio_info *p); #endif -extern void rio_copy_to_card(void *to, void *from, int len); +extern void rio_copy_to_card(void __iomem *to, void *from, int len); extern int rio_minor(struct tty_struct *tty); extern int rio_ismodem(struct tty_struct *tty); diff --git a/drivers/char/rio/host.h b/drivers/char/rio/host.h index 179cdbea712..ee2ddea7a63 100644 --- a/drivers/char/rio/host.h +++ b/drivers/char/rio/host.h @@ -48,8 +48,8 @@ struct Host { unsigned char Ivec; /* POLLED or ivec number */ unsigned char Mode; /* Control stuff */ unsigned char Slot; /* Slot */ - caddr_t Caddr; /* KV address of DPRAM */ - struct DpRam *CardP; /* KV address of DPRAM, with overlay */ + void __iomem *Caddr; /* KV address of DPRAM */ + struct DpRam __iomem *CardP; /* KV address of DPRAM, with overlay */ unsigned long PaddrP; /* Phys. address of DPRAM */ char Name[MAX_NAME_LEN]; /* The name of the host */ unsigned int UniqueNum; /* host unique number */ @@ -57,7 +57,7 @@ struct Host { unsigned int WorkToBeDone; /* set to true each interrupt */ unsigned int InIntr; /* Being serviced? */ unsigned int IntSrvDone; /* host's interrupt has been serviced */ - void (*Copy) (void *, void *, int); /* copy func */ + void (*Copy) (void *, void __iomem *, int); /* copy func */ struct timer_list timer; /* ** I M P O R T A N T ! @@ -83,11 +83,11 @@ struct Host { struct Top Topology[LINKS_PER_UNIT]; /* one per link */ struct Map Mapping[MAX_RUP]; /* Mappings for host */ - struct PHB *PhbP; /* Pointer to the PHB array */ - unsigned short *PhbNumP; /* Ptr to Number of PHB's */ - struct LPB *LinkStrP; /* Link Structure Array */ - struct RUP *RupP; /* Sixteen real rups here */ - struct PARM_MAP *ParmMapP; /* points to the parmmap */ + struct PHB __iomem *PhbP; /* Pointer to the PHB array */ + unsigned short __iomem *PhbNumP; /* Ptr to Number of PHB's */ + struct LPB __iomem *LinkStrP; /* Link Structure Array */ + struct RUP __iomem *RupP; /* Sixteen real rups here */ + struct PARM_MAP __iomem *ParmMapP; /* points to the parmmap */ unsigned int ExtraUnits[MAX_EXTRA_UNITS]; /* unknown things */ unsigned int NumExtraBooted; /* how many of the above */ /* diff --git a/drivers/char/rio/port.h b/drivers/char/rio/port.h index 9b5fa3eb040..49cf6d15ee5 100644 --- a/drivers/char/rio/port.h +++ b/drivers/char/rio/port.h @@ -40,7 +40,7 @@ struct Port { struct gs_port gs; int PortNum; /* RIO port no., 0-511 */ struct Host *HostP; - caddr_t Caddr; + void __iomem *Caddr; unsigned short HostPort; /* Port number on host card */ unsigned char RupNum; /* Number of RUP for port */ unsigned char ID2; /* Second ID of RTA for port */ @@ -92,13 +92,13 @@ struct Port { #define RIO_RTSFLOW 0x0400 /* RIO's own RTSFLOW flag */ - struct PHB *PhbP; /* pointer to PHB for port */ - u16 *TxAdd; /* Add packets here */ - u16 *TxStart; /* Start of add array */ - u16 *TxEnd; /* End of add array */ - u16 *RxRemove; /* Remove packets here */ - u16 *RxStart; /* Start of remove array */ - u16 *RxEnd; /* End of remove array */ + struct PHB __iomem *PhbP; /* pointer to PHB for port */ + u16 __iomem *TxAdd; /* Add packets here */ + u16 __iomem *TxStart; /* Start of add array */ + u16 __iomem *TxEnd; /* End of add array */ + u16 __iomem *RxRemove; /* Remove packets here */ + u16 __iomem *RxStart; /* Start of remove array */ + u16 __iomem *RxEnd; /* End of remove array */ unsigned int RtaUniqueNum; /* Unique number of RTA */ unsigned short PortState; /* status of port */ unsigned short ModemState; /* status of modem lines */ diff --git a/drivers/char/rio/rio.h b/drivers/char/rio/rio.h index b4c91871ba2..1bf36223a4e 100644 --- a/drivers/char/rio/rio.h +++ b/drivers/char/rio/rio.h @@ -129,8 +129,8 @@ ** RIO_OBJ takes hostp->Caddr and a UNIX pointer to an object and ** returns the offset into the DP RAM area. */ -#define RIO_PTR(C,O) (((unsigned char *)(C))+(0xFFFF&(O))) -#define RIO_OFF(C,O) ((long)(O)-(long)(C)) +#define RIO_PTR(C,O) (((unsigned char __iomem *)(C))+(0xFFFF&(O))) +#define RIO_OFF(C,O) ((unsigned char __iomem *)(O)-(unsigned char __iomem *)(C)) /* ** How to convert from various different device number formats: diff --git a/drivers/char/rio/rio_linux.c b/drivers/char/rio/rio_linux.c index 78dd856534c..39277e53d9a 100644 --- a/drivers/char/rio/rio_linux.c +++ b/drivers/char/rio/rio_linux.c @@ -333,7 +333,7 @@ int RIODelay_ni(struct Port *PortP, int njiffies) return !RIO_FAIL; } -void rio_copy_to_card(void *to, void *from, int len) +void rio_copy_to_card(void __iomem *to, void *from, int len) { rio_memcpy_toio(NULL, to, from, len); } @@ -573,7 +573,7 @@ static int rio_fw_ioctl(struct inode *inode, struct file *filp, unsigned int cmd func_enter(); /* The "dev" argument isn't used. */ - rc = riocontrol(p, 0, cmd, (void *) arg, capable(CAP_SYS_ADMIN)); + rc = riocontrol(p, 0, cmd, arg, capable(CAP_SYS_ADMIN)); func_exit(); return rc; @@ -583,6 +583,7 @@ extern int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, static int rio_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd, unsigned long arg) { + void __user *argp = (void __user *)arg; int rc; struct Port *PortP; int ival; @@ -594,14 +595,14 @@ static int rio_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd rc = 0; switch (cmd) { case TIOCSSOFTCAR: - if ((rc = get_user(ival, (unsigned int *) arg)) == 0) { + if ((rc = get_user(ival, (unsigned __user *) argp)) == 0) { tty->termios->c_cflag = (tty->termios->c_cflag & ~CLOCAL) | (ival ? CLOCAL : 0); } break; case TIOCGSERIAL: rc = -EFAULT; - if (access_ok(VERIFY_WRITE, (void *) arg, sizeof(struct serial_struct))) - rc = gs_getserial(&PortP->gs, (struct serial_struct *) arg); + if (access_ok(VERIFY_WRITE, argp, sizeof(struct serial_struct))) + rc = gs_getserial(&PortP->gs, argp); break; case TCSBRK: if (PortP->State & RIO_DELETED) { @@ -631,8 +632,8 @@ static int rio_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd break; case TIOCSSERIAL: rc = -EFAULT; - if (access_ok(VERIFY_READ, (void *) arg, sizeof(struct serial_struct))) - rc = gs_setserial(&PortP->gs, (struct serial_struct *) arg); + if (access_ok(VERIFY_READ, argp, sizeof(struct serial_struct))) + rc = gs_setserial(&PortP->gs, argp); break; default: rc = -ENOIOCTLCMD; @@ -919,7 +920,7 @@ static void __exit rio_release_drivers(void) static void fix_rio_pci(struct pci_dev *pdev) { unsigned long hwbase; - unsigned char *rebase; + unsigned char __iomem *rebase; unsigned int t; #define CNTRL_REG_OFFSET 0x50 @@ -999,7 +1000,7 @@ static int __init rio_init(void) if (((1 << hp->Ivec) & rio_irqmask) == 0) hp->Ivec = 0; hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN); - hp->CardP = (struct DpRam *) hp->Caddr; + hp->CardP = (struct DpRam __iomem *) hp->Caddr; hp->Type = RIO_PCI; hp->Copy = rio_copy_to_card; hp->Mode = RIO_PCI_BOOT_FROM_RAM; @@ -1021,7 +1022,7 @@ static int __init rio_init(void) p->RIONumHosts++; found++; } else { - iounmap((char *) (p->RIOHosts[p->RIONumHosts].Caddr)); + iounmap(p->RIOHosts[p->RIONumHosts].Caddr); } } @@ -1047,7 +1048,7 @@ static int __init rio_init(void) hp->Ivec = 0; hp->Ivec |= 0x8000; /* Mark as non-sharable */ hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN); - hp->CardP = (struct DpRam *) hp->Caddr; + hp->CardP = (struct DpRam __iomem *) hp->Caddr; hp->Type = RIO_PCI; hp->Copy = rio_copy_to_card; hp->Mode = RIO_PCI_BOOT_FROM_RAM; @@ -1070,7 +1071,7 @@ static int __init rio_init(void) p->RIONumHosts++; found++; } else { - iounmap((char *) (p->RIOHosts[p->RIONumHosts].Caddr)); + iounmap(p->RIOHosts[p->RIONumHosts].Caddr); } #else printk(KERN_ERR "Found an older RIO PCI card, but the driver is not " "compiled to support it.\n"); @@ -1085,7 +1086,7 @@ static int __init rio_init(void) /* There was something about the IRQs of these cards. 'Forget what.--REW */ hp->Ivec = 0; hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN); - hp->CardP = (struct DpRam *) hp->Caddr; + hp->CardP = (struct DpRam __iomem *) hp->Caddr; hp->Type = RIO_AT; hp->Copy = rio_copy_to_card; /* AT card PCI???? - PVDL * -- YES! this is now a normal copy. Only the @@ -1111,7 +1112,7 @@ static int __init rio_init(void) } if (!okboard) - iounmap((char *) (hp->Caddr)); + iounmap(hp->Caddr); } } diff --git a/drivers/char/rio/rio_linux.h b/drivers/char/rio/rio_linux.h index 4ce77fb1fae..99c7447b611 100644 --- a/drivers/char/rio/rio_linux.h +++ b/drivers/char/rio/rio_linux.h @@ -131,24 +131,24 @@ struct vpd_prom { #ifdef CONFIG_RIO_OLDPCI -static inline void *rio_memcpy_toio(void *dummy, void *dest, void *source, int n) +static inline void __iomem *rio_memcpy_toio(void __iomem *dummy, void __iomem *dest, void *source, int n) { - char *dst = dest; + char __iomem *dst = dest; char *src = source; while (n--) { writeb(*src++, dst++); - (void) readb(dummy); + (void) readb(dummy); /* WTF? */ } return dest; } -static inline void *rio_memcpy_fromio(void *dest, void *source, int n) +static inline void *rio_memcpy_fromio(void *dest, void __iomem *source, int n) { char *dst = dest; - char *src = source; + char __iomem *src = source; while (n--) *dst++ = readb(src++); diff --git a/drivers/char/rio/rioboot.c b/drivers/char/rio/rioboot.c index 290143addd3..b9abbd0e7ec 100644 --- a/drivers/char/rio/rioboot.c +++ b/drivers/char/rio/rioboot.c @@ -71,7 +71,7 @@ #include "cmdblk.h" #include "route.h" -static int RIOBootComplete(struct rio_info *p, struct Host *HostP, unsigned int Rup, struct PktCmd *PktCmdP); +static int RIOBootComplete(struct rio_info *p, struct Host *HostP, unsigned int Rup, struct PktCmd __iomem *PktCmdP); static const unsigned char RIOAtVec2Ctrl[] = { /* 0 */ INTERRUPT_DISABLE, @@ -204,13 +204,13 @@ void rio_start_card_running(struct Host *HostP) int RIOBootCodeHOST(struct rio_info *p, struct DownLoad *rbp) { struct Host *HostP; - u8 *Cad; - PARM_MAP *ParmMapP; + u8 __iomem *Cad; + PARM_MAP __iomem *ParmMapP; int RupN; int PortN; unsigned int host; - u8 *StartP; - u8 *DestP; + u8 __iomem *StartP; + u8 __iomem *DestP; int wait_count; u16 OldParmMap; u16 offset; /* It is very important that this is a u16 */ @@ -262,7 +262,7 @@ int RIOBootCodeHOST(struct rio_info *p, struct DownLoad *rbp) ** Ensure that the host really is stopped. ** Disable it's external bus & twang its reset line. */ - RIOHostReset(HostP->Type, (struct DpRam *) HostP->CardP, HostP->Slot); + RIOHostReset(HostP->Type, HostP->CardP, HostP->Slot); /* ** Copy the data directly from user space to the SRAM. @@ -366,7 +366,7 @@ int RIOBootCodeHOST(struct rio_info *p, struct DownLoad *rbp) ** a short branch to 0x7FF8, where a long branch is coded. */ - DestP = (u8 *) &Cad[0x7FF8]; /* <<<---- READ THE ABOVE COMMENTS */ + DestP = &Cad[0x7FF8]; /* <<<---- READ THE ABOVE COMMENTS */ #define NFIX(N) (0x60 | (N)) /* .O = (~(.O + N))<<4 */ #define PFIX(N) (0x20 | (N)) /* .O = (.O + N)<<4 */ @@ -438,7 +438,7 @@ int RIOBootCodeHOST(struct rio_info *p, struct DownLoad *rbp) rio_dprintk(RIO_DEBUG_BOOT, "RIO Mesg Run Fail\n"); HostP->Flags &= ~RUN_STATE; HostP->Flags |= RC_STUFFED; - RIOHostReset( HostP->Type, (struct DpRam *)HostP->CardP, HostP->Slot ); + RIOHostReset( HostP->Type, HostP->CardP, HostP->Slot ); continue; } @@ -453,9 +453,9 @@ int RIOBootCodeHOST(struct rio_info *p, struct DownLoad *rbp) /* ** Grab a 32 bit pointer to the parmmap structure */ - ParmMapP = (PARM_MAP *) RIO_PTR(Cad, readw(&HostP->__ParmMapR)); + ParmMapP = (PARM_MAP __iomem *) RIO_PTR(Cad, readw(&HostP->__ParmMapR)); rio_dprintk(RIO_DEBUG_BOOT, "ParmMapP : %p\n", ParmMapP); - ParmMapP = (PARM_MAP *) ((unsigned long) Cad + readw(&HostP->__ParmMapR)); + ParmMapP = (PARM_MAP __iomem *)(Cad + readw(&HostP->__ParmMapR)); rio_dprintk(RIO_DEBUG_BOOT, "ParmMapP : %p\n", ParmMapP); /* @@ -468,7 +468,7 @@ int RIOBootCodeHOST(struct rio_info *p, struct DownLoad *rbp) rio_dprintk(RIO_DEBUG_BOOT, "Links = 0x%x\n", readw(&ParmMapP->links)); HostP->Flags &= ~RUN_STATE; HostP->Flags |= RC_STUFFED; - RIOHostReset( HostP->Type, (struct DpRam *)HostP->CardP, HostP->Slot ); + RIOHostReset( HostP->Type, HostP->CardP, HostP->Slot ); continue; } @@ -491,7 +491,7 @@ int RIOBootCodeHOST(struct rio_info *p, struct DownLoad *rbp) rio_dprintk(RIO_DEBUG_BOOT, "Timedout waiting for init_done\n"); HostP->Flags &= ~RUN_STATE; HostP->Flags |= RC_STUFFED; - RIOHostReset( HostP->Type, (struct DpRam *)HostP->CardP, HostP->Slot ); + RIOHostReset( HostP->Type, HostP->CardP, HostP->Slot ); continue; } @@ -512,10 +512,10 @@ int RIOBootCodeHOST(struct rio_info *p, struct DownLoad *rbp) ** 32 bit pointers for the driver in ioremap space. */ HostP->ParmMapP = ParmMapP; - HostP->PhbP = (struct PHB *) RIO_PTR(Cad, readw(&ParmMapP->phb_ptr)); - HostP->RupP = (struct RUP *) RIO_PTR(Cad, readw(&ParmMapP->rups)); - HostP->PhbNumP = (unsigned short *) RIO_PTR(Cad, readw(&ParmMapP->phb_num_ptr)); - HostP->LinkStrP = (struct LPB *) RIO_PTR(Cad, readw(&ParmMapP->link_str_ptr)); + HostP->PhbP = (struct PHB __iomem *) RIO_PTR(Cad, readw(&ParmMapP->phb_ptr)); + HostP->RupP = (struct RUP __iomem *) RIO_PTR(Cad, readw(&ParmMapP->rups)); + HostP->PhbNumP = (unsigned short __iomem *) RIO_PTR(Cad, readw(&ParmMapP->phb_num_ptr)); + HostP->LinkStrP = (struct LPB __iomem *) RIO_PTR(Cad, readw(&ParmMapP->link_str_ptr)); /* ** point the UnixRups at the real Rups @@ -540,7 +540,7 @@ int RIOBootCodeHOST(struct rio_info *p, struct DownLoad *rbp) for (PortN = p->RIOFirstPortsMapped; PortN < p->RIOLastPortsMapped + PORTS_PER_RTA; PortN++) { if (p->RIOPortp[PortN]->HostP == HostP) { struct Port *PortP = p->RIOPortp[PortN]; - struct PHB *PhbP; + struct PHB __iomem *PhbP; /* int oldspl; */ if (!PortP->Mapped) @@ -551,12 +551,12 @@ int RIOBootCodeHOST(struct rio_info *p, struct DownLoad *rbp) PortP->PhbP = PhbP; - PortP->TxAdd = (u16 *) RIO_PTR(Cad, readw(&PhbP->tx_add)); - PortP->TxStart = (u16 *) RIO_PTR(Cad, readw(&PhbP->tx_start)); - PortP->TxEnd = (u16 *) RIO_PTR(Cad, readw(&PhbP->tx_end)); - PortP->RxRemove = (u16 *) RIO_PTR(Cad, readw(&PhbP->rx_remove)); - PortP->RxStart = (u16 *) RIO_PTR(Cad, readw(&PhbP->rx_start)); - PortP->RxEnd = (u16 *) RIO_PTR(Cad, readw(&PhbP->rx_end)); + PortP->TxAdd = (u16 __iomem *) RIO_PTR(Cad, readw(&PhbP->tx_add)); + PortP->TxStart = (u16 __iomem *) RIO_PTR(Cad, readw(&PhbP->tx_start)); + PortP->TxEnd = (u16 __iomem *) RIO_PTR(Cad, readw(&PhbP->tx_end)); + PortP->RxRemove = (u16 __iomem *) RIO_PTR(Cad, readw(&PhbP->rx_remove)); + PortP->RxStart = (u16 __iomem *) RIO_PTR(Cad, readw(&PhbP->rx_start)); + PortP->RxEnd = (u16 __iomem *) RIO_PTR(Cad, readw(&PhbP->rx_end)); rio_spin_unlock_irqrestore(&PortP->portSem, flags); /* @@ -601,9 +601,9 @@ int RIOBootCodeHOST(struct rio_info *p, struct DownLoad *rbp) * return 1. If we havent, then return 0. */ -int RIOBootRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct PKT *PacketP) +int RIOBootRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct PKT __iomem *PacketP) { - struct PktCmd *PktCmdP = (struct PktCmd *) PacketP->data; + struct PktCmd __iomem *PktCmdP = (struct PktCmd __iomem *) PacketP->data; struct PktCmd_M *PktReplyP; struct CmdBlk *CmdBlkP; unsigned int sequence; @@ -722,7 +722,7 @@ int RIOBootRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct * RtaUniq is the booted RTA. */ -static int RIOBootComplete(struct rio_info *p, struct Host *HostP, unsigned int Rup, struct PktCmd *PktCmdP) +static int RIOBootComplete(struct rio_info *p, struct Host *HostP, unsigned int Rup, struct PktCmd __iomem *PktCmdP) { struct Map *MapP = NULL; struct Map *MapP2 = NULL; diff --git a/drivers/char/rio/riocmd.c b/drivers/char/rio/riocmd.c index e6d2b14b5e6..595f7a9de70 100644 --- a/drivers/char/rio/riocmd.c +++ b/drivers/char/rio/riocmd.c @@ -180,7 +180,7 @@ int RIOCommandRta(struct rio_info *p, unsigned long RtaUnique, int (*func) (stru } -int RIOIdentifyRta(struct rio_info *p, void * arg) +int RIOIdentifyRta(struct rio_info *p, void __user * arg) { unsigned int Host; @@ -245,7 +245,7 @@ int RIOIdentifyRta(struct rio_info *p, void * arg) } -int RIOKillNeighbour(struct rio_info *p, void * arg) +int RIOKillNeighbour(struct rio_info *p, void __user * arg) { uint Host; uint ID; @@ -370,9 +370,9 @@ int RIOFoadWakeup(struct rio_info *p) /* ** Incoming command on the COMMAND_RUP to be processed. */ -static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, struct PKT * PacketP) +static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, struct PKT __iomem *PacketP) { - struct PktCmd *PktCmdP = (struct PktCmd *) PacketP->data; + struct PktCmd __iomem *PktCmdP = (struct PktCmd __iomem *)PacketP->data; struct Port *PortP; struct UnixRup *UnixRupP; unsigned short SysPort; @@ -601,7 +601,7 @@ int RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP) /* ** Whammy! blat that pack! */ - HostP->Copy((caddr_t) & CmdBlkP->Packet, RIO_PTR(HostP->Caddr, UnixRupP->RupP->txpkt), sizeof(struct PKT)); + HostP->Copy(&CmdBlkP->Packet, RIO_PTR(HostP->Caddr, UnixRupP->RupP->txpkt), sizeof(struct PKT)); /* ** place command packet on the pending position. @@ -655,7 +655,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP) { struct CmdBlk *CmdBlkP; struct UnixRup *UnixRupP; - struct PKT *PacketP; + struct PKT __iomem *PacketP; unsigned short Rup; unsigned long flags; @@ -676,7 +676,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP) if (readw(&UnixRupP->RupP->rxcontrol) != RX_RUP_INACTIVE) { int FreeMe; - PacketP = (struct PKT *) RIO_PTR(HostP->Caddr, readw(&UnixRupP->RupP->rxpkt)); + PacketP = (struct PKT __iomem *) RIO_PTR(HostP->Caddr, readw(&UnixRupP->RupP->rxpkt)); switch (readb(&PacketP->dest_port)) { case BOOT_RUP: @@ -696,7 +696,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP) FreeMe = RIOCommandRup(p, Rup, HostP, PacketP); if (PacketP->data[5] == MEMDUMP) { rio_dprintk(RIO_DEBUG_CMD, "Memdump from 0x%x complete\n", *(unsigned short *) & (PacketP->data[6])); - HostP->Copy((caddr_t) & (PacketP->data[8]), (caddr_t) p->RIOMemDump, 32); + HostP->Copy(&(PacketP->data[8]), p->RIOMemDump, 32); } rio_spin_lock_irqsave(&UnixRupP->RupLock, flags); break; @@ -782,7 +782,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP) /* ** Whammy! blat that pack! */ - HostP->Copy((caddr_t) & CmdBlkP->Packet, RIO_PTR(HostP->Caddr, UnixRupP->RupP->txpkt), sizeof(struct PKT)); + HostP->Copy(&CmdBlkP->Packet, RIO_PTR(HostP->Caddr, UnixRupP->RupP->txpkt), sizeof(struct PKT)); /* ** remove the command from the rup command queue... @@ -824,7 +824,7 @@ int RIOWFlushMark(unsigned long iPortP, struct CmdBlk *CmdBlkP) int RIORFlushEnable(unsigned long iPortP, struct CmdBlk *CmdBlkP) { struct Port *PortP = (struct Port *) iPortP; - struct PKT *PacketP; + struct PKT __iomem *PacketP; unsigned long flags; rio_spin_lock_irqsave(&PortP->portSem, flags); diff --git a/drivers/char/rio/rioctrl.c b/drivers/char/rio/rioctrl.c index 75b2557c37e..732e7db5f71 100644 --- a/drivers/char/rio/rioctrl.c +++ b/drivers/char/rio/rioctrl.c @@ -80,7 +80,7 @@ static char *_rioctrl_c_sccs_ = "@(#)rioctrl.c 1.3"; static struct LpbReq LpbReq; static struct RupReq RupReq; static struct PortReq PortReq; -static struct HostReq HostReq; +static struct HostReq HostReq; /* oh really? global? and no locking? */ static struct HostDpRam HostDpRam; static struct DebugCtrl DebugCtrl; static struct Map MapEnt; @@ -126,12 +126,7 @@ static int #define drv_makedev(maj, min) ((((uint) maj & 0xff) << 8) | ((uint) min & 0xff)) -int riocontrol(p, dev, cmd, arg, su) -struct rio_info *p; -dev_t dev; -int cmd; -caddr_t arg; -int su; +int riocontrol(struct rio_info *p, dev_t dev, int cmd, unsigned long arg, int su) { uint Host; /* leave me unsigned! */ uint port; /* and me! */ @@ -139,9 +134,10 @@ int su; ushort loop; int Entry; struct Port *PortP; - struct PKT *PacketP; + struct PKT __iomem *PacketP; int retval = 0; unsigned long flags; + void __user *argp = (void __user *)arg; func_enter(); @@ -149,7 +145,7 @@ int su; Host = 0; PortP = NULL; - rio_dprintk(RIO_DEBUG_CTRL, "control ioctl cmd: 0x%x arg: %p\n", cmd, arg); + rio_dprintk(RIO_DEBUG_CTRL, "control ioctl cmd: 0x%x arg: %p\n", cmd, argp); switch (cmd) { /* @@ -160,11 +156,11 @@ int su; ** otherwise just the specified host card will be changed. */ case RIO_SET_TIMER: - rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_TIMER to %ldms\n", (unsigned long)arg); + rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_TIMER to %ldms\n", arg); { int host, value; - host = ((unsigned long) arg >> 16) & 0x0000FFFF; - value = (unsigned long) arg & 0x0000ffff; + host = (arg >> 16) & 0x0000FFFF; + value = arg & 0x0000ffff; if (host == -1) { for (host = 0; host < p->RIONumHosts; host++) { if (p->RIOHosts[host].Flags == RC_RUNNING) { @@ -183,26 +179,26 @@ int su; case RIO_FOAD_RTA: rio_dprintk(RIO_DEBUG_CTRL, "RIO_FOAD_RTA\n"); - return RIOCommandRta(p, (unsigned long)arg, RIOFoadRta); + return RIOCommandRta(p, arg, RIOFoadRta); case RIO_ZOMBIE_RTA: rio_dprintk(RIO_DEBUG_CTRL, "RIO_ZOMBIE_RTA\n"); - return RIOCommandRta(p, (unsigned long)arg, RIOZombieRta); + return RIOCommandRta(p, arg, RIOZombieRta); case RIO_IDENTIFY_RTA: rio_dprintk(RIO_DEBUG_CTRL, "RIO_IDENTIFY_RTA\n"); - return RIOIdentifyRta(p, arg); + return RIOIdentifyRta(p, argp); case RIO_KILL_NEIGHBOUR: rio_dprintk(RIO_DEBUG_CTRL, "RIO_KILL_NEIGHBOUR\n"); - return RIOKillNeighbour(p, arg); + return RIOKillNeighbour(p, argp); case SPECIAL_RUP_CMD: { struct CmdBlk *CmdBlkP; rio_dprintk(RIO_DEBUG_CTRL, "SPECIAL_RUP_CMD\n"); - if (copy_from_user(&SpecialRupCmd, arg, sizeof(SpecialRupCmd))) { + if (copy_from_user(&SpecialRupCmd, argp, sizeof(SpecialRupCmd))) { rio_dprintk(RIO_DEBUG_CTRL, "SPECIAL_RUP_CMD copy failed\n"); p->RIOError.Error = COPYIN_FAILED; return -EFAULT; @@ -239,7 +235,7 @@ int su; if ((retval = RIOApel(p)) != 0) return retval; - if (copy_to_user(arg, p->RIOConnectTable, TOTAL_MAP_ENTRIES * sizeof(struct Map))) { + if (copy_to_user(argp, p->RIOConnectTable, TOTAL_MAP_ENTRIES * sizeof(struct Map))) { rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_TABLE copy failed\n"); p->RIOError.Error = COPYOUT_FAILED; return -EFAULT; @@ -284,7 +280,7 @@ int su; p->RIOError.Error = NOT_SUPER_USER; return -EPERM; } - if (copy_from_user(&p->RIOConnectTable[0], arg, TOTAL_MAP_ENTRIES * sizeof(struct Map))) { + if (copy_from_user(&p->RIOConnectTable[0], argp, TOTAL_MAP_ENTRIES * sizeof(struct Map))) { rio_dprintk(RIO_DEBUG_CTRL, "RIO_PUT_TABLE copy failed\n"); p->RIOError.Error = COPYIN_FAILED; return -EFAULT; @@ -330,7 +326,7 @@ int su; p->RIOError.Error = NOT_SUPER_USER; return -EPERM; } - if (copy_to_user(arg, p->RIOBindTab, (sizeof(ulong) * MAX_RTA_BINDINGS))) { + if (copy_to_user(argp, p->RIOBindTab, (sizeof(ulong) * MAX_RTA_BINDINGS))) { rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_BINDINGS copy failed\n"); p->RIOError.Error = COPYOUT_FAILED; return -EFAULT; @@ -349,7 +345,7 @@ int su; p->RIOError.Error = NOT_SUPER_USER; return -EPERM; } - if (copy_from_user(&p->RIOBindTab[0], arg, (sizeof(ulong) * MAX_RTA_BINDINGS))) { + if (copy_from_user(&p->RIOBindTab[0], argp, (sizeof(ulong) * MAX_RTA_BINDINGS))) { rio_dprintk(RIO_DEBUG_CTRL, "RIO_PUT_BINDINGS copy failed\n"); p->RIOError.Error = COPYIN_FAILED; return -EFAULT; @@ -373,12 +369,12 @@ int su; for (Entry = 0; Entry < MAX_RTA_BINDINGS; Entry++) { if ((EmptySlot == -1) && (p->RIOBindTab[Entry] == 0L)) EmptySlot = Entry; - else if (p->RIOBindTab[Entry] == (long)arg) { + else if (p->RIOBindTab[Entry] == arg) { /* ** Already exists - delete */ p->RIOBindTab[Entry] = 0L; - rio_dprintk(RIO_DEBUG_CTRL, "Removing Rta %ld from p->RIOBindTab\n", (unsigned long)arg); + rio_dprintk(RIO_DEBUG_CTRL, "Removing Rta %ld from p->RIOBindTab\n", arg); return 0; } } @@ -386,10 +382,10 @@ int su; ** Dosen't exist - add */ if (EmptySlot != -1) { - p->RIOBindTab[EmptySlot] = (unsigned long)arg; - rio_dprintk(RIO_DEBUG_CTRL, "Adding Rta %lx to p->RIOBindTab\n", (unsigned long) arg); + p->RIOBindTab[EmptySlot] = arg; + rio_dprintk(RIO_DEBUG_CTRL, "Adding Rta %lx to p->RIOBindTab\n", arg); } else { - rio_dprintk(RIO_DEBUG_CTRL, "p->RIOBindTab full! - Rta %lx not added\n", (unsigned long) arg); + rio_dprintk(RIO_DEBUG_CTRL, "p->RIOBindTab full! - Rta %lx not added\n", arg); return -ENOMEM; } return 0; @@ -397,7 +393,7 @@ int su; case RIO_RESUME: rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESUME\n"); - port = (unsigned long) arg; + port = arg; if ((port < 0) || (port > 511)) { rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESUME: Bad port number %d\n", port); p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE; @@ -433,7 +429,7 @@ int su; p->RIOError.Error = NOT_SUPER_USER; return -EPERM; } - if (copy_from_user(&MapEnt, arg, sizeof(MapEnt))) { + if (copy_from_user(&MapEnt, argp, sizeof(MapEnt))) { rio_dprintk(RIO_DEBUG_CTRL, "Copy from user space failed\n"); p->RIOError.Error = COPYIN_FAILED; return -EFAULT; @@ -447,7 +443,7 @@ int su; p->RIOError.Error = NOT_SUPER_USER; return -EPERM; } - if (copy_from_user(&MapEnt, arg, sizeof(MapEnt))) { + if (copy_from_user(&MapEnt, argp, sizeof(MapEnt))) { rio_dprintk(RIO_DEBUG_CTRL, "Copy from user space failed\n"); p->RIOError.Error = COPYIN_FAILED; return -EFAULT; @@ -461,7 +457,7 @@ int su; p->RIOError.Error = NOT_SUPER_USER; return -EPERM; } - if (copy_from_user(&MapEnt, arg, sizeof(MapEnt))) { + if (copy_from_user(&MapEnt, argp, sizeof(MapEnt))) { rio_dprintk(RIO_DEBUG_CTRL, "Copy from data space failed\n"); p->RIOError.Error = COPYIN_FAILED; return -EFAULT; @@ -469,14 +465,14 @@ int su; return RIODeleteRta(p, &MapEnt); case RIO_QUICK_CHECK: - if (copy_to_user(arg, &p->RIORtaDisCons, sizeof(unsigned int))) { + if (copy_to_user(argp, &p->RIORtaDisCons, sizeof(unsigned int))) { p->RIOError.Error = COPYOUT_FAILED; return -EFAULT; } return 0; case RIO_LAST_ERROR: - if (copy_to_user(arg, &p->RIOError, sizeof(struct Error))) + if (copy_to_user(argp, &p->RIOError, sizeof(struct Error))) return -EFAULT; return 0; @@ -485,7 +481,7 @@ int su; return -EINVAL; case RIO_GET_MODTYPE: - if (copy_from_user(&port, arg, sizeof(unsigned int))) { + if (copy_from_user(&port, argp, sizeof(unsigned int))) { p->RIOError.Error = COPYIN_FAILED; return -EFAULT; } @@ -505,7 +501,7 @@ int su; ** Return module type of port */ port = PortP->HostP->UnixRups[PortP->RupNum].ModTypes; - if (copy_to_user(arg, &port, sizeof(unsigned int))) { + if (copy_to_user(argp, &port, sizeof(unsigned int))) { p->RIOError.Error = COPYOUT_FAILED; return -EFAULT; } @@ -521,7 +517,7 @@ int su; case RIO_SETUP_PORTS: rio_dprintk(RIO_DEBUG_CTRL, "Setup ports\n"); - if (copy_from_user(&PortSetup, arg, sizeof(PortSetup))) { + if (copy_from_user(&PortSetup, argp, sizeof(PortSetup))) { p->RIOError.Error = COPYIN_FAILED; rio_dprintk(RIO_DEBUG_CTRL, "EFAULT"); return -EFAULT; @@ -551,7 +547,7 @@ int su; case RIO_GET_PORT_SETUP: rio_dprintk(RIO_DEBUG_CTRL, "Get port setup\n"); - if (copy_from_user(&PortSetup, arg, sizeof(PortSetup))) { + if (copy_from_user(&PortSetup, argp, sizeof(PortSetup))) { p->RIOError.Error = COPYIN_FAILED; return -EFAULT; } @@ -572,7 +568,7 @@ int su; PortSetup.XpOn[MAX_XP_CTRL_LEN - 1] = '\0'; PortSetup.XpOff[MAX_XP_CTRL_LEN - 1] = '\0'; - if (copy_to_user(arg, &PortSetup, sizeof(PortSetup))) { + if (copy_to_user(argp, &PortSetup, sizeof(PortSetup))) { p->RIOError.Error = COPYOUT_FAILED; return -EFAULT; } @@ -580,7 +576,7 @@ int su; case RIO_GET_PORT_PARAMS: rio_dprintk(RIO_DEBUG_CTRL, "Get port params\n"); - if (copy_from_user(&PortParams, arg, sizeof(struct PortParams))) { + if (copy_from_user(&PortParams, argp, sizeof(struct PortParams))) { p->RIOError.Error = COPYIN_FAILED; return -EFAULT; } @@ -593,7 +589,7 @@ int su; PortParams.State = PortP->State; rio_dprintk(RIO_DEBUG_CTRL, "Port %d\n", PortParams.Port); - if (copy_to_user(arg, &PortParams, sizeof(struct PortParams))) { + if (copy_to_user(argp, &PortParams, sizeof(struct PortParams))) { p->RIOError.Error = COPYOUT_FAILED; return -EFAULT; } @@ -601,7 +597,7 @@ int su; case RIO_GET_PORT_TTY: rio_dprintk(RIO_DEBUG_CTRL, "Get port tty\n"); - if (copy_from_user(&PortTty, arg, sizeof(struct PortTty))) { + if (copy_from_user(&PortTty, argp, sizeof(struct PortTty))) { p->RIOError.Error = COPYIN_FAILED; return -EFAULT; } @@ -612,14 +608,14 @@ int su; rio_dprintk(RIO_DEBUG_CTRL, "Port %d\n", PortTty.port); PortP = (p->RIOPortp[PortTty.port]); - if (copy_to_user(arg, &PortTty, sizeof(struct PortTty))) { + if (copy_to_user(argp, &PortTty, sizeof(struct PortTty))) { p->RIOError.Error = COPYOUT_FAILED; return -EFAULT; } return retval; case RIO_SET_PORT_TTY: - if (copy_from_user(&PortTty, arg, sizeof(struct PortTty))) { + if (copy_from_user(&PortTty, argp, sizeof(struct PortTty))) { p->RIOError.Error = COPYIN_FAILED; return -EFAULT; } @@ -634,7 +630,7 @@ int su; case RIO_SET_PORT_PARAMS: rio_dprintk(RIO_DEBUG_CTRL, "Set port params\n"); - if (copy_from_user(&PortParams, arg, sizeof(PortParams))) { + if (copy_from_user(&PortParams, argp, sizeof(PortParams))) { p->RIOError.Error = COPYIN_FAILED; return -EFAULT; } @@ -650,7 +646,7 @@ int su; case RIO_GET_PORT_STATS: rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_PORT_STATS\n"); - if (copy_from_user(&portStats, arg, sizeof(struct portStats))) { + if (copy_from_user(&portStats, argp, sizeof(struct portStats))) { p->RIOError.Error = COPYIN_FAILED; return -EFAULT; } @@ -665,14 +661,14 @@ int su; portStats.opens = PortP->opens; portStats.closes = PortP->closes; portStats.ioctls = PortP->ioctls; - if (copy_to_user(arg, &portStats, sizeof(struct portStats))) { + if (copy_to_user(argp, &portStats, sizeof(struct portStats))) { p->RIOError.Error = COPYOUT_FAILED; return -EFAULT; } return retval; case RIO_RESET_PORT_STATS: - port = (unsigned long) arg; + port = arg; rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESET_PORT_STATS\n"); if (port >= RIO_PORTS) { p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE; @@ -690,7 +686,7 @@ int su; case RIO_GATHER_PORT_STATS: rio_dprintk(RIO_DEBUG_CTRL, "RIO_GATHER_PORT_STATS\n"); - if (copy_from_user(&portStats, arg, sizeof(struct portStats))) { + if (copy_from_user(&portStats, argp, sizeof(struct portStats))) { p->RIOError.Error = COPYIN_FAILED; return -EFAULT; } @@ -706,7 +702,7 @@ int su; case RIO_READ_CONFIG: rio_dprintk(RIO_DEBUG_CTRL, "RIO_READ_CONFIG\n"); - if (copy_to_user(arg, &p->RIOConf, sizeof(struct Conf))) { + if (copy_to_user(argp, &p->RIOConf, sizeof(struct Conf))) { p->RIOError.Error = COPYOUT_FAILED; return -EFAULT; } @@ -718,7 +714,7 @@ int su; p->RIOError.Error = NOT_SUPER_USER; return -EPERM; } - if (copy_from_user(&p->RIOConf, arg, sizeof(struct Conf))) { + if (copy_from_user(&p->RIOConf, argp, sizeof(struct Conf))) { p->RIOError.Error = COPYIN_FAILED; return -EFAULT; } @@ -746,7 +742,7 @@ int su; case RIO_SETDEBUG: case RIO_GETDEBUG: rio_dprintk(RIO_DEBUG_CTRL, "RIO_SETDEBUG/RIO_GETDEBUG\n"); - if (copy_from_user(&DebugCtrl, arg, sizeof(DebugCtrl))) { + if (copy_from_user(&DebugCtrl, argp, sizeof(DebugCtrl))) { p->RIOError.Error = COPYIN_FAILED; return -EFAULT; } @@ -763,7 +759,7 @@ int su; rio_dprintk(RIO_DEBUG_CTRL, "Get global debug 0x%x wait 0x%x\n", p->rio_debug, p->RIODebugWait); DebugCtrl.Debug = p->rio_debug; DebugCtrl.Wait = p->RIODebugWait; - if (copy_to_user(arg, &DebugCtrl, sizeof(DebugCtrl))) { + if (copy_to_user(argp, &DebugCtrl, sizeof(DebugCtrl))) { rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET/GET DEBUG: bad port number %d\n", DebugCtrl.SysPort); p->RIOError.Error = COPYOUT_FAILED; return -EFAULT; @@ -785,7 +781,7 @@ int su; } else { rio_dprintk(RIO_DEBUG_CTRL, "RIO_GETDEBUG 0x%x\n", p->RIOPortp[DebugCtrl.SysPort]->Debug); DebugCtrl.Debug = p->RIOPortp[DebugCtrl.SysPort]->Debug; - if (copy_to_user(arg, &DebugCtrl, sizeof(DebugCtrl))) { + if (copy_to_user(argp, &DebugCtrl, sizeof(DebugCtrl))) { rio_dprintk(RIO_DEBUG_CTRL, "RIO_GETDEBUG: Bad copy to user space\n"); p->RIOError.Error = COPYOUT_FAILED; return -EFAULT; @@ -800,7 +796,7 @@ int su; ** textual null terminated string. */ rio_dprintk(RIO_DEBUG_CTRL, "RIO_VERSID\n"); - if (copy_to_user(arg, RIOVersid(), sizeof(struct rioVersion))) { + if (copy_to_user(argp, RIOVersid(), sizeof(struct rioVersion))) { rio_dprintk(RIO_DEBUG_CTRL, "RIO_VERSID: Bad copy to user space (host=%d)\n", Host); p->RIOError.Error = COPYOUT_FAILED; return -EFAULT; @@ -813,7 +809,7 @@ int su; ** at init time. */ rio_dprintk(RIO_DEBUG_CTRL, "RIO_NUM_HOSTS\n"); - if (copy_to_user(arg, &p->RIONumHosts, sizeof(p->RIONumHosts))) { + if (copy_to_user(argp, &p->RIONumHosts, sizeof(p->RIONumHosts))) { rio_dprintk(RIO_DEBUG_CTRL, "RIO_NUM_HOSTS: Bad copy to user space\n"); p->RIOError.Error = COPYOUT_FAILED; return -EFAULT; @@ -824,7 +820,7 @@ int su; /* ** Kill host. This may not be in the final version... */ - rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_FOAD %ld\n", (unsigned long) arg); + rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_FOAD %ld\n", arg); if (!su) { rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_FOAD: Not super user\n"); p->RIOError.Error = NOT_SUPER_USER; @@ -858,7 +854,7 @@ int su; p->RIOError.Error = NOT_SUPER_USER; return -EPERM; } - if (copy_from_user(&DownLoad, arg, sizeof(DownLoad))) { + if (copy_from_user(&DownLoad, argp, sizeof(DownLoad))) { rio_dprintk(RIO_DEBUG_CTRL, "RIO_DOWNLOAD: Copy in from user space failed\n"); p->RIOError.Error = COPYIN_FAILED; return -EFAULT; @@ -888,7 +884,7 @@ int su; { unsigned int host; - if (copy_from_user(&host, arg, sizeof(host))) { + if (copy_from_user(&host, argp, sizeof(host))) { rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ: Copy in from user space failed\n"); p->RIOError.Error = COPYIN_FAILED; return -EFAULT; @@ -897,7 +893,7 @@ int su; ** Fetch the parmmap */ rio_dprintk(RIO_DEBUG_CTRL, "RIO_PARMS\n"); - if (copy_to_user(arg, p->RIOHosts[host].ParmMapP, sizeof(PARM_MAP))) { + if (copy_to_user(argp, p->RIOHosts[host].ParmMapP, sizeof(PARM_MAP))) { p->RIOError.Error = COPYOUT_FAILED; rio_dprintk(RIO_DEBUG_CTRL, "RIO_PARMS: Copy out to user space failed\n"); return -EFAULT; @@ -907,7 +903,7 @@ int su; case RIO_HOST_REQ: rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ\n"); - if (copy_from_user(&HostReq, arg, sizeof(HostReq))) { + if (copy_from_user(&HostReq, argp, sizeof(HostReq))) { rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ: Copy in from user space failed\n"); p->RIOError.Error = COPYIN_FAILED; return -EFAULT; @@ -928,7 +924,7 @@ int su; case RIO_HOST_DPRAM: rio_dprintk(RIO_DEBUG_CTRL, "Request for DPRAM\n"); - if (copy_from_user(&HostDpRam, arg, sizeof(HostDpRam))) { + if (copy_from_user(&HostDpRam, argp, sizeof(HostDpRam))) { rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Copy in from user space failed\n"); p->RIOError.Error = COPYIN_FAILED; return -EFAULT; @@ -945,7 +941,7 @@ int su; /* It's hardware like this that really gets on my tits. */ static unsigned char copy[sizeof(struct DpRam)]; for (off = 0; off < sizeof(struct DpRam); off++) - copy[off] = readb(&p->RIOHosts[HostDpRam.HostNum].Caddr[off]); + copy[off] = readb(p->RIOHosts[HostDpRam.HostNum].Caddr + off); if (copy_to_user(HostDpRam.DpRamP, copy, sizeof(struct DpRam))) { p->RIOError.Error = COPYOUT_FAILED; rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Bad copy to user space\n"); @@ -960,13 +956,13 @@ int su; case RIO_SET_BUSY: rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_BUSY\n"); - if ((unsigned long) arg > 511) { - rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_BUSY: Bad port number %ld\n", (unsigned long) arg); + if (arg > 511) { + rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_BUSY: Bad port number %ld\n", arg); p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE; return -EINVAL; } rio_spin_lock_irqsave(&PortP->portSem, flags); - p->RIOPortp[(unsigned long) arg]->State |= RIO_BUSY; + p->RIOPortp[arg]->State |= RIO_BUSY; rio_spin_unlock_irqrestore(&PortP->portSem, flags); return retval; @@ -976,7 +972,7 @@ int su; ** (probably for debug reasons) */ rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_PORT\n"); - if (copy_from_user(&PortReq, arg, sizeof(PortReq))) { + if (copy_from_user(&PortReq, argp, sizeof(PortReq))) { rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_PORT: Copy in from user space failed\n"); p->RIOError.Error = COPYIN_FAILED; return -EFAULT; @@ -1001,7 +997,7 @@ int su; ** (probably for debug reasons) */ rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_RUP\n"); - if (copy_from_user(&RupReq, arg, sizeof(RupReq))) { + if (copy_from_user(&RupReq, argp, sizeof(RupReq))) { rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_RUP: Copy in from user space failed\n"); p->RIOError.Error = COPYIN_FAILED; return -EFAULT; @@ -1038,7 +1034,7 @@ int su; ** (probably for debug reasons) */ rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_LPB\n"); - if (copy_from_user(&LpbReq, arg, sizeof(LpbReq))) { + if (copy_from_user(&LpbReq, argp, sizeof(LpbReq))) { rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_LPB: Bad copy from user space\n"); p->RIOError.Error = COPYIN_FAILED; return -EFAULT; @@ -1136,7 +1132,7 @@ int su; case RIO_MAP_B110_TO_110: case RIO_MAP_B110_TO_115200: rio_dprintk(RIO_DEBUG_CTRL, "Baud rate mapping\n"); - port = (unsigned long) arg; + port = arg; if (port < 0 || port > 511) { rio_dprintk(RIO_DEBUG_CTRL, "Baud rate mapping: Bad port number %d\n", port); p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE; @@ -1166,7 +1162,7 @@ int su; case RIO_SEND_PACKET: rio_dprintk(RIO_DEBUG_CTRL, "RIO_SEND_PACKET\n"); - if (copy_from_user(&SendPack, arg, sizeof(SendPack))) { + if (copy_from_user(&SendPack, argp, sizeof(SendPack))) { rio_dprintk(RIO_DEBUG_CTRL, "RIO_SEND_PACKET: Bad copy from user space\n"); p->RIOError.Error = COPYIN_FAILED; return -EFAULT; @@ -1210,7 +1206,7 @@ int su; return su ? 0 : -EPERM; case RIO_WHAT_MESG: - if (copy_to_user(arg, &p->RIONoMessage, sizeof(p->RIONoMessage))) { + if (copy_to_user(argp, &p->RIONoMessage, sizeof(p->RIONoMessage))) { rio_dprintk(RIO_DEBUG_CTRL, "RIO_WHAT_MESG: Bad copy to user space\n"); p->RIOError.Error = COPYOUT_FAILED; return -EFAULT; @@ -1218,7 +1214,7 @@ int su; return 0; case RIO_MEM_DUMP: - if (copy_from_user(&SubCmd, arg, sizeof(struct SubCmdStruct))) { + if (copy_from_user(&SubCmd, argp, sizeof(struct SubCmdStruct))) { p->RIOError.Error = COPYIN_FAILED; return -EFAULT; } @@ -1248,7 +1244,7 @@ int su; PortP->State |= RIO_BUSY; rio_spin_unlock_irqrestore(&PortP->portSem, flags); - if (copy_to_user(arg, p->RIOMemDump, MEMDUMP_SIZE)) { + if (copy_to_user(argp, p->RIOMemDump, MEMDUMP_SIZE)) { rio_dprintk(RIO_DEBUG_CTRL, "RIO_MEM_DUMP copy failed\n"); p->RIOError.Error = COPYOUT_FAILED; return -EFAULT; @@ -1256,30 +1252,30 @@ int su; return 0; case RIO_TICK: - if ((unsigned long) arg >= p->RIONumHosts) + if (arg >= p->RIONumHosts) return -EINVAL; - rio_dprintk(RIO_DEBUG_CTRL, "Set interrupt for host %ld\n", (unsigned long) arg); - writeb(0xFF, &p->RIOHosts[(unsigned long) arg].SetInt); + rio_dprintk(RIO_DEBUG_CTRL, "Set interrupt for host %ld\n", arg); + writeb(0xFF, &p->RIOHosts[arg].SetInt); return 0; case RIO_TOCK: - if ((unsigned long) arg >= p->RIONumHosts) + if (arg >= p->RIONumHosts) return -EINVAL; - rio_dprintk(RIO_DEBUG_CTRL, "Clear interrupt for host %ld\n", (unsigned long) arg); - writeb(0xFF, &p->RIOHosts[(unsigned long) arg].ResetInt); + rio_dprintk(RIO_DEBUG_CTRL, "Clear interrupt for host %ld\n", arg); + writeb(0xFF, &p->RIOHosts[arg].ResetInt); return 0; case RIO_READ_CHECK: /* Check reads for pkts with data[0] the same */ p->RIOReadCheck = !p->RIOReadCheck; - if (copy_to_user(arg, &p->RIOReadCheck, sizeof(unsigned int))) { + if (copy_to_user(argp, &p->RIOReadCheck, sizeof(unsigned int))) { p->RIOError.Error = COPYOUT_FAILED; return -EFAULT; } return 0; case RIO_READ_REGISTER: - if (copy_from_user(&SubCmd, arg, sizeof(struct SubCmdStruct))) { + if (copy_from_user(&SubCmd, argp, sizeof(struct SubCmdStruct))) { p->RIOError.Error = COPYIN_FAILED; return -EFAULT; } @@ -1314,7 +1310,7 @@ int su; PortP->State |= RIO_BUSY; rio_spin_unlock_irqrestore(&PortP->portSem, flags); - if (copy_to_user(arg, &p->CdRegister, sizeof(unsigned int))) { + if (copy_to_user(argp, &p->CdRegister, sizeof(unsigned int))) { rio_dprintk(RIO_DEBUG_CTRL, "RIO_READ_REGISTER copy failed\n"); p->RIOError.Error = COPYOUT_FAILED; return -EFAULT; @@ -1327,10 +1323,10 @@ int su; */ case RIO_MAKE_DEV: { - unsigned int port = (unsigned long) arg & RIO_MODEM_MASK; + unsigned int port = arg & RIO_MODEM_MASK; unsigned int ret; - switch ((unsigned long) arg & RIO_DEV_MASK) { + switch (arg & RIO_DEV_MASK) { case RIO_DEV_DIRECT: ret = drv_makedev(MAJOR(dev), port); rio_dprintk(RIO_DEBUG_CTRL, "Makedev direct 0x%x is 0x%x\n", port, ret); @@ -1358,7 +1354,7 @@ int su; int mino; unsigned long ret; - dv = (dev_t) ((unsigned long) arg); + dv = (dev_t) (arg); mino = RIO_UNMODEM(dv); if (RIO_ISMODEM(dv)) { diff --git a/drivers/char/rio/rioinit.c b/drivers/char/rio/rioinit.c index 24d2992154c..12e34bc3f7c 100644 --- a/drivers/char/rio/rioinit.c +++ b/drivers/char/rio/rioinit.c @@ -79,7 +79,7 @@ static char *_rioinit_c_sccs_ = "@(#)rioinit.c 1.3"; int RIOPCIinit(struct rio_info *p, int Mode); -static int RIOScrub(int, u8 *, int); +static int RIOScrub(int, u8 __iomem *, int); /** @@ -92,10 +92,10 @@ static int RIOScrub(int, u8 *, int); ** bits > 0 indicates 16 bit operation. */ -int RIOAssignAT(struct rio_info *p, int Base, caddr_t virtAddr, int mode) +int RIOAssignAT(struct rio_info *p, int Base, void __iomem *virtAddr, int mode) { int bits; - struct DpRam *cardp = (struct DpRam *)virtAddr; + struct DpRam __iomem *cardp = (struct DpRam __iomem *)virtAddr; if ((Base < ONE_MEG) || (mode & BYTE_ACCESS_MODE)) bits = BYTE_OPERATION; @@ -107,7 +107,7 @@ int RIOAssignAT(struct rio_info *p, int Base, caddr_t virtAddr, int mode) ** transient stuff. */ p->RIOHosts[p->RIONumHosts].Caddr = virtAddr; - p->RIOHosts[p->RIONumHosts].CardP = (struct DpRam *)virtAddr; + p->RIOHosts[p->RIONumHosts].CardP = virtAddr; /* ** Revision 01 AT host cards don't support WORD operations, @@ -151,10 +151,10 @@ static u8 val[] = { ** RAM test a board. ** Nothing too complicated, just enough to check it out. */ -int RIOBoardTest(unsigned long paddr, caddr_t caddr, unsigned char type, int slot) +int RIOBoardTest(unsigned long paddr, void __iomem *caddr, unsigned char type, int slot) { - struct DpRam *DpRam = (struct DpRam *)caddr; - char *ram[4]; + struct DpRam __iomem *DpRam = caddr; + void __iomem *ram[4]; int size[4]; int op, bank; int nbanks; @@ -179,12 +179,12 @@ int RIOBoardTest(unsigned long paddr, caddr_t caddr, unsigned char type, int slo size[2] = DP_SRAM3_SIZE; size[3] = DP_SCRATCH_SIZE; - ram[0] = (char *)&DpRam->DpSram1[0]; - ram[1] = (char *)&DpRam->DpSram2[0]; - ram[2] = (char *)&DpRam->DpSram3[0]; + ram[0] = DpRam->DpSram1; + ram[1] = DpRam->DpSram2; + ram[2] = DpRam->DpSram3; nbanks = (type == RIO_PCI) ? 3 : 4; if (nbanks == 4) - ram[3] = (char *)&DpRam->DpScratch[0]; + ram[3] = DpRam->DpScratch; if (nbanks == 3) { @@ -202,7 +202,7 @@ int RIOBoardTest(unsigned long paddr, caddr_t caddr, unsigned char type, int slo */ for (op=0; opHostP->Caddr, (caddr_t) PacketP->data, PortP->gs.xmit_buf + PortP->gs.xmit_tail, c); + rio_memcpy_toio(PortP->HostP->Caddr, PacketP->data, PortP->gs.xmit_buf + PortP->gs.xmit_tail, c); /* udelay (1); */ writeb(c, &(PacketP->len)); @@ -219,7 +219,7 @@ void RIOServiceHost(struct rio_info *p, struct Host *HostP, int From) for (port = p->RIOFirstPortsBooted; port < p->RIOLastPortsBooted + PORTS_PER_RTA; port++) { struct Port *PortP = p->RIOPortp[port]; struct tty_struct *ttyP; - struct PKT *PacketP; + struct PKT __iomem *PacketP; /* ** not mapped in - most of the RIOPortp[] information @@ -298,7 +298,7 @@ void RIOServiceHost(struct rio_info *p, struct Host *HostP, int From) for (port = p->RIOFirstPortsBooted; port < p->RIOLastPortsBooted + PORTS_PER_RTA; port++) { struct Port *PortP = p->RIOPortp[port]; struct tty_struct *ttyP; - struct PKT *PacketP; + struct PKT __iomem *PacketP; /* ** not mapped in - most of the RIOPortp[] information @@ -427,13 +427,13 @@ void RIOServiceHost(struct rio_info *p, struct Host *HostP, int From) while (PortP->WflushFlag && can_add_transmit(&PacketP, PortP) && (PortP->InUse == NOT_INUSE)) { int p; - struct PktCmd *PktCmdP; + struct PktCmd __iomem *PktCmdP; rio_dprintk(RIO_DEBUG_INTR, "Add WFLUSH marker to data queue\n"); /* ** make it look just like a WFLUSH command */ - PktCmdP = (struct PktCmd *) &PacketP->data[0]; + PktCmdP = (struct PktCmd __iomem *) &PacketP->data[0]; writeb(WFLUSH, &PktCmdP->Command); @@ -525,9 +525,9 @@ static void RIOReceive(struct rio_info *p, struct Port *PortP) { struct tty_struct *TtyP; unsigned short transCount; - struct PKT *PacketP; + struct PKT __iomem *PacketP; register unsigned int DataCnt; - unsigned char *ptr; + unsigned char __iomem *ptr; unsigned char *buf; int copied = 0; @@ -625,7 +625,7 @@ static void RIOReceive(struct rio_info *p, struct Port *PortP) ** to '#define', (this is the only place ___DEBUG_IT___ occurs in the ** driver). */ - ptr = (unsigned char *) PacketP->data + PortP->RxDataStart; + ptr = (unsigned char __iomem *) PacketP->data + PortP->RxDataStart; tty_prepare_flip_string(TtyP, &buf, transCount); rio_memcpy_fromio(buf, ptr, transCount); diff --git a/drivers/char/rio/rioparam.c b/drivers/char/rio/rioparam.c index d2e8092cdb2..1066d976070 100644 --- a/drivers/char/rio/rioparam.c +++ b/drivers/char/rio/rioparam.c @@ -154,8 +154,8 @@ int RIOParam(struct Port *PortP, int cmd, int Modem, int SleepFlag) { struct tty_struct *TtyP; int retval; - struct phb_param *phb_param_ptr; - struct PKT *PacketP; + struct phb_param __iomem *phb_param_ptr; + struct PKT __iomem *PacketP; int res; u8 Cor1 = 0, Cor2 = 0, Cor4 = 0, Cor5 = 0; u8 TxXon = 0, TxXoff = 0, RxXon = 0, RxXoff = 0; @@ -235,7 +235,7 @@ int RIOParam(struct Port *PortP, int cmd, int Modem, int SleepFlag) rio_dprintk(RIO_DEBUG_PARAM, "can_add_transmit() returns %x\n", res); rio_dprintk(RIO_DEBUG_PARAM, "Packet is %p\n", PacketP); - phb_param_ptr = (struct phb_param *) PacketP->data; + phb_param_ptr = (struct phb_param __iomem *) PacketP->data; switch (TtyP->termios->c_cflag & CSIZE) { @@ -580,11 +580,11 @@ int RIOParam(struct Port *PortP, int cmd, int Modem, int SleepFlag) ** We can add another packet to a transmit queue if the packet pointer pointed ** to by the TxAdd pointer has PKT_IN_USE clear in its address. */ -int can_add_transmit(struct PKT **PktP, struct Port *PortP) +int can_add_transmit(struct PKT __iomem **PktP, struct Port *PortP) { - struct PKT *tp; + struct PKT __iomem *tp; - *PktP = tp = (struct PKT *) RIO_PTR(PortP->Caddr, readw(PortP->TxAdd)); + *PktP = tp = (struct PKT __iomem *) RIO_PTR(PortP->Caddr, readw(PortP->TxAdd)); return !((unsigned long) tp & PKT_IN_USE); } @@ -608,9 +608,9 @@ void add_transmit(struct Port *PortP) * Put a packet onto the end of the * free list ****************************************/ -void put_free_end(struct Host *HostP, struct PKT *PktP) +void put_free_end(struct Host *HostP, struct PKT __iomem *PktP) { - struct rio_free_list *tmp_pointer; + struct rio_free_list __iomem *tmp_pointer; unsigned short old_end, new_end; unsigned long flags; @@ -625,15 +625,15 @@ void put_free_end(struct Host *HostP, struct PKT *PktP) if ((old_end = readw(&HostP->ParmMapP->free_list_end)) != TPNULL) { new_end = RIO_OFF(HostP->Caddr, PktP); - tmp_pointer = (struct rio_free_list *) RIO_PTR(HostP->Caddr, old_end); + tmp_pointer = (struct rio_free_list __iomem *) RIO_PTR(HostP->Caddr, old_end); writew(new_end, &tmp_pointer->next); - writew(old_end, &((struct rio_free_list *) PktP)->prev); - writew(TPNULL, &((struct rio_free_list *) PktP)->next); + writew(old_end, &((struct rio_free_list __iomem *) PktP)->prev); + writew(TPNULL, &((struct rio_free_list __iomem *) PktP)->next); writew(new_end, &HostP->ParmMapP->free_list_end); } else { /* First packet on the free list this should never happen! */ rio_dprintk(RIO_DEBUG_PFE, "put_free_end(): This should never happen\n"); writew(RIO_OFF(HostP->Caddr, PktP), &HostP->ParmMapP->free_list_end); - tmp_pointer = (struct rio_free_list *) PktP; + tmp_pointer = (struct rio_free_list __iomem *) PktP; writew(TPNULL, &tmp_pointer->prev); writew(TPNULL, &tmp_pointer->next); } @@ -647,10 +647,10 @@ void put_free_end(struct Host *HostP, struct PKT *PktP) ** relevant packet, [having cleared the PKT_IN_USE bit]. If PKT_IN_USE is clear, ** then can_remove_receive() returns 0. */ -int can_remove_receive(struct PKT **PktP, struct Port *PortP) +int can_remove_receive(struct PKT __iomem **PktP, struct Port *PortP) { if (readw(PortP->RxRemove) & PKT_IN_USE) { - *PktP = (struct PKT *) RIO_PTR(PortP->Caddr, readw(PortP->RxRemove) & ~PKT_IN_USE); + *PktP = (struct PKT __iomem *) RIO_PTR(PortP->Caddr, readw(PortP->RxRemove) & ~PKT_IN_USE); return 1; } return 0; diff --git a/drivers/char/rio/rioroute.c b/drivers/char/rio/rioroute.c index 35708533794..376d0e353dc 100644 --- a/drivers/char/rio/rioroute.c +++ b/drivers/char/rio/rioroute.c @@ -86,9 +86,9 @@ static void RIOConCon(struct rio_info *, struct Host *, unsigned int, unsigned i ** Incoming on the ROUTE_RUP ** I wrote this while I was tired. Forgive me. */ -int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct PKT * PacketP) +int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct PKT __iomem * PacketP) { - struct PktCmd *PktCmdP = (struct PktCmd *) PacketP->data; + struct PktCmd __iomem *PktCmdP = (struct PktCmd __iomem *) PacketP->data; struct PktCmd_M *PktReplyP; struct CmdBlk *CmdBlkP; struct Port *PortP; @@ -517,8 +517,8 @@ void RIOFixPhbs(struct rio_info *p, struct Host *HostP, unsigned int unit) for (port = 0; port < PORTS_PER_RTA; port++, PortN++) { unsigned short dest_port = port + 8; - u16 *TxPktP; - struct PKT *Pkt; + u16 __iomem *TxPktP; + struct PKT __iomem *Pkt; PortP = p->RIOPortp[PortN]; @@ -555,12 +555,12 @@ void RIOFixPhbs(struct rio_info *p, struct Host *HostP, unsigned int unit) ** card. This needs to be translated into a 32 bit pointer ** so it can be accessed from the driver. */ - Pkt = (struct PKT *) RIO_PTR(HostP->Caddr, readw(TxPktP)); + Pkt = (struct PKT __iomem *) RIO_PTR(HostP->Caddr, readw(TxPktP)); /* ** If the packet is used, reset it. */ - Pkt = (struct PKT *) ((unsigned long) Pkt & ~PKT_IN_USE); + Pkt = (struct PKT __iomem *) ((unsigned long) Pkt & ~PKT_IN_USE); writeb(dest_unit, &Pkt->dest_unit); writeb(dest_port, &Pkt->dest_port); } diff --git a/drivers/char/rio/riotable.c b/drivers/char/rio/riotable.c index d3abe0d37d6..364119e975b 100644 --- a/drivers/char/rio/riotable.c +++ b/drivers/char/rio/riotable.c @@ -534,8 +534,8 @@ int RIODeleteRta(struct rio_info *p, struct Map *MapP) if (PortP->SecondBlock) { u16 dest_unit = HostMapP->ID; u16 dest_port = port - SysPort; - u16 *TxPktP; - struct PKT *Pkt; + u16 __iomem *TxPktP; + struct PKT __iomem *Pkt; for (TxPktP = PortP->TxStart; TxPktP <= PortP->TxEnd; TxPktP++) { /* @@ -545,7 +545,7 @@ int RIODeleteRta(struct rio_info *p, struct Map *MapP) ** a 32 bit pointer so it can be ** accessed from the driver. */ - Pkt = (struct PKT *) RIO_PTR(HostP->Caddr, readw(&*TxPktP)); + Pkt = (struct PKT __iomem *) RIO_PTR(HostP->Caddr, readw(&*TxPktP)); rio_dprintk(RIO_DEBUG_TABLE, "Tx packet (%x) destination: Old %x:%x New %x:%x\n", *TxPktP, Pkt->dest_unit, Pkt->dest_port, dest_unit, dest_port); writew(dest_unit, &Pkt->dest_unit); writew(dest_port, &Pkt->dest_port); @@ -781,13 +781,13 @@ int RIOReMapPorts(struct rio_info *p, struct Host *HostP, struct Map *HostMapP) ** unless the host has been booted */ if ((HostP->Flags & RUN_STATE) == RC_RUNNING) { - struct PHB *PhbP = PortP->PhbP = &HostP->PhbP[HostPort]; - PortP->TxAdd = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->tx_add)); - PortP->TxStart = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->tx_start)); - PortP->TxEnd = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->tx_end)); - PortP->RxRemove = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->rx_remove)); - PortP->RxStart = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->rx_start)); - PortP->RxEnd = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->rx_end)); + struct PHB __iomem *PhbP = PortP->PhbP = &HostP->PhbP[HostPort]; + PortP->TxAdd = (u16 __iomem *) RIO_PTR(HostP->Caddr, readw(&PhbP->tx_add)); + PortP->TxStart = (u16 __iomem *) RIO_PTR(HostP->Caddr, readw(&PhbP->tx_start)); + PortP->TxEnd = (u16 __iomem *) RIO_PTR(HostP->Caddr, readw(&PhbP->tx_end)); + PortP->RxRemove = (u16 __iomem *) RIO_PTR(HostP->Caddr, readw(&PhbP->rx_remove)); + PortP->RxStart = (u16 __iomem *) RIO_PTR(HostP->Caddr, readw(&PhbP->rx_start)); + PortP->RxEnd = (u16 __iomem *) RIO_PTR(HostP->Caddr, readw(&PhbP->rx_end)); } else PortP->PhbP = NULL; diff --git a/drivers/char/rio/riotty.c b/drivers/char/rio/riotty.c index 204267613c9..a4f0b1e3e7f 100644 --- a/drivers/char/rio/riotty.c +++ b/drivers/char/rio/riotty.c @@ -576,7 +576,7 @@ static void RIOClearUp(struct Port *PortP) */ int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, int len, int arg) { - struct PKT *PacketP; + struct PKT __iomem *PacketP; int retries = 20; /* at 10 per second -> 2 seconds */ unsigned long flags; diff --git a/drivers/char/rio/unixrup.h b/drivers/char/rio/unixrup.h index 4306e01dbf0..46bd532f774 100644 --- a/drivers/char/rio/unixrup.h +++ b/drivers/char/rio/unixrup.h @@ -44,7 +44,7 @@ static char *_unixrup_h_sccs_ = "@(#)unixrup.h 1.2"; struct UnixRup { struct CmdBlk *CmdsWaitingP; /* Commands waiting to be done */ struct CmdBlk *CmdPendingP; /* The command currently being sent */ - struct RUP *RupP; /* the Rup to send it to */ + struct RUP __iomem *RupP; /* the Rup to send it to */ unsigned int Id; /* Id number */ unsigned int BaseSysPort; /* SysPort of first tty on this RTA */ unsigned int ModTypes; /* Modules on this RTA */ -- cgit v1.2.3-70-g09d2 From 38d0d001b973d8c72c18524cc25ef39db85c66cd Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 27 May 2006 00:15:09 -0400 Subject: [PATCH] rio ->Copy() expects the sourse as first argument ... so conversion from rio_pcicopy() to rio_copy_to_card() had broken the damn thing. Signed-off-by: Al Viro --- drivers/char/rio/func.h | 2 +- drivers/char/rio/rio_linux.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/rio/func.h b/drivers/char/rio/func.h index 0707af33f01..6b039186856 100644 --- a/drivers/char/rio/func.h +++ b/drivers/char/rio/func.h @@ -140,7 +140,7 @@ int rio_isr_thread(char *); struct rio_info *rio_info_store(int cmd, struct rio_info *p); #endif -extern void rio_copy_to_card(void __iomem *to, void *from, int len); +extern void rio_copy_to_card(void *from, void __iomem *to, int len); extern int rio_minor(struct tty_struct *tty); extern int rio_ismodem(struct tty_struct *tty); diff --git a/drivers/char/rio/rio_linux.c b/drivers/char/rio/rio_linux.c index 39277e53d9a..8f96b20090e 100644 --- a/drivers/char/rio/rio_linux.c +++ b/drivers/char/rio/rio_linux.c @@ -333,7 +333,7 @@ int RIODelay_ni(struct Port *PortP, int njiffies) return !RIO_FAIL; } -void rio_copy_to_card(void __iomem *to, void *from, int len) +void rio_copy_to_card(void *from, void __iomem *to, int len) { rio_memcpy_toio(NULL, to, from, len); } -- cgit v1.2.3-70-g09d2 From c7c0d0a10f6e4cea95ed84adcdd37948cac09b85 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 27 May 2006 00:19:54 -0400 Subject: [PATCH] bogus order of copy_from_user() arguments ... aka "somebody forgot to swap arguments when converting from copyin()" Signed-off-by: Al Viro --- drivers/char/rio/rioboot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/char') diff --git a/drivers/char/rio/rioboot.c b/drivers/char/rio/rioboot.c index b9abbd0e7ec..eca2b95343e 100644 --- a/drivers/char/rio/rioboot.c +++ b/drivers/char/rio/rioboot.c @@ -280,7 +280,7 @@ int RIOBootCodeHOST(struct rio_info *p, struct DownLoad *rbp) func_exit(); return -ENOMEM; } - if (copy_from_user(rbp->DataP, DownCode, rbp->Count)) { + if (copy_from_user(DownCode, rbp->DataP, rbp->Count)) { kfree(DownCode); p->RIOError.Error = COPYIN_FAILED; func_exit(); -- cgit v1.2.3-70-g09d2 From bfa6b7bb35a9c8c8acae3056f2cb3364c52693d4 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 27 May 2006 00:36:10 -0400 Subject: [PATCH] uses of ->Copy() in rioroute are bogus ... there we are building a command in normal memory; it will be copied to iomem (by ->Copy()) later. Use memcpy()... Signed-off-by: Al Viro --- drivers/char/rio/rioroute.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/rio/rioroute.c b/drivers/char/rio/rioroute.c index 376d0e353dc..a99f3d9d7d6 100644 --- a/drivers/char/rio/rioroute.c +++ b/drivers/char/rio/rioroute.c @@ -307,7 +307,7 @@ int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct if (!RIOBootOk(p, HostP, RtaUniq)) { rio_dprintk(RIO_DEBUG_ROUTE, "RTA %x tried to get an ID, but does not belong - FOAD it!\n", RtaUniq); PktReplyP->Command = ROUTE_FOAD; - HostP->Copy("RT_FOAD", PktReplyP->CommandText, 7); + memcpy(PktReplyP->CommandText, "RT_FOAD", 7); RIOQueueCmdBlk(HostP, Rup, CmdBlkP); return 1; } @@ -341,7 +341,7 @@ int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct HostP->Mapping[ThisUnit].Flags |= MSG_DONE; } PktReplyP->Command = ROUTE_FOAD; - HostP->Copy("RT_FOAD", PktReplyP->CommandText, 7); + memcpy(PktReplyP->CommandText, "RT_FOAD", 7); RIOQueueCmdBlk(HostP, Rup, CmdBlkP); return 1; } @@ -367,7 +367,7 @@ int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct PktReplyP->IDNum2 = ROUTE_NO_ID; rio_dprintk(RIO_DEBUG_ROUTE, "RTA '%s' has been allocated ID %d\n", HostP->Mapping[ThisUnit].Name, PktReplyP->IDNum); } - HostP->Copy("RT_ALLOCAT", PktReplyP->CommandText, 10); + memcpy(PktReplyP->CommandText, "RT_ALLOCAT", 10); RIOQueueCmdBlk(HostP, Rup, CmdBlkP); @@ -469,7 +469,7 @@ int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct } PktReplyP->Command = ROUTE_FOAD; - HostP->Copy("RT_FOAD", PktReplyP->CommandText, 7); + memcpy(PktReplyP->CommandText, "RT_FOAD", 7); } else { /* ** we did boot it (as an extra), and there may now be a table @@ -489,7 +489,7 @@ int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct } } PktReplyP->Command = ROUTE_USED; - HostP->Copy("RT_USED", PktReplyP->CommandText, 7); + memcpy(PktReplyP->CommandText, "RT_USED", 7); } RIOQueueCmdBlk(HostP, Rup, CmdBlkP); return 1; -- cgit v1.2.3-70-g09d2 From ae5b28a5bb1b5f5d53085a044aec69db41fd0336 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 27 May 2006 01:48:08 -0400 Subject: [PATCH] fix rio_copy_to_card() for OLDPCI case It replaced old rio_pcicopy(). That puppy did _not_ do readb() (unlike rio_memcpy_toio()) and current implementation is simply broken - readb(NULL) is never a valid thing to do. Signed-off-by: Al Viro --- drivers/char/rio/rio_linux.c | 2 +- drivers/char/rio/rio_linux.h | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/rio/rio_linux.c b/drivers/char/rio/rio_linux.c index 8f96b20090e..aa43436d5d1 100644 --- a/drivers/char/rio/rio_linux.c +++ b/drivers/char/rio/rio_linux.c @@ -335,7 +335,7 @@ int RIODelay_ni(struct Port *PortP, int njiffies) void rio_copy_to_card(void *from, void __iomem *to, int len) { - rio_memcpy_toio(NULL, to, from, len); + rio_copy_toio(to, from, len); } int rio_minor(struct tty_struct *tty) diff --git a/drivers/char/rio/rio_linux.h b/drivers/char/rio/rio_linux.h index 99c7447b611..55b9c97e847 100644 --- a/drivers/char/rio/rio_linux.h +++ b/drivers/char/rio/rio_linux.h @@ -138,12 +138,23 @@ static inline void __iomem *rio_memcpy_toio(void __iomem *dummy, void __iomem *d while (n--) { writeb(*src++, dst++); - (void) readb(dummy); /* WTF? */ + (void) readb(dummy); } return dest; } +static inline void __iomem *rio_copy_toio(void __iomem *dest, void *source, int n) +{ + char __iomem *dst = dest; + char *src = source; + + while (n--) + writeb(*src++, dst++); + + return dest; +} + static inline void *rio_memcpy_fromio(void *dest, void __iomem *source, int n) { @@ -158,6 +169,7 @@ static inline void *rio_memcpy_fromio(void *dest, void __iomem *source, int n) #else #define rio_memcpy_toio(dummy,dest,source,n) memcpy_toio(dest, source, n) +#define rio_copy_toio memcpy_toio #define rio_memcpy_fromio memcpy_fromio #endif -- cgit v1.2.3-70-g09d2 From 1bf087194f01bce5b2d7b39f27d71d5f346fbf08 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 27 May 2006 01:55:52 -0400 Subject: [PATCH] handling rio MEMDUMP it copies data _from_ iomem, so it should be rio_memcpy_fromio(), not ->Copy(). Signed-off-by: Al Viro --- drivers/char/rio/riocmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/char') diff --git a/drivers/char/rio/riocmd.c b/drivers/char/rio/riocmd.c index 595f7a9de70..1a8d4a7fa44 100644 --- a/drivers/char/rio/riocmd.c +++ b/drivers/char/rio/riocmd.c @@ -696,7 +696,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP) FreeMe = RIOCommandRup(p, Rup, HostP, PacketP); if (PacketP->data[5] == MEMDUMP) { rio_dprintk(RIO_DEBUG_CMD, "Memdump from 0x%x complete\n", *(unsigned short *) & (PacketP->data[6])); - HostP->Copy(&(PacketP->data[8]), p->RIOMemDump, 32); + rio_memcpy_fromio(p->RIOMemDump, &(PacketP->data[8]), 32); } rio_spin_lock_irqsave(&UnixRupP->RupLock, flags); break; -- cgit v1.2.3-70-g09d2 From 6bc540e69a6376b9d58d8490f4998da9e45e2746 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 27 May 2006 02:00:00 -0400 Subject: [PATCH] forgotten swap of copyout() arguments Signed-off-by: Al Viro --- drivers/char/rio/rioctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/char') diff --git a/drivers/char/rio/rioctrl.c b/drivers/char/rio/rioctrl.c index 732e7db5f71..caeae5b774b 100644 --- a/drivers/char/rio/rioctrl.c +++ b/drivers/char/rio/rioctrl.c @@ -1021,7 +1021,7 @@ int riocontrol(struct rio_info *p, dev_t dev, int cmd, unsigned long arg, int su } rio_dprintk(RIO_DEBUG_CTRL, "Request for rup %d from host %d\n", RupReq.RupNum, RupReq.HostNum); - if (copy_to_user(HostP->UnixRups[RupReq.RupNum].RupP, RupReq.RupP, sizeof(struct RUP))) { + if (copy_to_user(RupReq.RupP, HostP->UnixRups[RupReq.RupNum].RupP, sizeof(struct RUP))) { p->RIOError.Error = COPYOUT_FAILED; rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_RUP: Bad copy to user space\n"); return -EFAULT; -- cgit v1.2.3-70-g09d2 From 0645819196b5029936cf07a8ba27860e0d45c8d9 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 27 May 2006 02:11:12 -0400 Subject: [PATCH] copy_to_user() from iomem is a bad thing Signed-off-by: Al Viro --- drivers/char/rio/rioctrl.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/rio/rioctrl.c b/drivers/char/rio/rioctrl.c index caeae5b774b..052e8120a47 100644 --- a/drivers/char/rio/rioctrl.c +++ b/drivers/char/rio/rioctrl.c @@ -126,6 +126,18 @@ static int #define drv_makedev(maj, min) ((((uint) maj & 0xff) << 8) | ((uint) min & 0xff)) +static int copy_from_io(void __user *to, void __iomem *from, size_t size) +{ + void *buf = kmalloc(size, GFP_KERNEL); + int res = -ENOMEM; + if (buf) { + rio_memcpy_fromio(buf, from, size); + res = copy_to_user(to, buf, size); + kfree(buf); + } + return res; +} + int riocontrol(struct rio_info *p, dev_t dev, int cmd, unsigned long arg, int su) { uint Host; /* leave me unsigned! */ @@ -893,7 +905,7 @@ int riocontrol(struct rio_info *p, dev_t dev, int cmd, unsigned long arg, int su ** Fetch the parmmap */ rio_dprintk(RIO_DEBUG_CTRL, "RIO_PARMS\n"); - if (copy_to_user(argp, p->RIOHosts[host].ParmMapP, sizeof(PARM_MAP))) { + if (copy_from_io(argp, p->RIOHosts[host].ParmMapP, sizeof(PARM_MAP))) { p->RIOError.Error = COPYOUT_FAILED; rio_dprintk(RIO_DEBUG_CTRL, "RIO_PARMS: Copy out to user space failed\n"); return -EFAULT; @@ -947,7 +959,7 @@ int riocontrol(struct rio_info *p, dev_t dev, int cmd, unsigned long arg, int su rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Bad copy to user space\n"); return -EFAULT; } - } else if (copy_to_user(HostDpRam.DpRamP, p->RIOHosts[HostDpRam.HostNum].Caddr, sizeof(struct DpRam))) { + } else if (copy_from_io(HostDpRam.DpRamP, p->RIOHosts[HostDpRam.HostNum].Caddr, sizeof(struct DpRam))) { p->RIOError.Error = COPYOUT_FAILED; rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Bad copy to user space\n"); return -EFAULT; @@ -1021,7 +1033,7 @@ int riocontrol(struct rio_info *p, dev_t dev, int cmd, unsigned long arg, int su } rio_dprintk(RIO_DEBUG_CTRL, "Request for rup %d from host %d\n", RupReq.RupNum, RupReq.HostNum); - if (copy_to_user(RupReq.RupP, HostP->UnixRups[RupReq.RupNum].RupP, sizeof(struct RUP))) { + if (copy_from_io(RupReq.RupP, HostP->UnixRups[RupReq.RupNum].RupP, sizeof(struct RUP))) { p->RIOError.Error = COPYOUT_FAILED; rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_RUP: Bad copy to user space\n"); return -EFAULT; @@ -1058,7 +1070,7 @@ int riocontrol(struct rio_info *p, dev_t dev, int cmd, unsigned long arg, int su } rio_dprintk(RIO_DEBUG_CTRL, "Request for lpb %d from host %d\n", LpbReq.Link, LpbReq.Host); - if (copy_to_user(LpbReq.LpbP, &HostP->LinkStrP[LpbReq.Link], sizeof(struct LPB))) { + if (copy_from_io(LpbReq.LpbP, &HostP->LinkStrP[LpbReq.Link], sizeof(struct LPB))) { rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_LPB: Bad copy to user space\n"); p->RIOError.Error = COPYOUT_FAILED; return -EFAULT; -- cgit v1.2.3-70-g09d2 From 92af11cdec410f5de4e8d702d24e1672ce26a1f6 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 27 May 2006 02:24:14 -0400 Subject: [PATCH] missing readb/readw in rio Signed-off-by: Al Viro --- drivers/char/rio/riocmd.c | 20 ++++++++++---------- drivers/char/rio/riointr.c | 24 ++++++++++++------------ drivers/char/rio/riotable.c | 4 ++-- 3 files changed, 24 insertions(+), 24 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/rio/riocmd.c b/drivers/char/rio/riocmd.c index 1a8d4a7fa44..4df6ab2206a 100644 --- a/drivers/char/rio/riocmd.c +++ b/drivers/char/rio/riocmd.c @@ -407,12 +407,12 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, struc } else rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: This is the RUP for link ``%c'' of host ``%s''\n", ('A' + Rup - MAX_RUP), HostP->Name); - rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Destination 0x%x:0x%x\n", PacketP->dest_unit, PacketP->dest_port); - rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Source 0x%x:0x%x\n", PacketP->src_unit, PacketP->src_port); - rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Length 0x%x (%d)\n", PacketP->len, PacketP->len); - rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Control 0x%x (%d)\n", PacketP->control, PacketP->control); - rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Check 0x%x (%d)\n", PacketP->csum, PacketP->csum); - rio_dprintk(RIO_DEBUG_CMD, "COMMAND information: Host Port Number 0x%x, " "Command Code 0x%x\n", PktCmdP->PhbNum, PktCmdP->Command); + rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Destination 0x%x:0x%x\n", readb(&PacketP->dest_unit), readb(&PacketP->dest_port)); + rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Source 0x%x:0x%x\n", readb(&PacketP->src_unit), readb(&PacketP->src_port)); + rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Length 0x%x (%d)\n", readb(&PacketP->len), readb(&PacketP->len)); + rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Control 0x%x (%d)\n", readb(&PacketP->control), readb(&PacketP->control)); + rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Check 0x%x (%d)\n", readw(&PacketP->csum), readw(&PacketP->csum)); + rio_dprintk(RIO_DEBUG_CMD, "COMMAND information: Host Port Number 0x%x, " "Command Code 0x%x\n", readb(&PktCmdP->PhbNum), readb(&PktCmdP->Command)); return 1; } PortP = p->RIOPortp[SysPort]; @@ -601,7 +601,7 @@ int RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP) /* ** Whammy! blat that pack! */ - HostP->Copy(&CmdBlkP->Packet, RIO_PTR(HostP->Caddr, UnixRupP->RupP->txpkt), sizeof(struct PKT)); + HostP->Copy(&CmdBlkP->Packet, RIO_PTR(HostP->Caddr, readw(&UnixRupP->RupP->txpkt)), sizeof(struct PKT)); /* ** place command packet on the pending position. @@ -694,8 +694,8 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP) */ rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags); FreeMe = RIOCommandRup(p, Rup, HostP, PacketP); - if (PacketP->data[5] == MEMDUMP) { - rio_dprintk(RIO_DEBUG_CMD, "Memdump from 0x%x complete\n", *(unsigned short *) & (PacketP->data[6])); + if (readb(&PacketP->data[5]) == MEMDUMP) { + rio_dprintk(RIO_DEBUG_CMD, "Memdump from 0x%x complete\n", readw(&(PacketP->data[6]))); rio_memcpy_fromio(p->RIOMemDump, &(PacketP->data[8]), 32); } rio_spin_lock_irqsave(&UnixRupP->RupLock, flags); @@ -782,7 +782,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP) /* ** Whammy! blat that pack! */ - HostP->Copy(&CmdBlkP->Packet, RIO_PTR(HostP->Caddr, UnixRupP->RupP->txpkt), sizeof(struct PKT)); + HostP->Copy(&CmdBlkP->Packet, RIO_PTR(HostP->Caddr, readw(&UnixRupP->RupP->txpkt)), sizeof(struct PKT)); /* ** remove the command from the rup command queue... diff --git a/drivers/char/rio/riointr.c b/drivers/char/rio/riointr.c index c05e84c6b0d..eec1fea0cb9 100644 --- a/drivers/char/rio/riointr.c +++ b/drivers/char/rio/riointr.c @@ -585,19 +585,19 @@ static void RIOReceive(struct rio_info *p, struct Port *PortP) /* ** check that it is not a command! */ - if (PacketP->len & PKT_CMD_BIT) { + if (readb(&PacketP->len) & PKT_CMD_BIT) { rio_dprintk(RIO_DEBUG_INTR, "RIO: unexpected command packet received on PHB\n"); /* rio_dprint(RIO_DEBUG_INTR, (" sysport = %d\n", p->RIOPortp->PortNum)); */ - rio_dprintk(RIO_DEBUG_INTR, " dest_unit = %d\n", PacketP->dest_unit); - rio_dprintk(RIO_DEBUG_INTR, " dest_port = %d\n", PacketP->dest_port); - rio_dprintk(RIO_DEBUG_INTR, " src_unit = %d\n", PacketP->src_unit); - rio_dprintk(RIO_DEBUG_INTR, " src_port = %d\n", PacketP->src_port); - rio_dprintk(RIO_DEBUG_INTR, " len = %d\n", PacketP->len); - rio_dprintk(RIO_DEBUG_INTR, " control = %d\n", PacketP->control); - rio_dprintk(RIO_DEBUG_INTR, " csum = %d\n", PacketP->csum); + rio_dprintk(RIO_DEBUG_INTR, " dest_unit = %d\n", readb(&PacketP->dest_unit)); + rio_dprintk(RIO_DEBUG_INTR, " dest_port = %d\n", readb(&PacketP->dest_port)); + rio_dprintk(RIO_DEBUG_INTR, " src_unit = %d\n", readb(&PacketP->src_unit)); + rio_dprintk(RIO_DEBUG_INTR, " src_port = %d\n", readb(&PacketP->src_port)); + rio_dprintk(RIO_DEBUG_INTR, " len = %d\n", readb(&PacketP->len)); + rio_dprintk(RIO_DEBUG_INTR, " control = %d\n", readb(&PacketP->control)); + rio_dprintk(RIO_DEBUG_INTR, " csum = %d\n", readw(&PacketP->csum)); rio_dprintk(RIO_DEBUG_INTR, " data bytes: "); for (DataCnt = 0; DataCnt < PKT_MAX_DATA_LEN; DataCnt++) - rio_dprintk(RIO_DEBUG_INTR, "%d\n", PacketP->data[DataCnt]); + rio_dprintk(RIO_DEBUG_INTR, "%d\n", readb(&PacketP->data[DataCnt])); remove_receive(PortP); put_free_end(PortP->HostP, PacketP); continue; /* with next packet */ @@ -618,7 +618,7 @@ static void RIOReceive(struct rio_info *p, struct Port *PortP) ** and available space. */ - transCount = tty_buffer_request_room(TtyP, PacketP->len & PKT_LEN_MASK); + transCount = tty_buffer_request_room(TtyP, readb(&PacketP->len) & PKT_LEN_MASK); rio_dprintk(RIO_DEBUG_REC, "port %d: Copy %d bytes\n", PortP->PortNum, transCount); /* ** To use the following 'kkprintfs' for debugging - change the '#undef' @@ -630,12 +630,12 @@ static void RIOReceive(struct rio_info *p, struct Port *PortP) tty_prepare_flip_string(TtyP, &buf, transCount); rio_memcpy_fromio(buf, ptr, transCount); PortP->RxDataStart += transCount; - PacketP->len -= transCount; + writeb(readb(&PacketP->len)-transCount, &PacketP->len); copied += transCount; - if (PacketP->len == 0) { + if (readb(&PacketP->len) == 0) { /* ** If we have emptied the packet, then we can ** free it, and reset the start pointer for diff --git a/drivers/char/rio/riotable.c b/drivers/char/rio/riotable.c index 364119e975b..7e988357326 100644 --- a/drivers/char/rio/riotable.c +++ b/drivers/char/rio/riotable.c @@ -546,11 +546,11 @@ int RIODeleteRta(struct rio_info *p, struct Map *MapP) ** accessed from the driver. */ Pkt = (struct PKT __iomem *) RIO_PTR(HostP->Caddr, readw(&*TxPktP)); - rio_dprintk(RIO_DEBUG_TABLE, "Tx packet (%x) destination: Old %x:%x New %x:%x\n", *TxPktP, Pkt->dest_unit, Pkt->dest_port, dest_unit, dest_port); + rio_dprintk(RIO_DEBUG_TABLE, "Tx packet (%x) destination: Old %x:%x New %x:%x\n", readw(TxPktP), readb(&Pkt->dest_unit), readb(&Pkt->dest_port), dest_unit, dest_port); writew(dest_unit, &Pkt->dest_unit); writew(dest_port, &Pkt->dest_port); } - rio_dprintk(RIO_DEBUG_TABLE, "Port %d phb destination: Old %x:%x New %x:%x\n", port, PortP->PhbP->destination & 0xff, (PortP->PhbP->destination >> 8) & 0xff, dest_unit, dest_port); + rio_dprintk(RIO_DEBUG_TABLE, "Port %d phb destination: Old %x:%x New %x:%x\n", port, readb(&PortP->PhbP->destination) & 0xff, (readb(&PortP->PhbP->destination) >> 8) & 0xff, dest_unit, dest_port); writew(dest_unit + (dest_port << 8), &PortP->PhbP->destination); } rio_spin_unlock_irqrestore(&PortP->portSem, sem_flags); -- cgit v1.2.3-70-g09d2 From 0f5e560e4523e15f33922de5becd024ccaaff76c Mon Sep 17 00:00:00 2001 From: Andreas Mohr Date: Mon, 5 Jun 2006 00:18:00 -0400 Subject: Input: constify drivers/char/keyboard.c Signed-off-by: Andreas Mohr Signed-off-by: Andrew Morton Signed-off-by: Dmitry Torokhov --- drivers/char/keyboard.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c index 5755b7e5f18..24f2656000e 100644 --- a/drivers/char/keyboard.c +++ b/drivers/char/keyboard.c @@ -672,7 +672,7 @@ static void k_dead2(struct vc_data *vc, unsigned char value, char up_flag, struc */ static void k_dead(struct vc_data *vc, unsigned char value, char up_flag, struct pt_regs *regs) { - static unsigned char ret_diacr[NR_DEAD] = {'`', '\'', '^', '~', '"', ',' }; + static const unsigned char ret_diacr[NR_DEAD] = {'`', '\'', '^', '~', '"', ',' }; value = ret_diacr[value]; k_deadunicode(vc, value, up_flag, regs); } @@ -709,8 +709,8 @@ static void k_cur(struct vc_data *vc, unsigned char value, char up_flag, struct static void k_pad(struct vc_data *vc, unsigned char value, char up_flag, struct pt_regs *regs) { - static const char *pad_chars = "0123456789+-*/\015,.?()#"; - static const char *app_map = "pqrstuvwxylSRQMnnmPQS"; + static const char pad_chars[] = "0123456789+-*/\015,.?()#"; + static const char app_map[] = "pqrstuvwxylSRQMnnmPQS"; if (up_flag) return; /* no action, if this is a key release */ @@ -1035,7 +1035,7 @@ static void kbd_refresh_leds(struct input_handle *handle) #define HW_RAW(dev) (test_bit(EV_MSC, dev->evbit) && test_bit(MSC_RAW, dev->mscbit) &&\ ((dev)->id.bustype == BUS_I8042) && ((dev)->id.vendor == 0x0001) && ((dev)->id.product == 0x0001)) -static unsigned short x86_keycodes[256] = +static const unsigned short x86_keycodes[256] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, -- cgit v1.2.3-70-g09d2 From b53744612f276ad20c5d7ef33ac991ec13101417 Mon Sep 17 00:00:00 2001 From: Michael Ellerman Date: Wed, 7 Jun 2006 17:10:03 +1000 Subject: [PATCH] powerpc: Make rtas console _much_ faster Currently the hvc_rtas driver is painfully slow to use. Our "benchmark" is ls -R /etc, which spits out about 27866 characters. The theoretical maximum speed would be about 2.2 seconds, the current code takes ~50 seconds. The core of the problem is that sometimes when the tty layer asks us to push characters the firmware isn't able to handle some or all of them, and so returns an error. The current code sees this and just returns to the tty code with the buffer half sent. The khvcd thread will eventually wake up and try to push more characters, which will usually work because by then the firmware's had time to make room. But the khvcd thread only wakes up every 10 milliseconds, which isn't fast enough. So change the khvcd thread logic so that if there's an incomplete write we yield() and then immediately try writing again. Doing so makes POLL_QUICK and POLL_WRITE synonymous, so remove POLL_QUICK. With this patch our "benchmark" takes ~2.8 seconds. Signed-off-by: Michael Ellerman Signed-off-by: Paul Mackerras --- drivers/char/hvc_console.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c index 2b6a56b2bf3..a5c6a9d7ff0 100644 --- a/drivers/char/hvc_console.c +++ b/drivers/char/hvc_console.c @@ -553,7 +553,6 @@ static int hvc_chars_in_buffer(struct tty_struct *tty) #define HVC_POLL_READ 0x00000001 #define HVC_POLL_WRITE 0x00000002 -#define HVC_POLL_QUICK 0x00000004 static int hvc_poll(struct hvc_struct *hp) { @@ -568,6 +567,7 @@ static int hvc_poll(struct hvc_struct *hp) /* Push pending writes */ if (hp->n_outbuf > 0) hvc_push(hp); + /* Reschedule us if still some write pending */ if (hp->n_outbuf > 0) poll_mask |= HVC_POLL_WRITE; @@ -680,7 +680,7 @@ int khvcd(void *unused) poll_mask |= HVC_POLL_READ; if (hvc_kicked) continue; - if (poll_mask & HVC_POLL_QUICK) { + if (poll_mask & HVC_POLL_WRITE) { yield(); continue; } -- cgit v1.2.3-70-g09d2 From 6b81e80049a8815dc457fec4dadb6ae535c3b988 Mon Sep 17 00:00:00 2001 From: Michael Ellerman Date: Wed, 7 Jun 2006 17:10:09 +1000 Subject: [PATCH] powerpc: Cleanup hvc_rtas.c a little A few cleanups in hvc_rtas.c: 1. Remove unused RTASCONS_PUT_ATTEMPTS 2. Remove unused rtascons_put_delay. 3. Use i as a loop counter like everyone else on earth. 4. Remove pointless variables, eg. x = foo; if (x) return something_else; 5. Whitespace cleanups and formatting. Signed-off-by: Michael Ellerman Signed-off-by: Paul Mackerras --- drivers/char/hvc_rtas.c | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/hvc_rtas.c b/drivers/char/hvc_rtas.c index 83364ea63cb..57106e02fd2 100644 --- a/drivers/char/hvc_rtas.c +++ b/drivers/char/hvc_rtas.c @@ -41,37 +41,28 @@ #define hvc_rtas_cookie 0x67781e15 struct hvc_struct *hvc_rtas_dev; -#define RTASCONS_PUT_ATTEMPTS 16 - static int rtascons_put_char_token = RTAS_UNKNOWN_SERVICE; static int rtascons_get_char_token = RTAS_UNKNOWN_SERVICE; -static int rtascons_put_delay = 100; -module_param_named(put_delay, rtascons_put_delay, int, 0644); -static inline int hvc_rtas_write_console(uint32_t vtermno, const char *buf, int count) +static inline int hvc_rtas_write_console(uint32_t vtermno, const char *buf, + int count) { - int done; + int i; - /* if there is more than one character to be displayed, wait a bit */ - for (done = 0; done < count; done++) { - int result; - result = rtas_call(rtascons_put_char_token, 1, 1, NULL, buf[done]); - if (result) + for (i = 0; i < count; i++) { + if (rtas_call(rtascons_put_char_token, 1, 1, NULL, buf[i])) break; } - /* the calling routine expects to receive the number of bytes sent */ - return done; + + return i; } static int hvc_rtas_read_console(uint32_t vtermno, char *buf, int count) { - int i; + int i, c; for (i = 0; i < count; i++) { - int c, err; - - err = rtas_call(rtascons_get_char_token, 0, 2, &c); - if (err) + if (rtas_call(rtascons_get_char_token, 0, 2, &c)) break; buf[i] = c; @@ -106,7 +97,9 @@ static int hvc_rtas_init(void) hp = hvc_alloc(hvc_rtas_cookie, NO_IRQ, &hvc_rtas_get_put_ops); if (IS_ERR(hp)) return PTR_ERR(hp); + hvc_rtas_dev = hp; + return 0; } module_init(hvc_rtas_init); @@ -114,8 +107,8 @@ module_init(hvc_rtas_init); /* This will tear down the tty portion of the driver */ static void __exit hvc_rtas_exit(void) { - /* Really the fun isn't over until the worker thread breaks down and the - * tty cleans up */ + /* Really the fun isn't over until the worker thread breaks down and + * the tty cleans up */ if (hvc_rtas_dev) hvc_remove(hvc_rtas_dev); } @@ -127,12 +120,14 @@ static int hvc_rtas_console_init(void) rtascons_put_char_token = rtas_token("put-term-char"); if (rtascons_put_char_token == RTAS_UNKNOWN_SERVICE) return -EIO; + rtascons_get_char_token = rtas_token("get-term-char"); if (rtascons_get_char_token == RTAS_UNKNOWN_SERVICE) return -EIO; - hvc_instantiate(hvc_rtas_cookie, 0, &hvc_rtas_get_put_ops ); + hvc_instantiate(hvc_rtas_cookie, 0, &hvc_rtas_get_put_ops); add_preferred_console("hvc", 0, NULL); + return 0; } console_initcall(hvc_rtas_console_init); -- cgit v1.2.3-70-g09d2 From c6387a48cf5958e43c201fc27a158c328927531a Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Tue, 20 Jun 2006 01:21:29 -0700 Subject: [SPARC]: Kill __irq_itoa(). This ugly hack was long overdue to die. It was a way to print out Sparc interrupts in a more freindly format, since IRQ numbers were arbitrary opaque 32-bit integers which vectored into PIL levels. These 32-bit integers were not necessarily in the 0-->NR_IRQS range, but the PILs they vectored to were. The idea now is that we will increase NR_IRQS a little bit and use a virtual<-->real IRQ number mapping scheme similar to PowerPC. That makes this IRQ printing hack irrelevant, and furthermore only a handful of drivers actually used __irq_itoa() making it even less useful. Signed-off-by: David S. Miller --- arch/sparc/kernel/pcic.c | 8 -------- arch/sparc/kernel/sparc_ksyms.c | 1 - arch/sparc/kernel/sun4c_irq.c | 3 --- arch/sparc/kernel/sun4d_irq.c | 12 ------------ arch/sparc/kernel/sun4m_irq.c | 8 -------- drivers/atm/fore200e.c | 4 ---- drivers/char/rtc.c | 4 ---- drivers/fc4/soc.c | 2 +- drivers/fc4/socal.c | 2 +- drivers/ide/ide-probe.c | 7 +------ drivers/ide/setup-pci.c | 5 ----- drivers/ieee1394/ohci1394.c | 4 ---- drivers/ieee1394/pcilynx.c | 4 ---- drivers/message/fusion/mptbase.c | 16 ---------------- drivers/net/3c59x.c | 5 ----- drivers/net/acenic.c | 6 +----- drivers/net/sunhme.c | 5 ----- drivers/net/sunlance.c | 2 +- drivers/sbus/char/cpwatchdog.c | 4 ++-- drivers/sbus/char/uctrl.c | 2 +- drivers/scsi/esp.c | 4 ++-- drivers/scsi/qlogicpti.c | 6 +++--- drivers/scsi/sym53c8xx_2/sym_glue.c | 6 ------ drivers/serial/sunsu.c | 4 ++-- drivers/serial/sunzilog.c | 4 ++-- drivers/usb/core/hcd.c | 12 ++---------- drivers/usb/gadget/goku_udc.c | 11 ++--------- drivers/usb/gadget/net2280.c | 14 ++++---------- include/asm-sparc/irq.h | 2 -- include/asm-sparc64/irq.h | 8 -------- sound/sparc/amd7930.c | 8 ++++---- sound/sparc/cs4231.c | 13 ++++++------- sound/sparc/dbri.c | 4 ++-- 33 files changed, 37 insertions(+), 163 deletions(-) (limited to 'drivers/char') diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c index 42002b742de..bcdf5ad0f03 100644 --- a/arch/sparc/kernel/pcic.c +++ b/arch/sparc/kernel/pcic.c @@ -896,13 +896,6 @@ static inline unsigned long get_irqmask(int irq_nr) return 1 << irq_nr; } -static inline char *pcic_irq_itoa(unsigned int irq) -{ - static char buff[16]; - sprintf(buff, "%d", irq); - return buff; -} - static void pcic_disable_irq(unsigned int irq_nr) { unsigned long mask, flags; @@ -955,7 +948,6 @@ void __init sun4m_pci_init_IRQ(void) BTFIXUPSET_CALL(clear_clock_irq, pcic_clear_clock_irq, BTFIXUPCALL_NORM); BTFIXUPSET_CALL(clear_profile_irq, pcic_clear_profile_irq, BTFIXUPCALL_NORM); BTFIXUPSET_CALL(load_profile_irq, pcic_load_profile_irq, BTFIXUPCALL_NORM); - BTFIXUPSET_CALL(__irq_itoa, pcic_irq_itoa, BTFIXUPCALL_NORM); } int pcibios_assign_resource(struct pci_dev *pdev, int resource) diff --git a/arch/sparc/kernel/sparc_ksyms.c b/arch/sparc/kernel/sparc_ksyms.c index 4b376fae752..fd7deabf998 100644 --- a/arch/sparc/kernel/sparc_ksyms.c +++ b/arch/sparc/kernel/sparc_ksyms.c @@ -163,7 +163,6 @@ EXPORT_SYMBOL(BTFIXUP_CALL(__hard_smp_processor_id)); #endif EXPORT_SYMBOL(BTFIXUP_CALL(enable_irq)); EXPORT_SYMBOL(BTFIXUP_CALL(disable_irq)); -EXPORT_SYMBOL(BTFIXUP_CALL(__irq_itoa)); EXPORT_SYMBOL(BTFIXUP_CALL(mmu_unlockarea)); EXPORT_SYMBOL(BTFIXUP_CALL(mmu_lockarea)); EXPORT_SYMBOL(BTFIXUP_CALL(mmu_get_scsi_sgl)); diff --git a/arch/sparc/kernel/sun4c_irq.c b/arch/sparc/kernel/sun4c_irq.c index 3d6a99073c4..0f2d8d9cbdb 100644 --- a/arch/sparc/kernel/sun4c_irq.c +++ b/arch/sparc/kernel/sun4c_irq.c @@ -198,8 +198,6 @@ static void __init sun4c_init_timers(irqreturn_t (*counter_fn)(int, void *, stru static void sun4c_nop(void) {} #endif -extern char *sun4m_irq_itoa(unsigned int irq); - void __init sun4c_init_IRQ(void) { struct linux_prom_registers int_regs[2]; @@ -238,7 +236,6 @@ void __init sun4c_init_IRQ(void) BTFIXUPSET_CALL(clear_clock_irq, sun4c_clear_clock_irq, BTFIXUPCALL_NORM); BTFIXUPSET_CALL(clear_profile_irq, sun4c_clear_profile_irq, BTFIXUPCALL_NOP); BTFIXUPSET_CALL(load_profile_irq, sun4c_load_profile_irq, BTFIXUPCALL_NOP); - BTFIXUPSET_CALL(__irq_itoa, sun4m_irq_itoa, BTFIXUPCALL_NORM); sparc_init_timers = sun4c_init_timers; #ifdef CONFIG_SMP BTFIXUPSET_CALL(set_cpu_int, sun4c_nop, BTFIXUPCALL_NOP); diff --git a/arch/sparc/kernel/sun4d_irq.c b/arch/sparc/kernel/sun4d_irq.c index ca656d9bd6f..9c30e35c88f 100644 --- a/arch/sparc/kernel/sun4d_irq.c +++ b/arch/sparc/kernel/sun4d_irq.c @@ -560,17 +560,6 @@ void __init sun4d_init_sbi_irq(void) } } -static char *sun4d_irq_itoa(unsigned int irq) -{ - static char buff[16]; - - if (irq < (1 << 5)) - sprintf(buff, "%d", irq); - else - sprintf(buff, "%d,%x", sbus_to_pil[(irq >> 2) & 7], irq); - return buff; -} - void __init sun4d_init_IRQ(void) { local_irq_disable(); @@ -581,7 +570,6 @@ void __init sun4d_init_IRQ(void) BTFIXUPSET_CALL(clear_clock_irq, sun4d_clear_clock_irq, BTFIXUPCALL_NORM); BTFIXUPSET_CALL(clear_profile_irq, sun4d_clear_profile_irq, BTFIXUPCALL_NORM); BTFIXUPSET_CALL(load_profile_irq, sun4d_load_profile_irq, BTFIXUPCALL_NORM); - BTFIXUPSET_CALL(__irq_itoa, sun4d_irq_itoa, BTFIXUPCALL_NORM); sparc_init_timers = sun4d_init_timers; #ifdef CONFIG_SMP BTFIXUPSET_CALL(set_cpu_int, sun4d_set_cpu_int, BTFIXUPCALL_NORM); diff --git a/arch/sparc/kernel/sun4m_irq.c b/arch/sparc/kernel/sun4m_irq.c index 39d712c3c80..a296c13ac18 100644 --- a/arch/sparc/kernel/sun4m_irq.c +++ b/arch/sparc/kernel/sun4m_irq.c @@ -229,13 +229,6 @@ static void sun4m_load_profile_irq(int cpu, unsigned int limit) sun4m_timers->cpu_timers[cpu].l14_timer_limit = limit; } -char *sun4m_irq_itoa(unsigned int irq) -{ - static char buff[16]; - sprintf(buff, "%d", irq); - return buff; -} - static void __init sun4m_init_timers(irqreturn_t (*counter_fn)(int, void *, struct pt_regs *)) { int reg_count, irq, cpu; @@ -388,7 +381,6 @@ void __init sun4m_init_IRQ(void) BTFIXUPSET_CALL(clear_clock_irq, sun4m_clear_clock_irq, BTFIXUPCALL_NORM); BTFIXUPSET_CALL(clear_profile_irq, sun4m_clear_profile_irq, BTFIXUPCALL_NORM); BTFIXUPSET_CALL(load_profile_irq, sun4m_load_profile_irq, BTFIXUPCALL_NORM); - BTFIXUPSET_CALL(__irq_itoa, sun4m_irq_itoa, BTFIXUPCALL_NORM); sparc_init_timers = sun4m_init_timers; #ifdef CONFIG_SMP BTFIXUPSET_CALL(set_cpu_int, sun4m_send_ipi, BTFIXUPCALL_NORM); diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c index 05983a312d5..92923bf2723 100644 --- a/drivers/atm/fore200e.c +++ b/drivers/atm/fore200e.c @@ -167,13 +167,9 @@ fore200e_atm2fore_aal(int aal) static char* fore200e_irq_itoa(int irq) { -#if defined(__sparc_v9__) - return __irq_itoa(irq); -#else static char str[8]; sprintf(str, "%d", irq); return str; -#endif } diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c index 7cac6d05d72..f6686fcce80 100644 --- a/drivers/char/rtc.c +++ b/drivers/char/rtc.c @@ -960,10 +960,6 @@ found: * PCI Slot 2 INTA# (and some INTx# in Slot 1). */ if (request_irq(rtc_irq, rtc_interrupt, SA_SHIRQ, "rtc", (void *)&rtc_port)) { - /* - * Standard way for sparc to print irq's is to use - * __irq_itoa(). I think for EBus it's ok to use %d. - */ printk(KERN_ERR "rtc: cannot register IRQ %d\n", rtc_irq); return -EIO; } diff --git a/drivers/fc4/soc.c b/drivers/fc4/soc.c index ec1f94738c5..cf8768b8d1f 100644 --- a/drivers/fc4/soc.c +++ b/drivers/fc4/soc.c @@ -643,7 +643,7 @@ static inline void soc_init(struct sbus_dev *sdev, int no) return; } - SOD(("SOC uses IRQ%s\n", __irq_itoa(irq))) + SOD(("SOC uses IRQ %d\n", irq)) s->port[0].fc.irq = irq; s->port[1].fc.irq = irq; diff --git a/drivers/fc4/socal.c b/drivers/fc4/socal.c index 922e9613b2c..f52d1e5bd5a 100644 --- a/drivers/fc4/socal.c +++ b/drivers/fc4/socal.c @@ -767,7 +767,7 @@ static inline void socal_init(struct sbus_dev *sdev, int no) return; } - SOD(("SOCAL uses IRQ %s\n", __irq_itoa(irq))) + SOD(("SOCAL uses IRQ %d\n", irq)) s->port[0].fc.irq = irq; s->port[1].fc.irq = irq; diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index 1b7b4c531bc..9ebf8ae2a5e 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c @@ -1138,16 +1138,11 @@ static int init_irq (ide_hwif_t *hwif) spin_unlock_irq(&ide_lock); } -#if !defined(__mc68000__) && !defined(CONFIG_APUS) && !defined(__sparc__) +#if !defined(__mc68000__) && !defined(CONFIG_APUS) printk("%s at 0x%03lx-0x%03lx,0x%03lx on irq %d", hwif->name, hwif->io_ports[IDE_DATA_OFFSET], hwif->io_ports[IDE_DATA_OFFSET]+7, hwif->io_ports[IDE_CONTROL_OFFSET], hwif->irq); -#elif defined(__sparc__) - printk("%s at 0x%03lx-0x%03lx,0x%03lx on irq %s", hwif->name, - hwif->io_ports[IDE_DATA_OFFSET], - hwif->io_ports[IDE_DATA_OFFSET]+7, - hwif->io_ports[IDE_CONTROL_OFFSET], __irq_itoa(hwif->irq)); #else printk("%s at 0x%08lx on irq %d", hwif->name, hwif->io_ports[IDE_DATA_OFFSET], hwif->irq); diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c index 462ed3006c3..c11e3b2e67a 100644 --- a/drivers/ide/setup-pci.c +++ b/drivers/ide/setup-pci.c @@ -694,13 +694,8 @@ static int do_ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t *d, goto out; } if (noisy) -#ifdef __sparc__ - printk(KERN_INFO "%s: 100%% native mode on irq %s\n", - d->name, __irq_itoa(pciirq)); -#else printk(KERN_INFO "%s: 100%% native mode on irq %d\n", d->name, pciirq); -#endif } /* FIXME: silent failure can happen */ diff --git a/drivers/ieee1394/ohci1394.c b/drivers/ieee1394/ohci1394.c index 11f13778f13..c031650a1c7 100644 --- a/drivers/ieee1394/ohci1394.c +++ b/drivers/ieee1394/ohci1394.c @@ -586,11 +586,7 @@ static void ohci_initialize(struct ti_ohci *ohci) reg_write(ohci, OHCI1394_HCControlSet, OHCI1394_HCControl_linkEnable); buf = reg_read(ohci, OHCI1394_Version); -#ifndef __sparc__ sprintf (irq_buf, "%d", ohci->dev->irq); -#else - sprintf (irq_buf, "%s", __irq_itoa(ohci->dev->irq)); -#endif PRINT(KERN_INFO, "OHCI-1394 %d.%d (PCI): IRQ=[%s] " "MMIO=[%lx-%lx] Max Packet=[%d] IR/IT contexts=[%d/%d]", ((((buf) >> 16) & 0xf) + (((buf) >> 20) & 0xf) * 10), diff --git a/drivers/ieee1394/pcilynx.c b/drivers/ieee1394/pcilynx.c index e2edc41e1b6..e29dfd280be 100644 --- a/drivers/ieee1394/pcilynx.c +++ b/drivers/ieee1394/pcilynx.c @@ -1252,11 +1252,7 @@ static int __devinit add_card(struct pci_dev *dev, /* Fix buggy cards with autoboot pin not tied low: */ reg_write(lynx, DMA0_CHAN_CTRL, 0); -#ifndef __sparc__ sprintf (irq_buf, "%d", dev->irq); -#else - sprintf (irq_buf, "%s", __irq_itoa(dev->irq)); -#endif if (!request_irq(dev->irq, lynx_irq_handler, SA_SHIRQ, PCILYNX_DRIVER_NAME, lynx)) { diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c index a30084076ac..59690cbabfc 100644 --- a/drivers/message/fusion/mptbase.c +++ b/drivers/message/fusion/mptbase.c @@ -63,9 +63,6 @@ #ifdef CONFIG_MTRR #include #endif -#ifdef __sparc__ -#include /* needed for __irq_itoa() proto */ -#endif #include "mptbase.h" @@ -1394,13 +1391,8 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id) r = request_irq(pdev->irq, mpt_interrupt, SA_SHIRQ, ioc->name, ioc); if (r < 0) { -#ifndef __sparc__ printk(MYIOC_s_ERR_FMT "Unable to allocate interrupt %d!\n", ioc->name, pdev->irq); -#else - printk(MYIOC_s_ERR_FMT "Unable to allocate interrupt %s!\n", - ioc->name, __irq_itoa(pdev->irq)); -#endif list_del(&ioc->list); iounmap(mem); kfree(ioc); @@ -1412,11 +1404,7 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id) pci_set_master(pdev); /* ?? */ pci_set_drvdata(pdev, ioc); -#ifndef __sparc__ dprintk((KERN_INFO MYNAM ": %s installed at interrupt %d\n", ioc->name, pdev->irq)); -#else - dprintk((KERN_INFO MYNAM ": %s installed at interrupt %s\n", ioc->name, __irq_itoa(pdev->irq))); -#endif } /* Check for "bound ports" (929, 929X, 1030, 1035) to reduce redundant resets. @@ -5647,11 +5635,7 @@ mpt_print_ioc_summary(MPT_ADAPTER *ioc, char *buffer, int *size, int len, int sh a[5], a[4], a[3], a[2], a[1], a[0]); } -#ifndef __sparc__ y += sprintf(buffer+len+y, ", IRQ=%d", ioc->pci_irq); -#else - y += sprintf(buffer+len+y, ", IRQ=%s", __irq_itoa(ioc->pci_irq)); -#endif if (!ioc->active) y += sprintf(buffer+len+y, " (disabled)"); diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c index 274b0138d44..e27778926eb 100644 --- a/drivers/net/3c59x.c +++ b/drivers/net/3c59x.c @@ -1382,17 +1382,12 @@ static int __devinit vortex_probe1(struct device *gendev, for (i = 0; i < 6; i++) iowrite8(dev->dev_addr[i], ioaddr + i); -#ifdef __sparc__ - if (print_info) - printk(", IRQ %s\n", __irq_itoa(dev->irq)); -#else if (print_info) printk(", IRQ %d\n", dev->irq); /* Tell them about an invalid IRQ. */ if (dev->irq <= 0 || dev->irq >= NR_IRQS) printk(KERN_WARNING " *** Warning: IRQ %d is unlikely to work! ***\n", dev->irq); -#endif EL3WINDOW(4); step = (ioread8(ioaddr + Wn4_NetDiag) & 0x1e) >> 1; diff --git a/drivers/net/acenic.c b/drivers/net/acenic.c index b508812e97a..23ff22ba5d3 100644 --- a/drivers/net/acenic.c +++ b/drivers/net/acenic.c @@ -579,11 +579,7 @@ static int __devinit acenic_probe_one(struct pci_dev *pdev, } printk("Gigabit Ethernet at 0x%08lx, ", dev->base_addr); -#ifdef __sparc__ - printk("irq %s\n", __irq_itoa(pdev->irq)); -#else - printk("irq %i\n", pdev->irq); -#endif + printk("irq %d\n", pdev->irq); #ifdef CONFIG_ACENIC_OMIT_TIGON_I if ((readl(&ap->regs->HostCtrl) >> 28) == 4) { diff --git a/drivers/net/sunhme.c b/drivers/net/sunhme.c index 9f046cae2f7..bd5d2668a36 100644 --- a/drivers/net/sunhme.c +++ b/drivers/net/sunhme.c @@ -2221,13 +2221,8 @@ static int happy_meal_open(struct net_device *dev) if (request_irq(dev->irq, &happy_meal_interrupt, SA_SHIRQ, dev->name, (void *)dev)) { HMD(("EAGAIN\n")); -#ifdef __sparc__ - printk(KERN_ERR "happy_meal(SBUS): Can't order irq %s to go.\n", - __irq_itoa(dev->irq)); -#else printk(KERN_ERR "happy_meal(SBUS): Can't order irq %d to go.\n", dev->irq); -#endif return -EAGAIN; } diff --git a/drivers/net/sunlance.c b/drivers/net/sunlance.c index b7d87d4690b..6381243d8d0 100644 --- a/drivers/net/sunlance.c +++ b/drivers/net/sunlance.c @@ -936,7 +936,7 @@ static int lance_open(struct net_device *dev) if (request_irq(dev->irq, &lance_interrupt, SA_SHIRQ, lancestr, (void *) dev)) { - printk(KERN_ERR "Lance: Can't get irq %s\n", __irq_itoa(dev->irq)); + printk(KERN_ERR "Lance: Can't get irq %d\n", dev->irq); return -EAGAIN; } diff --git a/drivers/sbus/char/cpwatchdog.c b/drivers/sbus/char/cpwatchdog.c index fd2cc7782f7..5bf3dd901b6 100644 --- a/drivers/sbus/char/cpwatchdog.c +++ b/drivers/sbus/char/cpwatchdog.c @@ -304,8 +304,8 @@ static int wd_open(struct inode *inode, struct file *f) SA_SHIRQ, WD_OBPNAME, (void *)wd_dev.regs)) { - printk("%s: Cannot register IRQ %s\n", - WD_OBPNAME, __irq_itoa(wd_dev.irq)); + printk("%s: Cannot register IRQ %d\n", + WD_OBPNAME, wd_dev.irq); return(-EBUSY); } wd_dev.initialized = 1; diff --git a/drivers/sbus/char/uctrl.c b/drivers/sbus/char/uctrl.c index e2d9a7c8542..575b1f7ed41 100644 --- a/drivers/sbus/char/uctrl.c +++ b/drivers/sbus/char/uctrl.c @@ -400,7 +400,7 @@ static int __init ts102_uctrl_init(void) } driver->regs->uctrl_intr = UCTRL_INTR_RXNE_REQ|UCTRL_INTR_RXNE_MSK; - printk("uctrl: 0x%x (irq %s)\n", driver->regs, __irq_itoa(driver->irq)); + printk("uctrl: 0x%x (irq %d)\n", driver->regs, driver->irq); uctrl_get_event_status(); uctrl_get_external_status(); return 0; diff --git a/drivers/scsi/esp.c b/drivers/scsi/esp.c index 87a8c3d2072..0a3e45d7a97 100644 --- a/drivers/scsi/esp.c +++ b/drivers/scsi/esp.c @@ -821,8 +821,8 @@ static int __init esp_register_irq(struct esp *esp) return -1; } - printk("esp%d: IRQ %s ", esp->esp_id, - __irq_itoa(esp->ehost->irq)); + printk("esp%d: IRQ %d ", esp->esp_id, + esp->ehost->irq); return 0; } diff --git a/drivers/scsi/qlogicpti.c b/drivers/scsi/qlogicpti.c index c7e78dcf09d..7c27ecc6fb5 100644 --- a/drivers/scsi/qlogicpti.c +++ b/drivers/scsi/qlogicpti.c @@ -725,7 +725,7 @@ static int __init qpti_register_irq(struct qlogicpti *qpti) SA_SHIRQ, "Qlogic/PTI", qpti)) goto fail; - printk("qpti%d: IRQ %s ", qpti->qpti_id, __irq_itoa(qpti->irq)); + printk("qpti%d: IRQ %d ", qpti->qpti_id, qpti->irq); return 0; @@ -988,8 +988,8 @@ const char *qlogicpti_info(struct Scsi_Host *host) static char buf[80]; struct qlogicpti *qpti = (struct qlogicpti *) host->hostdata; - sprintf(buf, "PTI Qlogic,ISP SBUS SCSI irq %s regs at %p", - __irq_itoa(qpti->qhost->irq), qpti->qregs); + sprintf(buf, "PTI Qlogic,ISP SBUS SCSI irq %d regs at %p", + qpti->qhost->irq, qpti->qregs); return buf; } diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index 9c83b4d39a2..7677fba2ceb 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c @@ -54,14 +54,8 @@ #define NAME53C "sym53c" #define NAME53C8XX "sym53c8xx" -/* SPARC just has to be different ... */ -#ifdef __sparc__ -#define IRQ_FMT "%s" -#define IRQ_PRM(x) __irq_itoa(x) -#else #define IRQ_FMT "%d" #define IRQ_PRM(x) (x) -#endif struct sym_driver_setup sym_driver_setup = SYM_LINUX_DRIVER_SETUP; unsigned int sym_debug_flags = 0; diff --git a/drivers/serial/sunsu.c b/drivers/serial/sunsu.c index 2b4f96541b8..4cdb610cdd3 100644 --- a/drivers/serial/sunsu.c +++ b/drivers/serial/sunsu.c @@ -1295,9 +1295,9 @@ static int __init sunsu_kbd_ms_init(struct uart_sunsu_port *up, int channel) if (up->port.type == PORT_UNKNOWN) return -1; - printk(KERN_INFO "su%d at 0x%p (irq = %s) is a %s\n", + printk(KERN_INFO "su%d at 0x%p (irq = %d) is a %s\n", channel, - up->port.membase, __irq_itoa(up->port.irq), + up->port.membase, up->port.irq, sunsu_type(&up->port)); #ifdef CONFIG_SERIO diff --git a/drivers/serial/sunzilog.c b/drivers/serial/sunzilog.c index cd49ebbf4a4..5b6569728a9 100644 --- a/drivers/serial/sunzilog.c +++ b/drivers/serial/sunzilog.c @@ -1540,8 +1540,8 @@ static void __init sunzilog_init_kbdms(struct uart_sunzilog_port *up, int channe up->cflag = B4800 | CS8 | CLOCAL | CREAD; baud = 4800; } - printk(KERN_INFO "zs%d at 0x%p (irq = %s) is a SunZilog\n", - channel, up->port.membase, __irq_itoa(zilog_irq)); + printk(KERN_INFO "zs%d at 0x%p (irq = %d) is a SunZilog\n", + channel, up->port.membase, zilog_irq); up->curregs[R15] = BRKIE; brg = BPS_TO_BRG(baud, ZS_CLOCK / ZS_CLOCK_DIVISOR); diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index e2e00ba4e1e..4bf914d00a1 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -1826,24 +1826,16 @@ int usb_add_hcd(struct usb_hcd *hcd, /* enable irqs just before we start the controller */ if (hcd->driver->irq) { - char buf[8], *bufp = buf; - -#ifdef __sparc__ - bufp = __irq_itoa(irqnum); -#else - sprintf(buf, "%d", irqnum); -#endif - snprintf(hcd->irq_descr, sizeof(hcd->irq_descr), "%s:usb%d", hcd->driver->description, hcd->self.busnum); if ((retval = request_irq(irqnum, &usb_hcd_irq, irqflags, hcd->irq_descr, hcd)) != 0) { dev_err(hcd->self.controller, - "request interrupt %s failed\n", bufp); + "request interrupt %d failed\n", irqnum); goto err_request_irq; } hcd->irq = irqnum; - dev_info(hcd->self.controller, "irq %s, %s 0x%08llx\n", bufp, + dev_info(hcd->self.controller, "irq %d, %s 0x%08llx\n", irqnum, (hcd->driver->flags & HCD_MEMORY) ? "io mem" : "io base", (unsigned long long)hcd->rsrc_start); diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c index 66b81bbf6be..5378c175729 100644 --- a/drivers/usb/gadget/goku_udc.c +++ b/drivers/usb/gadget/goku_udc.c @@ -1850,7 +1850,6 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id) unsigned long resource, len; void __iomem *base = NULL; int retval; - char buf [8], *bufp; /* if you want to support more than one controller in a system, * usb_gadget_driver_{register,unregister}() must change. @@ -1913,20 +1912,14 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id) pci_set_drvdata(pdev, dev); INFO(dev, "%s\n", driver_desc); INFO(dev, "version: " DRIVER_VERSION " %s\n", dmastr()); -#ifndef __sparc__ - scnprintf(buf, sizeof buf, "%d", pdev->irq); - bufp = buf; -#else - bufp = __irq_itoa(pdev->irq); -#endif - INFO(dev, "irq %s, pci mem %p\n", bufp, base); + INFO(dev, "irq %d, pci mem %p\n", pdev->irq, base); /* init to known state, then setup irqs */ udc_reset(dev); udc_reinit (dev); if (request_irq(pdev->irq, goku_irq, SA_SHIRQ/*|SA_SAMPLE_RANDOM*/, driver_name, dev) != 0) { - DBG(dev, "request interrupt %s failed\n", bufp); + DBG(dev, "request interrupt %d failed\n", pdev->irq); retval = -EBUSY; goto done; } diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c index 0b929349395..020d3c42b1a 100644 --- a/drivers/usb/gadget/net2280.c +++ b/drivers/usb/gadget/net2280.c @@ -2822,7 +2822,6 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id) unsigned long resource, len; void __iomem *base = NULL; int retval, i; - char buf [8], *bufp; /* if you want to support more than one controller in a system, * usb_gadget_driver_{register,unregister}() must change. @@ -2896,15 +2895,10 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id) retval = -ENODEV; goto done; } -#ifndef __sparc__ - scnprintf (buf, sizeof buf, "%d", pdev->irq); - bufp = buf; -#else - bufp = __irq_itoa(pdev->irq); -#endif + if (request_irq (pdev->irq, net2280_irq, SA_SHIRQ, driver_name, dev) != 0) { - ERROR (dev, "request interrupt %s failed\n", bufp); + ERROR (dev, "request interrupt %d failed\n", pdev->irq); retval = -EBUSY; goto done; } @@ -2953,8 +2947,8 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id) /* done */ INFO (dev, "%s\n", driver_desc); - INFO (dev, "irq %s, pci mem %p, chip rev %04x\n", - bufp, base, dev->chiprev); + INFO (dev, "irq %d, pci mem %p, chip rev %04x\n", + pdev->irq, base, dev->chiprev); INFO (dev, "version: " DRIVER_VERSION "; dma %s\n", use_dma ? (use_dma_chaining ? "chaining" : "enabled") diff --git a/include/asm-sparc/irq.h b/include/asm-sparc/irq.h index cee356b0dae..a6115c6ed6e 100644 --- a/include/asm-sparc/irq.h +++ b/include/asm-sparc/irq.h @@ -17,8 +17,6 @@ #define __irq_ino(irq) irq #define __irq_pil(irq) irq -BTFIXUPDEF_CALL(char *, __irq_itoa, unsigned int) -#define __irq_itoa(irq) BTFIXUP_CALL(__irq_itoa)(irq) #define NR_IRQS 16 diff --git a/include/asm-sparc64/irq.h b/include/asm-sparc64/irq.h index de33d6e1afb..bbdf89e6faa 100644 --- a/include/asm-sparc64/irq.h +++ b/include/asm-sparc64/irq.h @@ -99,14 +99,6 @@ extern struct ino_bucket ivector_table[NUM_IVECS]; #define __bucket(irq) ((struct ino_bucket *)(unsigned long)(irq)) #define __irq(bucket) ((unsigned int)(unsigned long)(bucket)) -static __inline__ char *__irq_itoa(unsigned int irq) -{ - static char buff[16]; - - sprintf(buff, "%d,%x", __irq_pil(irq), (unsigned int)__irq_ino(irq)); - return buff; -} - #define NR_IRQS 16 #define irq_canonicalize(irq) (irq) diff --git a/sound/sparc/amd7930.c b/sound/sparc/amd7930.c index 55493340f46..dfe9bac7fa3 100644 --- a/sound/sparc/amd7930.c +++ b/sound/sparc/amd7930.c @@ -977,9 +977,9 @@ static int __init snd_amd7930_create(struct snd_card *card, if (request_irq(irq_prop->pri, snd_amd7930_interrupt, SA_INTERRUPT | SA_SHIRQ, "amd7930", amd)) { - snd_printk("amd7930-%d: Unable to grab IRQ %s\n", + snd_printk("amd7930-%d: Unable to grab IRQ %d\n", dev, - __irq_itoa(irq_prop->pri)); + irq_prop->pri); snd_amd7930_free(amd); return -EBUSY; } @@ -1063,11 +1063,11 @@ static int __init amd7930_attach(int prom_node, struct sbus_dev *sdev) strcpy(card->driver, "AMD7930"); strcpy(card->shortname, "Sun AMD7930"); - sprintf(card->longname, "%s at 0x%02lx:0x%08lx, irq %s", + sprintf(card->longname, "%s at 0x%02lx:0x%08lx, irq %d", card->shortname, rp->flags & 0xffL, rp->start, - __irq_itoa(irq_prop.pri)); + irq_prop.pri); if ((err = snd_amd7930_create(card, sdev, rp, reg_prop.reg_size, &irq_prop, dev, &amd)) < 0) diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c index 8804f26ddb3..b3efc9aa291 100644 --- a/sound/sparc/cs4231.c +++ b/sound/sparc/cs4231.c @@ -2003,9 +2003,8 @@ static int __init snd_cs4231_sbus_create(struct snd_card *card, if (request_irq(sdev->irqs[0], snd_cs4231_sbus_interrupt, SA_SHIRQ, "cs4231", chip)) { - snd_printdd("cs4231-%d: Unable to grab SBUS IRQ %s\n", - dev, - __irq_itoa(sdev->irqs[0])); + snd_printdd("cs4231-%d: Unable to grab SBUS IRQ %d\n", + dev, sdev->irqs[0]); snd_cs4231_sbus_free(chip); return -EBUSY; } @@ -2038,11 +2037,11 @@ static int __init cs4231_sbus_attach(struct sbus_dev *sdev) if (err) return err; - sprintf(card->longname, "%s at 0x%02lx:0x%08lx, irq %s", + sprintf(card->longname, "%s at 0x%02lx:0x%08lx, irq %d", card->shortname, rp->flags & 0xffL, rp->start, - __irq_itoa(sdev->irqs[0])); + sdev->irqs[0]); if ((err = snd_cs4231_sbus_create(card, sdev, dev, &cp)) < 0) { snd_card_free(card); @@ -2244,10 +2243,10 @@ static int __init cs4231_ebus_attach(struct linux_ebus_device *edev) if (err) return err; - sprintf(card->longname, "%s at 0x%lx, irq %s", + sprintf(card->longname, "%s at 0x%lx, irq %d", card->shortname, edev->resource[0].start, - __irq_itoa(edev->irqs[0])); + edev->irqs[0]); if ((err = snd_cs4231_ebus_create(card, edev, dev, &chip)) < 0) { snd_card_free(card); diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c index 2164b7d290c..e622d08215c 100644 --- a/sound/sparc/dbri.c +++ b/sound/sparc/dbri.c @@ -2645,9 +2645,9 @@ static int __init dbri_attach(int prom_node, struct sbus_dev *sdev) strcpy(card->driver, "DBRI"); strcpy(card->shortname, "Sun DBRI"); rp = &sdev->resource[0]; - sprintf(card->longname, "%s at 0x%02lx:0x%08lx, irq %s", + sprintf(card->longname, "%s at 0x%02lx:0x%08lx, irq %d", card->shortname, - rp->flags & 0xffL, rp->start, __irq_itoa(irq.pri)); + rp->flags & 0xffL, rp->start, irq.pri); if ((err = snd_dbri_create(card, sdev, &irq, dev)) < 0) { snd_card_free(card); -- cgit v1.2.3-70-g09d2 From 58b519f3e5e491d5a3e320dc525f58ac439bdde4 Mon Sep 17 00:00:00 2001 From: Wim Van Sebroeck Date: Sun, 21 May 2006 12:48:44 +0200 Subject: [WATCHDOG] add WDIOC_GETTIMELEFT ioctl Some watchdog drivers have the ability to report the remaining time before the system will reboot. With the WDIOC_GETTIMELEFT ioctl you can now read the time left before the watchdog would reboot your system. The following drivers support this new IOCTL: i8xx_tco.c, pcwd_pci.c and pcwd_usb.c . Signed-off-by: Wim Van Sebroeck Signed-off-by: Andrew Morton --- Documentation/watchdog/watchdog-api.txt | 9 +++++++++ drivers/char/watchdog/i8xx_tco.c | 28 +++++++++++++++++++++++++++- drivers/char/watchdog/pcwd_pci.c | 30 +++++++++++++++++++++++++++++- drivers/char/watchdog/pcwd_usb.c | 23 +++++++++++++++++++++++ include/linux/watchdog.h | 7 ++++--- 5 files changed, 92 insertions(+), 5 deletions(-) (limited to 'drivers/char') diff --git a/Documentation/watchdog/watchdog-api.txt b/Documentation/watchdog/watchdog-api.txt index 7dc2c1c6f77..d738ec25eaa 100644 --- a/Documentation/watchdog/watchdog-api.txt +++ b/Documentation/watchdog/watchdog-api.txt @@ -134,6 +134,15 @@ There is also a get function for getting the pretimeout: Not all watchdog drivers will support a pretimeout. +Get the number of seconds before reboot: + +Some watchdog drivers have the ability to report the remaining time +before the system will reboot. The WDIOC_GETTIMELEFT is the ioctl +that returns the number of seconds before reboot. + + ioctl(fd, WDIOC_GETTIMELEFT, &timeleft); + printf("The timeout was is %d seconds\n", timeleft); + Environmental monitoring: All watchdog drivers are required return more information about the system, diff --git a/drivers/char/watchdog/i8xx_tco.c b/drivers/char/watchdog/i8xx_tco.c index fa2ba9ebe42..bfbdbbf3c2f 100644 --- a/drivers/char/watchdog/i8xx_tco.c +++ b/drivers/char/watchdog/i8xx_tco.c @@ -205,6 +205,23 @@ static int tco_timer_set_heartbeat (int t) return 0; } +static int tco_timer_get_timeleft (int *time_left) +{ + unsigned char val; + + spin_lock(&tco_lock); + + /* read the TCO Timer */ + val = inb (TCO1_RLD); + val &= 0x3f; + + spin_unlock(&tco_lock); + + *time_left = (int)((val * 6) / 10); + + return 0; +} + /* * /dev/watchdog handling */ @@ -272,6 +289,7 @@ static int i8xx_tco_ioctl (struct inode *inode, struct file *file, { int new_options, retval = -EINVAL; int new_heartbeat; + int time_left; void __user *argp = (void __user *)arg; int __user *p = argp; static struct watchdog_info ident = { @@ -320,7 +338,7 @@ static int i8xx_tco_ioctl (struct inode *inode, struct file *file, return -EFAULT; if (tco_timer_set_heartbeat(new_heartbeat)) - return -EINVAL; + return -EINVAL; tco_timer_keepalive (); /* Fall */ @@ -329,6 +347,14 @@ static int i8xx_tco_ioctl (struct inode *inode, struct file *file, case WDIOC_GETTIMEOUT: return put_user(heartbeat, p); + case WDIOC_GETTIMELEFT: + { + if (tco_timer_get_timeleft(&time_left)) + return -EINVAL; + + return put_user(time_left, p); + } + default: return -ENOIOCTLCMD; } diff --git a/drivers/char/watchdog/pcwd_pci.c b/drivers/char/watchdog/pcwd_pci.c index 2451edbefec..1f40ecefbf7 100644 --- a/drivers/char/watchdog/pcwd_pci.c +++ b/drivers/char/watchdog/pcwd_pci.c @@ -21,7 +21,7 @@ */ /* - * A bells and whistles driver is available from: + * A bells and whistles driver is available from: * http://www.kernel.org/pub/linux/kernel/people/wim/pcwd/pcwd_pci/ * * More info available at http://www.berkprod.com/ or http://www.pcwatchdog.com/ @@ -390,6 +390,24 @@ static int pcipcwd_get_temperature(int *temperature) return 0; } +static int pcipcwd_get_timeleft(int *time_left) +{ + int msb; + int lsb; + + /* Read the time that's left before rebooting */ + /* Note: if the board is not yet armed then we will read 0xFFFF */ + send_command(CMD_READ_WATCHDOG_TIMEOUT, &msb, &lsb); + + *time_left = (msb << 8) + lsb; + + if (debug >= VERBOSE) + printk(KERN_DEBUG PFX "Time left before next reboot: %d\n", + *time_left); + + return 0; +} + /* * /dev/watchdog handling */ @@ -512,6 +530,16 @@ static int pcipcwd_ioctl(struct inode *inode, struct file *file, case WDIOC_GETTIMEOUT: return put_user(heartbeat, p); + case WDIOC_GETTIMELEFT: + { + int time_left; + + if (pcipcwd_get_timeleft(&time_left)) + return -EFAULT; + + return put_user(time_left, p); + } + default: return -ENOIOCTLCMD; } diff --git a/drivers/char/watchdog/pcwd_usb.c b/drivers/char/watchdog/pcwd_usb.c index 3fdfda9324f..0d072bed501 100644 --- a/drivers/char/watchdog/pcwd_usb.c +++ b/drivers/char/watchdog/pcwd_usb.c @@ -317,6 +317,19 @@ static int usb_pcwd_get_temperature(struct usb_pcwd_private *usb_pcwd, int *temp return 0; } +static int usb_pcwd_get_timeleft(struct usb_pcwd_private *usb_pcwd, int *time_left) +{ + unsigned char msb, lsb; + + /* Read the time that's left before rebooting */ + /* Note: if the board is not yet armed then we will read 0xFFFF */ + usb_pcwd_send_command(usb_pcwd, CMD_READ_WATCHDOG_TIMEOUT, &msb, &lsb); + + *time_left = (msb << 8) + lsb; + + return 0; +} + /* * /dev/watchdog handling */ @@ -422,6 +435,16 @@ static int usb_pcwd_ioctl(struct inode *inode, struct file *file, case WDIOC_GETTIMEOUT: return put_user(heartbeat, p); + case WDIOC_GETTIMELEFT: + { + int time_left; + + if (usb_pcwd_get_timeleft(usb_pcwd_device, &time_left)) + return -EFAULT; + + return put_user(time_left, p); + } + default: return -ENOIOCTLCMD; } diff --git a/include/linux/watchdog.h b/include/linux/watchdog.h index a99c937f665..011bcfeb9f0 100644 --- a/include/linux/watchdog.h +++ b/include/linux/watchdog.h @@ -30,6 +30,7 @@ struct watchdog_info { #define WDIOC_GETTIMEOUT _IOR(WATCHDOG_IOCTL_BASE, 7, int) #define WDIOC_SETPRETIMEOUT _IOWR(WATCHDOG_IOCTL_BASE, 8, int) #define WDIOC_GETPRETIMEOUT _IOR(WATCHDOG_IOCTL_BASE, 9, int) +#define WDIOC_GETTIMELEFT _IOR(WATCHDOG_IOCTL_BASE, 10, int) #define WDIOF_UNKNOWN -1 /* Unknown flag error */ #define WDIOS_UNKNOWN -1 /* Unknown status error */ @@ -40,9 +41,9 @@ struct watchdog_info { #define WDIOF_EXTERN2 0x0008 /* External relay 2 */ #define WDIOF_POWERUNDER 0x0010 /* Power bad/power fault */ #define WDIOF_CARDRESET 0x0020 /* Card previously reset the CPU */ -#define WDIOF_POWEROVER 0x0040 /* Power over voltage */ -#define WDIOF_SETTIMEOUT 0x0080 /* Set timeout (in seconds) */ -#define WDIOF_MAGICCLOSE 0x0100 /* Supports magic close char */ +#define WDIOF_POWEROVER 0x0040 /* Power over voltage */ +#define WDIOF_SETTIMEOUT 0x0080 /* Set timeout (in seconds) */ +#define WDIOF_MAGICCLOSE 0x0100 /* Supports magic close char */ #define WDIOF_PRETIMEOUT 0x0200 /* Pretimeout (in seconds), get/set */ #define WDIOF_KEEPALIVEPING 0x8000 /* Keep alive ping reply */ -- cgit v1.2.3-70-g09d2 From dfc7bd9c385a888851a2d009ba272099549f98cc Mon Sep 17 00:00:00 2001 From: Andrew Victor Date: Sun, 21 May 2006 15:32:59 +0200 Subject: [WATCHDOG] convert AT91RM9200 watchdog to platform driver Converted to a platform driver. Added suspend/resume support - the watchdog is disabled during the sleep states. Original patch from David Brownell. Signed-off-by: Andrew Victor Signed-off-by: Wim Van Sebroeck Signed-off-by: Andrew Morton --- drivers/char/watchdog/at91_wdt.c | 82 ++++++++++++++++++++++++++++++++++------ 1 file changed, 71 insertions(+), 11 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/watchdog/at91_wdt.c b/drivers/char/watchdog/at91_wdt.c index ac83bc4b019..00080655533 100644 --- a/drivers/char/watchdog/at91_wdt.c +++ b/drivers/char/watchdog/at91_wdt.c @@ -17,14 +17,15 @@ #include #include #include +#include #include #include #include #include -#define WDT_DEFAULT_TIME 5 /* 5 seconds */ -#define WDT_MAX_TIME 256 /* 256 seconds */ +#define WDT_DEFAULT_TIME 5 /* seconds */ +#define WDT_MAX_TIME 256 /* seconds */ static int wdt_time = WDT_DEFAULT_TIME; static int nowayout = WATCHDOG_NOWAYOUT; @@ -32,8 +33,10 @@ static int nowayout = WATCHDOG_NOWAYOUT; module_param(wdt_time, int, 0); MODULE_PARM_DESC(wdt_time, "Watchdog time in seconds. (default="__MODULE_STRING(WDT_DEFAULT_TIME) ")"); +#ifdef CONFIG_WATCHDOG_NOWAYOUT module_param(nowayout, int, 0); MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); +#endif static unsigned long at91wdt_busy; @@ -138,7 +141,7 @@ static int at91_wdt_ioctl(struct inode *inode, struct file *file, case WDIOC_SETTIMEOUT: if (get_user(new_value, p)) return -EFAULT; - + if (at91_wdt_settimeout(new_value)) return -EINVAL; @@ -196,27 +199,84 @@ static struct miscdevice at91wdt_miscdev = { .fops = &at91wdt_fops, }; -static int __init at91_wdt_init(void) +static int __init at91wdt_probe(struct platform_device *pdev) { int res; - /* Check that the heartbeat value is within range; if not reset to the default */ - if (at91_wdt_settimeout(wdt_time)) { - at91_wdt_settimeout(WDT_DEFAULT_TIME); - printk(KERN_INFO "at91_wdt: wdt_time value must be 1 <= wdt_time <= 256, using %d\n", wdt_time); - } + if (at91wdt_miscdev.dev) + return -EBUSY; + at91wdt_miscdev.dev = &pdev->dev; res = misc_register(&at91wdt_miscdev); if (res) return res; - printk("AT91 Watchdog Timer enabled (%d seconds, nowayout=%d)\n", wdt_time, nowayout); + printk("AT91 Watchdog Timer enabled (%d seconds%s)\n", wdt_time, nowayout ? ", nowayout" : ""); return 0; } +static int __exit at91wdt_remove(struct platform_device *pdev) +{ + int res; + + res = misc_deregister(&at91wdt_miscdev); + if (!res) + at91wdt_miscdev.dev = NULL; + + return res; +} + +static void at91wdt_shutdown(struct platform_device *pdev) +{ + at91_wdt_stop(); +} + +#ifdef CONFIG_PM + +static int at91wdt_suspend(struct platform_device *pdev, pm_message_t message) +{ + at91_wdt_stop(); + return 0; +} + +static int at91wdt_resume(struct platform_device *pdev) +{ + if (at91wdt_busy) + at91_wdt_start(); + return 0; +} + +#else +#define at91wdt_suspend NULL +#define at91wdt_resume NULL +#endif + +static struct platform_driver at91wdt_driver = { + .probe = at91wdt_probe, + .remove = __exit_p(at91wdt_remove), + .shutdown = at91wdt_shutdown, + .suspend = at91wdt_suspend, + .resume = at91wdt_resume, + .driver = { + .name = "at91_wdt", + .owner = THIS_MODULE, + }, +}; + +static int __init at91_wdt_init(void) +{ + /* Check that the heartbeat value is within range; if not reset to the default */ + if (at91_wdt_settimeout(wdt_time)) { + at91_wdt_settimeout(WDT_DEFAULT_TIME); + pr_info("at91_wdt: wdt_time value must be 1 <= wdt_time <= 256, using %d\n", wdt_time); + } + + return platform_driver_register(&at91wdt_driver); +} + static void __exit at91_wdt_exit(void) { - misc_deregister(&at91wdt_miscdev); + platform_driver_unregister(&at91wdt_driver); } module_init(at91_wdt_init); -- cgit v1.2.3-70-g09d2 From 1cdcb6b43fda7424b7435dac8f80b2b5d8a48899 Mon Sep 17 00:00:00 2001 From: Hansjoerg Lipp Date: Sat, 22 Apr 2006 18:36:53 +0200 Subject: [PATCH] TTY: return class device pointer from tty_register_device() Let tty_register_device() return a pointer to the class device it creates. This allows registrants to add their own sysfs files under the class device node. Signed-off-by: Hansjoerg Lipp Signed-off-by: Tilman Schmidt Signed-off-by: Greg Kroah-Hartman --- drivers/char/tty_io.c | 11 +++++++---- include/linux/tty.h | 4 +++- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index a88b94a82b1..8b2a5996986 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c @@ -2961,12 +2961,14 @@ static struct class *tty_class; * This field is optional, if there is no known struct device for this * tty device it can be set to NULL safely. * + * Returns a pointer to the class device (or ERR_PTR(-EFOO) on error). + * * This call is required to be made to register an individual tty device if * the tty driver's flags have the TTY_DRIVER_NO_DEVFS bit set. If that * bit is not set, this function should not be called. */ -void tty_register_device(struct tty_driver *driver, unsigned index, - struct device *device) +struct class_device *tty_register_device(struct tty_driver *driver, + unsigned index, struct device *device) { char name[64]; dev_t dev = MKDEV(driver->major, driver->minor_start) + index; @@ -2974,7 +2976,7 @@ void tty_register_device(struct tty_driver *driver, unsigned index, if (index >= driver->num) { printk(KERN_ERR "Attempt to register invalid tty line number " " (%d).\n", index); - return; + return ERR_PTR(-EINVAL); } devfs_mk_cdev(dev, S_IFCHR | S_IRUSR | S_IWUSR, @@ -2984,7 +2986,8 @@ void tty_register_device(struct tty_driver *driver, unsigned index, pty_line_name(driver, index, name); else tty_line_name(driver, index, name); - class_device_create(tty_class, NULL, dev, device, "%s", name); + + return class_device_create(tty_class, NULL, dev, device, "%s", name); } /** diff --git a/include/linux/tty.h b/include/linux/tty.h index e898eeb9416..cb35ca50a0a 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h @@ -290,7 +290,9 @@ extern int tty_register_ldisc(int disc, struct tty_ldisc *new_ldisc); extern int tty_unregister_ldisc(int disc); extern int tty_register_driver(struct tty_driver *driver); extern int tty_unregister_driver(struct tty_driver *driver); -extern void tty_register_device(struct tty_driver *driver, unsigned index, struct device *dev); +extern struct class_device *tty_register_device(struct tty_driver *driver, + unsigned index, + struct device *dev); extern void tty_unregister_device(struct tty_driver *driver, unsigned index); extern int tty_read_raw_data(struct tty_struct *tty, unsigned char *bufp, int buflen); -- cgit v1.2.3-70-g09d2 From dcc1a66a09420ccc5a22671bddc5a842f92d67e5 Mon Sep 17 00:00:00 2001 From: Roman Zippel Date: Thu, 22 Jun 2006 14:47:35 -0700 Subject: [PATCH] x86_64: use select for GART_IOMMU to enable AGP The AGP default doesn't work well with other selects, so use a select for GART_IOMMU as well. Remove a redundant default for SWIOTLB as well. Signed-off-by: Roman Zippel Signed-off-by: Andi Kleen Cc: Andi Kleen Cc: Dave Jones Cc: Dave Airlie Cc: Jeff Garzik Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/x86_64/Kconfig | 5 ++--- drivers/char/agp/Kconfig | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'drivers/char') diff --git a/arch/x86_64/Kconfig b/arch/x86_64/Kconfig index 408d44a5975..7d3bc5ac5db 100644 --- a/arch/x86_64/Kconfig +++ b/arch/x86_64/Kconfig @@ -389,6 +389,7 @@ config GART_IOMMU bool "K8 GART IOMMU support" default y select SWIOTLB + select AGP depends on PCI help Support for hardware IOMMU in AMD's Opteron/Athlon64 Processors @@ -401,11 +402,9 @@ config GART_IOMMU northbridge and a software emulation used on other systems without hardware IOMMU. If unsure, say Y. -# need this always enabled with GART_IOMMU for the VIA workaround +# need this always selected by GART_IOMMU for the VIA workaround config SWIOTLB bool - default y - depends on GART_IOMMU config X86_MCE bool "Machine check support" if EMBEDDED diff --git a/drivers/char/agp/Kconfig b/drivers/char/agp/Kconfig index 7c88c060a9e..46685a54077 100644 --- a/drivers/char/agp/Kconfig +++ b/drivers/char/agp/Kconfig @@ -1,7 +1,6 @@ config AGP - tristate "/dev/agpgart (AGP Support)" if !GART_IOMMU + tristate "/dev/agpgart (AGP Support)" depends on ALPHA || IA64 || PPC || X86 - default y if GART_IOMMU ---help--- AGP (Accelerated Graphics Port) is a bus system mainly used to connect graphics cards to the rest of the system. -- cgit v1.2.3-70-g09d2 From 66f969d064e46e6690c3426e2af846e76fb80e83 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Fri, 23 Jun 2006 02:05:45 -0700 Subject: [PATCH] ipmi: strstrip conversion Switch an open-coded strstrip() to use the new API. Acked-by: Corey Minyard Signed-off-by: Pekka Enberg Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/ipmi/ipmi_watchdog.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c index 2d11ddd99e5..8f886717097 100644 --- a/drivers/char/ipmi/ipmi_watchdog.c +++ b/drivers/char/ipmi/ipmi_watchdog.c @@ -212,24 +212,16 @@ static int set_param_str(const char *val, struct kernel_param *kp) { action_fn fn = (action_fn) kp->arg; int rv = 0; - const char *end; - char valcp[16]; - int len; - - /* Truncate leading and trailing spaces. */ - while (isspace(*val)) - val++; - end = val + strlen(val) - 1; - while ((end >= val) && isspace(*end)) - end--; - len = end - val + 1; - if (len > sizeof(valcp) - 1) - return -EINVAL; - memcpy(valcp, val, len); - valcp[len] = '\0'; + char *dup, *s; + + dup = kstrdup(val, GFP_KERNEL); + if (!dup) + return -ENOMEM; + + s = strstrip(dup); down_read(®ister_sem); - rv = fn(valcp, NULL); + rv = fn(s, NULL); if (rv) goto out_unlock; @@ -239,6 +231,7 @@ static int set_param_str(const char *val, struct kernel_param *kp) out_unlock: up_read(®ister_sem); + kfree(dup); return rv; } -- cgit v1.2.3-70-g09d2 From cdaad343b561cdeb38b0578bb038eb5e87ed5551 Mon Sep 17 00:00:00 2001 From: Peter Hagervall Date: Fri, 23 Jun 2006 02:06:04 -0700 Subject: [PATCH] Sparse fixes for synclink_cs Mark a few non-exported functions static. Signed-off-by: Peter Hagervall Cc: Paul Fulghum Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/pcmcia/synclink_cs.c | 54 +++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index 07213454c45..0c141c295fb 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c @@ -844,7 +844,7 @@ static int bh_action(MGSLPC_INFO *info) return rc; } -void bh_handler(void* Context) +static void bh_handler(void* Context) { MGSLPC_INFO *info = (MGSLPC_INFO*)Context; int action; @@ -888,7 +888,7 @@ void bh_handler(void* Context) __FILE__,__LINE__,info->device_name); } -void bh_transmit(MGSLPC_INFO *info) +static void bh_transmit(MGSLPC_INFO *info) { struct tty_struct *tty = info->tty; if (debug_level >= DEBUG_LEVEL_BH) @@ -900,7 +900,7 @@ void bh_transmit(MGSLPC_INFO *info) } } -void bh_status(MGSLPC_INFO *info) +static void bh_status(MGSLPC_INFO *info) { info->ri_chkcount = 0; info->dsr_chkcount = 0; @@ -2305,7 +2305,7 @@ static int mgslpc_ioctl(struct tty_struct *tty, struct file * file, return ioctl_common(info, cmd, arg); } -int ioctl_common(MGSLPC_INFO *info, unsigned int cmd, unsigned long arg) +static int ioctl_common(MGSLPC_INFO *info, unsigned int cmd, unsigned long arg) { int error; struct mgsl_icount cnow; /* kernel counter temps */ @@ -2877,7 +2877,7 @@ done: return ((count < begin+len-off) ? count : begin+len-off); } -int rx_alloc_buffers(MGSLPC_INFO *info) +static int rx_alloc_buffers(MGSLPC_INFO *info) { /* each buffer has header and data */ info->rx_buf_size = sizeof(RXBUF) + info->max_frame_size; @@ -2900,13 +2900,13 @@ int rx_alloc_buffers(MGSLPC_INFO *info) return 0; } -void rx_free_buffers(MGSLPC_INFO *info) +static void rx_free_buffers(MGSLPC_INFO *info) { kfree(info->rx_buf); info->rx_buf = NULL; } -int claim_resources(MGSLPC_INFO *info) +static int claim_resources(MGSLPC_INFO *info) { if (rx_alloc_buffers(info) < 0 ) { printk( "Cant allocate rx buffer %s\n", info->device_name); @@ -2916,7 +2916,7 @@ int claim_resources(MGSLPC_INFO *info) return 0; } -void release_resources(MGSLPC_INFO *info) +static void release_resources(MGSLPC_INFO *info) { if (debug_level >= DEBUG_LEVEL_INFO) printk("release_resources(%s)\n", info->device_name); @@ -2928,7 +2928,7 @@ void release_resources(MGSLPC_INFO *info) * * Arguments: info pointer to device instance data */ -void mgslpc_add_device(MGSLPC_INFO *info) +static void mgslpc_add_device(MGSLPC_INFO *info) { info->next_device = NULL; info->line = mgslpc_device_count; @@ -2964,7 +2964,7 @@ void mgslpc_add_device(MGSLPC_INFO *info) #endif } -void mgslpc_remove_device(MGSLPC_INFO *remove_info) +static void mgslpc_remove_device(MGSLPC_INFO *remove_info) { MGSLPC_INFO *info = mgslpc_device_list; MGSLPC_INFO *last = NULL; @@ -3257,7 +3257,7 @@ static void loopback_enable(MGSLPC_INFO *info) write_reg(info, CHA + MODE, val); } -void hdlc_mode(MGSLPC_INFO *info) +static void hdlc_mode(MGSLPC_INFO *info) { unsigned char val; unsigned char clkmode, clksubmode; @@ -3497,7 +3497,7 @@ void hdlc_mode(MGSLPC_INFO *info) rx_stop(info); } -void rx_stop(MGSLPC_INFO *info) +static void rx_stop(MGSLPC_INFO *info) { if (debug_level >= DEBUG_LEVEL_ISR) printk("%s(%d):rx_stop(%s)\n", @@ -3510,7 +3510,7 @@ void rx_stop(MGSLPC_INFO *info) info->rx_overflow = 0; } -void rx_start(MGSLPC_INFO *info) +static void rx_start(MGSLPC_INFO *info) { if (debug_level >= DEBUG_LEVEL_ISR) printk("%s(%d):rx_start(%s)\n", @@ -3526,7 +3526,7 @@ void rx_start(MGSLPC_INFO *info) info->rx_enabled = 1; } -void tx_start(MGSLPC_INFO *info) +static void tx_start(MGSLPC_INFO *info) { if (debug_level >= DEBUG_LEVEL_ISR) printk("%s(%d):tx_start(%s)\n", @@ -3564,7 +3564,7 @@ void tx_start(MGSLPC_INFO *info) info->tx_enabled = 1; } -void tx_stop(MGSLPC_INFO *info) +static void tx_stop(MGSLPC_INFO *info) { if (debug_level >= DEBUG_LEVEL_ISR) printk("%s(%d):tx_stop(%s)\n", @@ -3578,7 +3578,7 @@ void tx_stop(MGSLPC_INFO *info) /* Reset the adapter to a known state and prepare it for further use. */ -void reset_device(MGSLPC_INFO *info) +static void reset_device(MGSLPC_INFO *info) { /* power up both channels (set BIT7) */ write_reg(info, CHA + CCR0, 0x80); @@ -3628,7 +3628,7 @@ void reset_device(MGSLPC_INFO *info) write_reg(info, IPC, 0x05); } -void async_mode(MGSLPC_INFO *info) +static void async_mode(MGSLPC_INFO *info) { unsigned char val; @@ -3799,7 +3799,7 @@ void async_mode(MGSLPC_INFO *info) /* Set the HDLC idle mode for the transmitter. */ -void tx_set_idle(MGSLPC_INFO *info) +static void tx_set_idle(MGSLPC_INFO *info) { /* Note: ESCC2 only supports flags and one idle modes */ if (info->idle_mode == HDLC_TXIDLE_FLAGS) @@ -3810,7 +3810,7 @@ void tx_set_idle(MGSLPC_INFO *info) /* get state of the V24 status (input) signals. */ -void get_signals(MGSLPC_INFO *info) +static void get_signals(MGSLPC_INFO *info) { unsigned char status = 0; @@ -3832,7 +3832,7 @@ void get_signals(MGSLPC_INFO *info) /* Set the state of DTR and RTS based on contents of * serial_signals member of device extension. */ -void set_signals(MGSLPC_INFO *info) +static void set_signals(MGSLPC_INFO *info) { unsigned char val; @@ -3856,7 +3856,7 @@ void set_signals(MGSLPC_INFO *info) set_reg_bits(info, CHA + PVR, PVR_DTR); } -void rx_reset_buffers(MGSLPC_INFO *info) +static void rx_reset_buffers(MGSLPC_INFO *info) { RXBUF *buf; int i; @@ -3875,7 +3875,7 @@ void rx_reset_buffers(MGSLPC_INFO *info) * * Returns 1 if frame returned, otherwise 0 */ -int rx_get_frame(MGSLPC_INFO *info) +static int rx_get_frame(MGSLPC_INFO *info) { unsigned short status; RXBUF *buf; @@ -3961,7 +3961,7 @@ int rx_get_frame(MGSLPC_INFO *info) return 1; } -BOOLEAN register_test(MGSLPC_INFO *info) +static BOOLEAN register_test(MGSLPC_INFO *info) { static unsigned char patterns[] = { 0x00, 0xff, 0xaa, 0x55, 0x69, 0x96, 0x0f }; @@ -3987,7 +3987,7 @@ BOOLEAN register_test(MGSLPC_INFO *info) return rc; } -BOOLEAN irq_test(MGSLPC_INFO *info) +static BOOLEAN irq_test(MGSLPC_INFO *info) { unsigned long end_time; unsigned long flags; @@ -4022,7 +4022,7 @@ BOOLEAN irq_test(MGSLPC_INFO *info) return info->irq_occurred ? TRUE : FALSE; } -int adapter_test(MGSLPC_INFO *info) +static int adapter_test(MGSLPC_INFO *info) { if (!register_test(info)) { info->init_error = DiagStatus_AddressFailure; @@ -4044,7 +4044,7 @@ int adapter_test(MGSLPC_INFO *info) return 0; } -void trace_block(MGSLPC_INFO *info,const char* data, int count, int xmit) +static void trace_block(MGSLPC_INFO *info,const char* data, int count, int xmit) { int i; int linecount; @@ -4079,7 +4079,7 @@ void trace_block(MGSLPC_INFO *info,const char* data, int count, int xmit) /* HDLC frame time out * update stats and do tx completion processing */ -void tx_timeout(unsigned long context) +static void tx_timeout(unsigned long context) { MGSLPC_INFO *info = (MGSLPC_INFO*)context; unsigned long flags; -- cgit v1.2.3-70-g09d2 From 690c8fd31f1e35985d0f35772fde514da59ec9d1 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Thu, 22 Jun 2006 19:12:03 -0700 Subject: [SPARC64]: Use in-kernel PROM tree for EBUS and ISA. Signed-off-by: David S. Miller --- arch/sparc64/kernel/auxio.c | 2 +- arch/sparc64/kernel/ebus.c | 141 +++++++------- arch/sparc64/kernel/isa.c | 144 ++++++-------- arch/sparc64/kernel/power.c | 20 +- arch/sparc64/kernel/prom.c | 1 + arch/sparc64/kernel/time.c | 368 +++++++++++++++++++----------------- drivers/char/rtc.c | 4 +- drivers/input/misc/sparcspkr.c | 4 +- drivers/input/serio/i8042-sparcio.h | 10 +- drivers/sbus/char/bbc_envctrl.c | 4 +- drivers/sbus/char/bbc_i2c.c | 4 +- drivers/sbus/char/display7seg.c | 2 +- drivers/sbus/char/envctrl.c | 71 ++++--- drivers/sbus/char/flash.c | 16 +- drivers/serial/sunsab.c | 12 +- drivers/serial/sunsu.c | 4 +- include/asm-sparc64/ebus.h | 10 +- include/asm-sparc64/floppy.h | 27 ++- include/asm-sparc64/isa.h | 8 +- include/asm-sparc64/parport.h | 25 ++- sound/sparc/cs4231.c | 13 +- 21 files changed, 440 insertions(+), 450 deletions(-) (limited to 'drivers/char') diff --git a/arch/sparc64/kernel/auxio.c b/arch/sparc64/kernel/auxio.c index 8852c20c8d9..db36b66a4e3 100644 --- a/arch/sparc64/kernel/auxio.c +++ b/arch/sparc64/kernel/auxio.c @@ -136,7 +136,7 @@ found_sdev: for_each_ebus(ebus) { for_each_ebusdev(edev, ebus) { - if (!strcmp(edev->prom_name, "auxio")) + if (!strcmp(edev->prom_node->name, "auxio")) goto ebus_done; } } diff --git a/arch/sparc64/kernel/ebus.c b/arch/sparc64/kernel/ebus.c index 3125a5b4977..919a91d9e5d 100644 --- a/arch/sparc64/kernel/ebus.c +++ b/arch/sparc64/kernel/ebus.c @@ -285,36 +285,38 @@ static inline void *ebus_alloc(size_t size) static void __init ebus_ranges_init(struct linux_ebus *ebus) { - int success; + struct linux_prom_ebus_ranges *rngs; + int len; ebus->num_ebus_ranges = 0; - success = prom_getproperty(ebus->prom_node, "ranges", - (char *)ebus->ebus_ranges, - sizeof(ebus->ebus_ranges)); - if (success != -1) - ebus->num_ebus_ranges = (success/sizeof(struct linux_prom_ebus_ranges)); + rngs = of_get_property(ebus->prom_node, "ranges", &len); + if (rngs) { + memcpy(ebus->ebus_ranges, rngs, len); + ebus->num_ebus_ranges = + (len / sizeof(struct linux_prom_ebus_ranges)); + } } static void __init ebus_intmap_init(struct linux_ebus *ebus) { - int success; + struct linux_prom_ebus_intmap *imap; + struct linux_prom_ebus_intmask *imask; + int len; ebus->num_ebus_intmap = 0; - success = prom_getproperty(ebus->prom_node, "interrupt-map", - (char *)ebus->ebus_intmap, - sizeof(ebus->ebus_intmap)); - if (success == -1) + imap = of_get_property(ebus->prom_node, "interrupt-map", &len); + if (!imap) return; - ebus->num_ebus_intmap = (success/sizeof(struct linux_prom_ebus_intmap)); + memcpy(ebus->ebus_intmap, imap, len); + ebus->num_ebus_intmap = (len / sizeof(struct linux_prom_ebus_intmap)); - success = prom_getproperty(ebus->prom_node, "interrupt-map-mask", - (char *)&ebus->ebus_intmask, - sizeof(ebus->ebus_intmask)); - if (success == -1) { - prom_printf("%s: can't get interrupt-map-mask\n", __FUNCTION__); + imask = of_get_property(ebus->prom_node, "interrupt-map-mask", &len); + if (!imask) { + prom_printf("EBUS: can't get interrupt-map-mask\n"); prom_halt(); } + memcpy(&ebus->ebus_intmask, imask, sizeof(ebus->ebus_intmask)); } int __init ebus_intmap_match(struct linux_ebus *ebus, @@ -341,19 +343,23 @@ int __init ebus_intmap_match(struct linux_ebus *ebus, return -1; } -void __init fill_ebus_child(int node, struct linux_prom_registers *preg, - struct linux_ebus_child *dev, int non_standard_regs) +void __init fill_ebus_child(struct device_node *dp, + struct linux_prom_registers *preg, + struct linux_ebus_child *dev, + int non_standard_regs) { - int regs[PROMREG_MAX]; - int irqs[PROMREG_MAX]; + int *regs; + int *irqs; int i, len; - dev->prom_node = node; - prom_getstring(node, "name", dev->prom_name, sizeof(dev->prom_name)); - printk(" (%s)", dev->prom_name); + dev->prom_node = dp; + printk(" (%s)", dp->name); - len = prom_getproperty(node, "reg", (void *)regs, sizeof(regs)); - dev->num_addrs = len / sizeof(regs[0]); + regs = of_get_property(dp, "reg", &len); + if (!regs) + dev->num_addrs = 0; + else + dev->num_addrs = len / sizeof(regs[0]); if (non_standard_regs) { /* This is to handle reg properties which are not @@ -370,21 +376,21 @@ void __init fill_ebus_child(int node, struct linux_prom_registers *preg, int rnum = regs[i]; if (rnum >= dev->parent->num_addrs) { prom_printf("UGH: property for %s was %d, need < %d\n", - dev->prom_name, len, dev->parent->num_addrs); - panic(__FUNCTION__); + dp->name, len, dev->parent->num_addrs); + prom_halt(); } dev->resource[i].start = dev->parent->resource[i].start; dev->resource[i].end = dev->parent->resource[i].end; dev->resource[i].flags = IORESOURCE_MEM; - dev->resource[i].name = dev->prom_name; + dev->resource[i].name = dp->name; } } for (i = 0; i < PROMINTR_MAX; i++) dev->irqs[i] = PCI_IRQ_NONE; - len = prom_getproperty(node, "interrupts", (char *)&irqs, sizeof(irqs)); - if ((len == -1) || (len == 0)) { + irqs = of_get_property(dp, "interrupts", &len); + if (!irqs) { dev->num_irqs = 0; /* * Oh, well, some PROMs don't export interrupts @@ -392,8 +398,8 @@ void __init fill_ebus_child(int node, struct linux_prom_registers *preg, * * Be smart about PS/2 keyboard and mouse. */ - if (!strcmp(dev->parent->prom_name, "8042")) { - if (!strcmp(dev->prom_name, "kb_ps2")) { + if (!strcmp(dev->parent->prom_node->name, "8042")) { + if (!strcmp(dev->prom_node->name, "kb_ps2")) { dev->num_irqs = 1; dev->irqs[0] = dev->parent->irqs[0]; } else { @@ -423,32 +429,32 @@ void __init fill_ebus_child(int node, struct linux_prom_registers *preg, static int __init child_regs_nonstandard(struct linux_ebus_device *dev) { - if (!strcmp(dev->prom_name, "i2c") || - !strcmp(dev->prom_name, "SUNW,lombus")) + if (!strcmp(dev->prom_node->name, "i2c") || + !strcmp(dev->prom_node->name, "SUNW,lombus")) return 1; return 0; } -void __init fill_ebus_device(int node, struct linux_ebus_device *dev) +void __init fill_ebus_device(struct device_node *dp, struct linux_ebus_device *dev) { - struct linux_prom_registers regs[PROMREG_MAX]; + struct linux_prom_registers *regs; struct linux_ebus_child *child; - int irqs[PROMINTR_MAX]; + int *irqs; int i, n, len; - dev->prom_node = node; - prom_getstring(node, "name", dev->prom_name, sizeof(dev->prom_name)); - printk(" [%s", dev->prom_name); + dev->prom_node = dp; - len = prom_getproperty(node, "reg", (void *)regs, sizeof(regs)); - if (len == -1) { + printk(" [%s", dp->name); + + regs = of_get_property(dp, "reg", &len); + if (!regs) { dev->num_addrs = 0; goto probe_interrupts; } if (len % sizeof(struct linux_prom_registers)) { prom_printf("UGH: proplen for %s was %d, need multiple of %d\n", - dev->prom_name, len, + dev->prom_node->name, len, (int)sizeof(struct linux_prom_registers)); prom_halt(); } @@ -466,7 +472,7 @@ void __init fill_ebus_device(int node, struct linux_ebus_device *dev) dev->resource[i].end = (dev->resource[i].start + (unsigned long)regs[i].reg_size - 1UL); dev->resource[i].flags = IORESOURCE_MEM; - dev->resource[i].name = dev->prom_name; + dev->resource[i].name = dev->prom_node->name; request_resource(&dev->bus->self->resource[n], &dev->resource[i]); } @@ -475,8 +481,8 @@ probe_interrupts: for (i = 0; i < PROMINTR_MAX; i++) dev->irqs[i] = PCI_IRQ_NONE; - len = prom_getproperty(node, "interrupts", (char *)&irqs, sizeof(irqs)); - if ((len == -1) || (len == 0)) { + irqs = of_get_property(dp, "interrupts", &len); + if (!irqs) { dev->num_irqs = 0; } else { dev->num_irqs = len / sizeof(irqs[0]); @@ -497,7 +503,8 @@ probe_interrupts: } } - if ((node = prom_getchild(node))) { + dp = dp->child; + if (dp) { printk(" ->"); dev->children = ebus_alloc(sizeof(struct linux_ebus_child)); @@ -505,18 +512,18 @@ probe_interrupts: child->next = NULL; child->parent = dev; child->bus = dev->bus; - fill_ebus_child(node, ®s[0], - child, child_regs_nonstandard(dev)); + fill_ebus_child(dp, regs, child, + child_regs_nonstandard(dev)); - while ((node = prom_getsibling(node)) != 0) { + while ((dp = dp->sibling) != NULL) { child->next = ebus_alloc(sizeof(struct linux_ebus_child)); child = child->next; child->next = NULL; child->parent = dev; child->bus = dev->bus; - fill_ebus_child(node, ®s[0], - child, child_regs_nonstandard(dev)); + fill_ebus_child(dp, regs, child, + child_regs_nonstandard(dev)); } } printk("]"); @@ -543,7 +550,8 @@ void __init ebus_init(void) struct linux_ebus *ebus; struct pci_dev *pdev; struct pcidev_cookie *cookie; - int nd, ebusnd, is_rio; + struct device_node *dp; + int is_rio; int num_ebus = 0; pdev = find_next_ebus(NULL, &is_rio); @@ -553,20 +561,22 @@ void __init ebus_init(void) } cookie = pdev->sysdata; - ebusnd = cookie->prom_node->node; + dp = cookie->prom_node; ebus_chain = ebus = ebus_alloc(sizeof(struct linux_ebus)); ebus->next = NULL; ebus->is_rio = is_rio; - while (ebusnd) { + while (dp) { + struct device_node *child; + /* SUNW,pci-qfe uses four empty ebuses on it. I think we should not consider them here, as they have half of the properties this code expects and once we do PCI hot-plug, we'd have to tweak with the ebus_chain in the runtime after initialization. -jj */ - if (!prom_getchild (ebusnd)) { + if (!dp->child) { pdev = find_next_ebus(pdev, &is_rio); if (!pdev) { if (ebus == ebus_chain) { @@ -578,22 +588,21 @@ void __init ebus_init(void) } ebus->is_rio = is_rio; cookie = pdev->sysdata; - ebusnd = cookie->prom_node->node; + dp = cookie->prom_node; continue; } printk("ebus%d:", num_ebus); - prom_getstring(ebusnd, "name", ebus->prom_name, sizeof(ebus->prom_name)); ebus->index = num_ebus; - ebus->prom_node = ebusnd; + ebus->prom_node = dp; ebus->self = pdev; ebus->parent = pbm = cookie->pbm; ebus_ranges_init(ebus); ebus_intmap_init(ebus); - nd = prom_getchild(ebusnd); - if (!nd) + child = dp->child; + if (!child) goto next_ebus; ebus->devices = ebus_alloc(sizeof(struct linux_ebus_device)); @@ -602,16 +611,16 @@ void __init ebus_init(void) dev->next = NULL; dev->children = NULL; dev->bus = ebus; - fill_ebus_device(nd, dev); + fill_ebus_device(child, dev); - while ((nd = prom_getsibling(nd)) != 0) { + while ((child = child->sibling) != NULL) { dev->next = ebus_alloc(sizeof(struct linux_ebus_device)); dev = dev->next; dev->next = NULL; dev->children = NULL; dev->bus = ebus; - fill_ebus_device(nd, dev); + fill_ebus_device(child, dev); } next_ebus: @@ -622,7 +631,7 @@ void __init ebus_init(void) break; cookie = pdev->sysdata; - ebusnd = cookie->prom_node->node; + dp = cookie->prom_node; ebus->next = ebus_alloc(sizeof(struct linux_ebus)); ebus = ebus->next; diff --git a/arch/sparc64/kernel/isa.c b/arch/sparc64/kernel/isa.c index ae02c3820ea..8c8c5a491ad 100644 --- a/arch/sparc64/kernel/isa.c +++ b/arch/sparc64/kernel/isa.c @@ -15,23 +15,19 @@ static void __init fatal_err(const char *reason) static void __init report_dev(struct sparc_isa_device *isa_dev, int child) { if (child) - printk(" (%s)", isa_dev->prom_name); + printk(" (%s)", isa_dev->prom_node->name); else - printk(" [%s", isa_dev->prom_name); + printk(" [%s", isa_dev->prom_node->name); } -static void __init isa_dev_get_resource(struct sparc_isa_device *isa_dev, - struct linux_prom_registers *pregs, - int pregs_size) +static struct linux_prom_registers * __init +isa_dev_get_resource(struct sparc_isa_device *isa_dev) { + struct linux_prom_registers *pregs; unsigned long base, len; int prop_len; - prop_len = prom_getproperty(isa_dev->prom_node, "reg", - (char *) pregs, pregs_size); - - if (prop_len <= 0) - return; + pregs = of_get_property(isa_dev->prom_node, "reg", &prop_len); /* Only the first one is interesting. */ len = pregs[0].reg_size; @@ -42,10 +38,12 @@ static void __init isa_dev_get_resource(struct sparc_isa_device *isa_dev, isa_dev->resource.start = base; isa_dev->resource.end = (base + len - 1UL); isa_dev->resource.flags = IORESOURCE_IO; - isa_dev->resource.name = isa_dev->prom_name; + isa_dev->resource.name = isa_dev->prom_node->name; request_resource(&isa_dev->bus->parent->io_space, &isa_dev->resource); + + return pregs; } /* I can't believe they didn't put a real INO in the isa device @@ -98,8 +96,8 @@ static void __init isa_dev_get_irq(struct sparc_isa_device *isa_dev, { int irq_prop; - irq_prop = prom_getintdefault(isa_dev->prom_node, - "interrupts", -1); + irq_prop = of_getintprop_default(isa_dev->prom_node, + "interrupts", -1); if (irq_prop <= 0) { goto no_irq; } else { @@ -141,16 +139,15 @@ no_irq: static void __init isa_fill_children(struct sparc_isa_device *parent_isa_dev) { - int node = prom_getchild(parent_isa_dev->prom_node); + struct device_node *dp = parent_isa_dev->prom_node->child; - if (node == 0) + if (!dp) return; printk(" ->"); - while (node != 0) { - struct linux_prom_registers regs[PROMREG_MAX]; + while (dp) { + struct linux_prom_registers *regs; struct sparc_isa_device *isa_dev; - int prop_len; isa_dev = kmalloc(sizeof(*isa_dev), GFP_KERNEL); if (!isa_dev) { @@ -165,40 +162,24 @@ static void __init isa_fill_children(struct sparc_isa_device *parent_isa_dev) parent_isa_dev->child = isa_dev; isa_dev->bus = parent_isa_dev->bus; - isa_dev->prom_node = node; - prop_len = prom_getproperty(node, "name", - (char *) isa_dev->prom_name, - sizeof(isa_dev->prom_name)); - if (prop_len <= 0) { - fatal_err("cannot get child isa_dev OBP node name"); - prom_halt(); - } - - prop_len = prom_getproperty(node, "compatible", - (char *) isa_dev->compatible, - sizeof(isa_dev->compatible)); + isa_dev->prom_node = dp; - /* Not having this is OK. */ - if (prop_len <= 0) - isa_dev->compatible[0] = '\0'; - - isa_dev_get_resource(isa_dev, regs, sizeof(regs)); + regs = isa_dev_get_resource(isa_dev); isa_dev_get_irq(isa_dev, regs); report_dev(isa_dev, 1); - node = prom_getsibling(node); + dp = dp->sibling; } } static void __init isa_fill_devices(struct sparc_isa_bridge *isa_br) { - int node = prom_getchild(isa_br->prom_node); + struct device_node *dp = isa_br->prom_node->child; - while (node != 0) { - struct linux_prom_registers regs[PROMREG_MAX]; + while (dp) { + struct linux_prom_registers *regs; struct sparc_isa_device *isa_dev; - int prop_len; isa_dev = kmalloc(sizeof(*isa_dev), GFP_KERNEL); if (!isa_dev) { @@ -222,24 +203,9 @@ static void __init isa_fill_devices(struct sparc_isa_bridge *isa_br) } isa_dev->bus = isa_br; - isa_dev->prom_node = node; - prop_len = prom_getproperty(node, "name", - (char *) isa_dev->prom_name, - sizeof(isa_dev->prom_name)); - if (prop_len <= 0) { - fatal_err("cannot get isa_dev OBP node name"); - prom_halt(); - } - - prop_len = prom_getproperty(node, "compatible", - (char *) isa_dev->compatible, - sizeof(isa_dev->compatible)); - - /* Not having this is OK. */ - if (prop_len <= 0) - isa_dev->compatible[0] = '\0'; + isa_dev->prom_node = dp; - isa_dev_get_resource(isa_dev, regs, sizeof(regs)); + regs = isa_dev_get_resource(isa_dev); isa_dev_get_irq(isa_dev, regs); report_dev(isa_dev, 0); @@ -248,10 +214,40 @@ static void __init isa_fill_devices(struct sparc_isa_bridge *isa_br) printk("]"); - node = prom_getsibling(node); + dp = dp->sibling; } } +static void __init get_bridge_props(struct sparc_isa_bridge *isa_br) +{ + struct device_node *dp = isa_br->prom_node; + void *pval; + int len; + + pval = of_get_property(dp, "ranges", &len); + if (pval) { + memcpy(isa_br->isa_ranges, pval, len); + isa_br->num_isa_ranges = + len / sizeof(struct linux_prom_isa_ranges); + } else { + isa_br->num_isa_ranges = 0; + } + + pval = of_get_property(dp, "interrupt-map", &len); + if (pval) { + memcpy(isa_br->isa_intmap, pval, len); + isa_br->num_isa_intmap = + (len / sizeof(struct linux_prom_isa_intmap)); + } else { + isa_br->num_isa_intmap = 0; + } + + pval = of_get_property(dp, "interrupt-map-mask", &len); + if (pval) + memcpy(&isa_br->isa_intmask, pval, + sizeof(isa_br->isa_intmask)); +} + void __init isa_init(void) { struct pci_dev *pdev; @@ -266,7 +262,6 @@ void __init isa_init(void) struct pcidev_cookie *pdev_cookie; struct pci_pbm_info *pbm; struct sparc_isa_bridge *isa_br; - int prop_len; pdev_cookie = pdev->sysdata; if (!pdev_cookie) { @@ -291,34 +286,9 @@ void __init isa_init(void) isa_br->parent = pbm; isa_br->self = pdev; isa_br->index = index++; - isa_br->prom_node = pdev_cookie->prom_node->node; - strncpy(isa_br->prom_name, pdev_cookie->prom_node->name, - sizeof(isa_br->prom_name)); - - prop_len = prom_getproperty(isa_br->prom_node, - "ranges", - (char *) isa_br->isa_ranges, - sizeof(isa_br->isa_ranges)); - if (prop_len <= 0) - isa_br->num_isa_ranges = 0; - else - isa_br->num_isa_ranges = - (prop_len / sizeof(struct linux_prom_isa_ranges)); - - prop_len = prom_getproperty(isa_br->prom_node, - "interrupt-map", - (char *) isa_br->isa_intmap, - sizeof(isa_br->isa_intmap)); - if (prop_len <= 0) - isa_br->num_isa_intmap = 0; - else - isa_br->num_isa_intmap = - (prop_len / sizeof(struct linux_prom_isa_intmap)); - - prop_len = prom_getproperty(isa_br->prom_node, - "interrupt-map-mask", - (char *) &(isa_br->isa_intmask), - sizeof(isa_br->isa_intmask)); + isa_br->prom_node = pdev_cookie->prom_node; + + get_bridge_props(isa_br); printk("isa%d:", isa_br->index); diff --git a/arch/sparc64/kernel/power.c b/arch/sparc64/kernel/power.c index 30bcaf58e3a..75159a7843f 100644 --- a/arch/sparc64/kernel/power.c +++ b/arch/sparc64/kernel/power.c @@ -105,24 +105,24 @@ again: return 0; } -static int __init has_button_interrupt(unsigned int irq, int prom_node) +static int __init has_button_interrupt(unsigned int irq, struct device_node *dp) { if (irq == PCI_IRQ_NONE) return 0; - if (!prom_node_has_property(prom_node, "button")) + if (!of_find_property(dp, "button", NULL)) return 0; return 1; } -static int __init power_probe_ebus(struct resource **resp, unsigned int *irq_p, int *prom_node_p) +static int __init power_probe_ebus(struct resource **resp, unsigned int *irq_p, struct device_node **prom_node_p) { struct linux_ebus *ebus; struct linux_ebus_device *edev; for_each_ebus(ebus) { for_each_ebusdev(edev, ebus) { - if (!strcmp(edev->prom_name, "power")) { + if (!strcmp(edev->prom_node->name, "power")) { *resp = &edev->resource[0]; *irq_p = edev->irqs[0]; *prom_node_p = edev->prom_node; @@ -133,14 +133,14 @@ static int __init power_probe_ebus(struct resource **resp, unsigned int *irq_p, return -ENODEV; } -static int __init power_probe_isa(struct resource **resp, unsigned int *irq_p, int *prom_node_p) +static int __init power_probe_isa(struct resource **resp, unsigned int *irq_p, struct device_node **prom_node_p) { struct sparc_isa_bridge *isa_bus; struct sparc_isa_device *isa_dev; for_each_isa(isa_bus) { for_each_isadev(isa_dev, isa_bus) { - if (!strcmp(isa_dev->prom_name, "power")) { + if (!strcmp(isa_dev->prom_node->name, "power")) { *resp = &isa_dev->resource; *irq_p = isa_dev->irq; *prom_node_p = isa_dev->prom_node; @@ -155,17 +155,17 @@ void __init power_init(void) { struct resource *res = NULL; unsigned int irq; - int prom_node; + struct device_node *dp; static int invoked; if (invoked) return; invoked = 1; - if (!power_probe_ebus(&res, &irq, &prom_node)) + if (!power_probe_ebus(&res, &irq, &dp)) goto found; - if (!power_probe_isa(&res, &irq, &prom_node)) + if (!power_probe_isa(&res, &irq, &dp)) goto found; return; @@ -174,7 +174,7 @@ found: power_reg = ioremap(res->start, 0x4); printk("power: Control reg at %p ... ", power_reg); poweroff_method = machine_halt; /* able to use the standard halt */ - if (has_button_interrupt(irq, prom_node)) { + if (has_button_interrupt(irq, dp)) { if (kernel_thread(powerd, NULL, CLONE_FS) < 0) { printk("Failed to start power daemon.\n"); return; diff --git a/arch/sparc64/kernel/prom.c b/arch/sparc64/kernel/prom.c index fb112c3c048..7809100034b 100644 --- a/arch/sparc64/kernel/prom.c +++ b/arch/sparc64/kernel/prom.c @@ -63,6 +63,7 @@ struct device_node *of_find_node_by_path(const char *path) return np; } +EXPORT_SYMBOL(of_find_node_by_path); struct device_node *of_find_node_by_phandle(phandle handle) { diff --git a/arch/sparc64/kernel/time.c b/arch/sparc64/kernel/time.c index aa5438a4fd5..d072b8632cc 100644 --- a/arch/sparc64/kernel/time.c +++ b/arch/sparc64/kernel/time.c @@ -756,24 +756,200 @@ retry: return -EOPNOTSUPP; } -void __init clock_probe(void) +static int __init clock_model_matches(char *model) +{ + if (strcmp(model, "mk48t02") && + strcmp(model, "mk48t08") && + strcmp(model, "mk48t59") && + strcmp(model, "m5819") && + strcmp(model, "m5819p") && + strcmp(model, "m5823") && + strcmp(model, "ds1287")) + return 0; + + return 1; +} + +static void __init __clock_assign_common(void __iomem *addr, char *model) +{ + if (model[5] == '0' && model[6] == '2') { + mstk48t02_regs = addr; + } else if(model[5] == '0' && model[6] == '8') { + mstk48t08_regs = addr; + mstk48t02_regs = mstk48t08_regs + MOSTEK_48T08_48T02; + } else { + mstk48t59_regs = addr; + mstk48t02_regs = mstk48t59_regs + MOSTEK_48T59_48T02; + } +} + +static void __init clock_assign_clk_reg(struct linux_prom_registers *clk_reg, + char *model) +{ + unsigned long addr; + + addr = ((unsigned long) clk_reg[0].phys_addr | + (((unsigned long) clk_reg[0].which_io) << 32UL)); + + __clock_assign_common((void __iomem *) addr, model); +} + +static int __init clock_probe_central(void) { struct linux_prom_registers clk_reg[2]; - char model[128]; - int node, busnd = -1, err; - unsigned long flags; - struct linux_central *cbus; + char model[64]; + int node; + + if (!central_bus) + return 0; + + /* Get Central FHC's prom node. */ + node = central_bus->child->prom_node; + + /* Then get the first child device below it. */ + node = prom_getchild(node); + + while (node) { + prom_getstring(node, "model", model, sizeof(model)); + if (!clock_model_matches(model)) + goto next_sibling; + + prom_getproperty(node, "reg", (char *)clk_reg, + sizeof(clk_reg)); + + apply_fhc_ranges(central_bus->child, clk_reg, 1); + apply_central_ranges(central_bus, clk_reg, 1); + + clock_assign_clk_reg(clk_reg, model); + return 1; + + next_sibling: + node = prom_getsibling(node); + } + + return 0; +} + #ifdef CONFIG_PCI - struct linux_ebus *ebus = NULL; - struct sparc_isa_bridge *isa_br = NULL; +static void __init clock_isa_ebus_assign_regs(struct resource *res, char *model) +{ + if (!strcmp(model, "ds1287") || + !strcmp(model, "m5819") || + !strcmp(model, "m5819p") || + !strcmp(model, "m5823")) { + ds1287_regs = res->start; + } else { + mstk48t59_regs = (void __iomem *) res->start; + mstk48t02_regs = mstk48t59_regs + MOSTEK_48T59_48T02; + } +} + +static int __init clock_probe_one_ebus_dev(struct linux_ebus_device *edev) +{ + struct device_node *dp = edev->prom_node; + char *model; + + model = of_get_property(dp, "model", NULL); + if (!clock_model_matches(model)) + return 0; + + clock_isa_ebus_assign_regs(&edev->resource[0], model); + + return 1; +} + +static int __init clock_probe_ebus(void) +{ + struct linux_ebus *ebus; + + for_each_ebus(ebus) { + struct linux_ebus_device *edev; + + for_each_ebusdev(edev, ebus) { + if (clock_probe_one_ebus_dev(edev)) + return 1; + } + } + + return 0; +} + +static int __init clock_probe_one_isa_dev(struct sparc_isa_device *idev) +{ + struct device_node *dp = idev->prom_node; + char *model; + + model = of_get_property(dp, "model", NULL); + if (!clock_model_matches(model)) + return 0; + + clock_isa_ebus_assign_regs(&idev->resource, model); + + return 1; +} + +static int __init clock_probe_isa(void) +{ + struct sparc_isa_bridge *isa_br; + + for_each_isa(isa_br) { + struct sparc_isa_device *isa_dev; + + for_each_isadev(isa_dev, isa_br) { + if (clock_probe_one_isa_dev(isa_dev)) + return 1; + } + } + + return 0; +} +#endif /* CONFIG_PCI */ + +#ifdef CONFIG_SBUS +static int __init clock_probe_one_sbus_dev(struct sbus_bus *sbus, struct sbus_dev *sdev) +{ + struct resource *res; + char model[64]; + void __iomem *addr; + + prom_getstring(sdev->prom_node, "model", model, sizeof(model)); + if (!clock_model_matches(model)) + return 0; + + res = &sdev->resource[0]; + addr = sbus_ioremap(res, 0, 0x800UL, "eeprom"); + + __clock_assign_common(addr, model); + + return 1; +} + +static int __init clock_probe_sbus(void) +{ + struct sbus_bus *sbus; + + for_each_sbus(sbus) { + struct sbus_dev *sdev; + + for_each_sbusdev(sdev, sbus) { + if (clock_probe_one_sbus_dev(sbus, sdev)) + return 1; + } + } + + return 0; +} #endif + +void __init clock_probe(void) +{ static int invoked; + unsigned long flags; if (invoked) return; invoked = 1; - if (this_is_starfire) { xtime.tv_sec = starfire_get_time(); xtime.tv_nsec = (INITIAL_JIFFIES % HZ) * (NSEC_PER_SEC / HZ); @@ -789,183 +965,27 @@ void __init clock_probe(void) return; } - local_irq_save(flags); - - cbus = central_bus; - if (cbus != NULL) - busnd = central_bus->child->prom_node; - /* Check FHC Central then EBUSs then ISA bridges then SBUSs. * That way we handle the presence of multiple properly. * * As a special case, machines with Central must provide the * timer chip there. */ + if (!clock_probe_central() && #ifdef CONFIG_PCI - if (ebus_chain != NULL) { - ebus = ebus_chain; - if (busnd == -1) - busnd = ebus->prom_node; - } - if (isa_chain != NULL) { - isa_br = isa_chain; - if (busnd == -1) - busnd = isa_br->prom_node; - } -#endif - if (sbus_root != NULL && busnd == -1) - busnd = sbus_root->prom_node; - - if (busnd == -1) { - prom_printf("clock_probe: problem, cannot find bus to search.\n"); - prom_halt(); - } - - node = prom_getchild(busnd); - - while (1) { - if (!node) - model[0] = 0; - else - prom_getstring(node, "model", model, sizeof(model)); - if (strcmp(model, "mk48t02") && - strcmp(model, "mk48t08") && - strcmp(model, "mk48t59") && - strcmp(model, "m5819") && - strcmp(model, "m5819p") && - strcmp(model, "m5823") && - strcmp(model, "ds1287")) { - if (cbus != NULL) { - prom_printf("clock_probe: Central bus lacks timer chip.\n"); - prom_halt(); - } - - if (node != 0) - node = prom_getsibling(node); -#ifdef CONFIG_PCI - while ((node == 0) && ebus != NULL) { - ebus = ebus->next; - if (ebus != NULL) { - busnd = ebus->prom_node; - node = prom_getchild(busnd); - } - } - while ((node == 0) && isa_br != NULL) { - isa_br = isa_br->next; - if (isa_br != NULL) { - busnd = isa_br->prom_node; - node = prom_getchild(busnd); - } - } + !clock_probe_ebus() && + !clock_probe_isa() && #endif - if (node == 0) { - prom_printf("clock_probe: Cannot find timer chip\n"); - prom_halt(); - } - continue; - } - - err = prom_getproperty(node, "reg", (char *)clk_reg, - sizeof(clk_reg)); - if(err == -1) { - prom_printf("clock_probe: Cannot get Mostek reg property\n"); - prom_halt(); - } - - if (cbus != NULL) { - apply_fhc_ranges(central_bus->child, clk_reg, 1); - apply_central_ranges(central_bus, clk_reg, 1); - } -#ifdef CONFIG_PCI - else if (ebus != NULL) { - struct linux_ebus_device *edev; - - for_each_ebusdev(edev, ebus) - if (edev->prom_node == node) - break; - if (edev == NULL) { - if (isa_chain != NULL) - goto try_isa_clock; - prom_printf("%s: Mostek not probed by EBUS\n", - __FUNCTION__); - prom_halt(); - } - - if (!strcmp(model, "ds1287") || - !strcmp(model, "m5819") || - !strcmp(model, "m5819p") || - !strcmp(model, "m5823")) { - ds1287_regs = edev->resource[0].start; - } else { - mstk48t59_regs = (void __iomem *) - edev->resource[0].start; - mstk48t02_regs = mstk48t59_regs + MOSTEK_48T59_48T02; - } - break; - } - else if (isa_br != NULL) { - struct sparc_isa_device *isadev; - -try_isa_clock: - for_each_isadev(isadev, isa_br) - if (isadev->prom_node == node) - break; - if (isadev == NULL) { - prom_printf("%s: Mostek not probed by ISA\n"); - prom_halt(); - } - if (!strcmp(model, "ds1287") || - !strcmp(model, "m5819") || - !strcmp(model, "m5819p") || - !strcmp(model, "m5823")) { - ds1287_regs = isadev->resource.start; - } else { - mstk48t59_regs = (void __iomem *) - isadev->resource.start; - mstk48t02_regs = mstk48t59_regs + MOSTEK_48T59_48T02; - } - break; - } +#ifdef CONFIG_SBUS + !clock_probe_sbus() #endif - else { - if (sbus_root->num_sbus_ranges) { - int nranges = sbus_root->num_sbus_ranges; - int rngc; - - for (rngc = 0; rngc < nranges; rngc++) - if (clk_reg[0].which_io == - sbus_root->sbus_ranges[rngc].ot_child_space) - break; - if (rngc == nranges) { - prom_printf("clock_probe: Cannot find ranges for " - "clock regs.\n"); - prom_halt(); - } - clk_reg[0].which_io = - sbus_root->sbus_ranges[rngc].ot_parent_space; - clk_reg[0].phys_addr += - sbus_root->sbus_ranges[rngc].ot_parent_base; - } - } - - if(model[5] == '0' && model[6] == '2') { - mstk48t02_regs = (void __iomem *) - (((u64)clk_reg[0].phys_addr) | - (((u64)clk_reg[0].which_io)<<32UL)); - } else if(model[5] == '0' && model[6] == '8') { - mstk48t08_regs = (void __iomem *) - (((u64)clk_reg[0].phys_addr) | - (((u64)clk_reg[0].which_io)<<32UL)); - mstk48t02_regs = mstk48t08_regs + MOSTEK_48T08_48T02; - } else { - mstk48t59_regs = (void __iomem *) - (((u64)clk_reg[0].phys_addr) | - (((u64)clk_reg[0].which_io)<<32UL)); - mstk48t02_regs = mstk48t59_regs + MOSTEK_48T59_48T02; - } - break; + ) { + printk(KERN_WARNING "No clock chip found.\n"); + return; } + local_irq_save(flags); + if (mstk48t02_regs != NULL) { /* Report a low battery voltage condition. */ if (has_low_battery()) diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c index f6686fcce80..0897b0c8d52 100644 --- a/drivers/char/rtc.c +++ b/drivers/char/rtc.c @@ -928,7 +928,7 @@ static int __init rtc_init(void) #ifdef __sparc__ for_each_ebus(ebus) { for_each_ebusdev(edev, ebus) { - if(strcmp(edev->prom_name, "rtc") == 0) { + if(strcmp(edev->prom_node->name, "rtc") == 0) { rtc_port = edev->resource[0].start; rtc_irq = edev->irqs[0]; goto found; @@ -938,7 +938,7 @@ static int __init rtc_init(void) #ifdef __sparc_v9__ for_each_isa(isa_br) { for_each_isadev(isa_dev, isa_br) { - if (strcmp(isa_dev->prom_name, "rtc") == 0) { + if (strcmp(isa_dev->prom_node->name, "rtc") == 0) { rtc_port = isa_dev->resource.start; rtc_irq = isa_dev->irq; goto found; diff --git a/drivers/input/misc/sparcspkr.c b/drivers/input/misc/sparcspkr.c index f0fd2c4740f..ed95dc9420d 100644 --- a/drivers/input/misc/sparcspkr.c +++ b/drivers/input/misc/sparcspkr.c @@ -199,7 +199,7 @@ static int __init sparcspkr_init(void) for_each_ebus(ebus) { for_each_ebusdev(edev, ebus) { - if (!strcmp(edev->prom_name, "beep")) { + if (!strcmp(edev->prom_node->name, "beep")) { beep_name = "Sparc EBUS Speaker"; beep_event = ebus_spkr_event; beep_iobase = edev->resource[0].start; @@ -213,7 +213,7 @@ static int __init sparcspkr_init(void) /* A hack, the beep device's base lives in * the DMA isa node. */ - if (!strcmp(isa_dev->prom_name, "dma")) { + if (!strcmp(isa_dev->prom_node->name, "dma")) { beep_name = "Sparc ISA Speaker"; beep_event = isa_spkr_event, beep_iobase = isa_dev->resource.start; diff --git a/drivers/input/serio/i8042-sparcio.h b/drivers/input/serio/i8042-sparcio.h index ed9446f6d7e..6d66351805a 100644 --- a/drivers/input/serio/i8042-sparcio.h +++ b/drivers/input/serio/i8042-sparcio.h @@ -74,7 +74,7 @@ static int __init i8042_platform_init(void) for_each_ebus(ebus) { for_each_ebusdev(edev, ebus) { - if (!strcmp(edev->prom_name, "8042")) + if (!strcmp(edev->prom_node->name, "8042")) goto edev_found; } } @@ -82,14 +82,14 @@ static int __init i8042_platform_init(void) edev_found: for_each_edevchild(edev, child) { - if (!strcmp(child->prom_name, OBP_PS2KBD_NAME1) || - !strcmp(child->prom_name, OBP_PS2KBD_NAME2)) { + if (!strcmp(child->prom_node->name, OBP_PS2KBD_NAME1) || + !strcmp(child->prom_node->name, OBP_PS2KBD_NAME2)) { i8042_kbd_irq = child->irqs[0]; kbd_iobase = ioremap(child->resource[0].start, 8); } - if (!strcmp(child->prom_name, OBP_PS2MS_NAME1) || - !strcmp(child->prom_name, OBP_PS2MS_NAME2)) + if (!strcmp(child->prom_node->name, OBP_PS2MS_NAME1) || + !strcmp(child->prom_node->name, OBP_PS2MS_NAME2)) i8042_aux_irq = child->irqs[0]; } if (i8042_kbd_irq == -1 || diff --git a/drivers/sbus/char/bbc_envctrl.c b/drivers/sbus/char/bbc_envctrl.c index d89f83f769f..1cc706e1111 100644 --- a/drivers/sbus/char/bbc_envctrl.c +++ b/drivers/sbus/char/bbc_envctrl.c @@ -575,9 +575,9 @@ int bbc_envctrl_init(void) int devidx = 0; while ((echild = bbc_i2c_getdev(devidx++)) != NULL) { - if (!strcmp(echild->prom_name, "temperature")) + if (!strcmp(echild->prom_node->name, "temperature")) attach_one_temp(echild, temp_index++); - if (!strcmp(echild->prom_name, "fan-control")) + if (!strcmp(echild->prom_node->name, "fan-control")) attach_one_fan(echild, fan_index++); } if (temp_index != 0 && fan_index != 0) { diff --git a/drivers/sbus/char/bbc_i2c.c b/drivers/sbus/char/bbc_i2c.c index 3e156e005f2..73634371393 100644 --- a/drivers/sbus/char/bbc_i2c.c +++ b/drivers/sbus/char/bbc_i2c.c @@ -423,7 +423,7 @@ static int __init bbc_present(void) for_each_ebus(ebus) { for_each_ebusdev(edev, ebus) { - if (!strcmp(edev->prom_name, "bbc")) + if (!strcmp(edev->prom_node->name, "bbc")) return 1; } } @@ -446,7 +446,7 @@ static int __init bbc_i2c_init(void) for_each_ebus(ebus) { for_each_ebusdev(edev, ebus) { - if (!strcmp(edev->prom_name, "i2c")) { + if (!strcmp(edev->prom_node->name, "i2c")) { if (!attach_one_i2c(edev, index)) index++; } diff --git a/drivers/sbus/char/display7seg.c b/drivers/sbus/char/display7seg.c index c3a51d1fae5..d92bc8827a9 100644 --- a/drivers/sbus/char/display7seg.c +++ b/drivers/sbus/char/display7seg.c @@ -184,7 +184,7 @@ static int __init d7s_init(void) for_each_ebus(ebus) { for_each_ebusdev(edev, ebus) { - if (!strcmp(edev->prom_name, D7S_OBPNAME)) + if (!strcmp(edev->prom_node->name, D7S_OBPNAME)) goto ebus_done; } } diff --git a/drivers/sbus/char/envctrl.c b/drivers/sbus/char/envctrl.c index 19e8eddf887..cf97e9efe9b 100644 --- a/drivers/sbus/char/envctrl.c +++ b/drivers/sbus/char/envctrl.c @@ -768,16 +768,14 @@ static void envctrl_set_mon(struct i2c_child_t *pchild, * decoding tables, monitor type, optional properties. * Return: None. */ -static void envctrl_init_adc(struct i2c_child_t *pchild, int node) +static void envctrl_init_adc(struct i2c_child_t *pchild, struct device_node *dp) { - char chnls_desc[CHANNEL_DESC_SZ]; int i = 0, len; - char *pos = chnls_desc; + char *pos; + unsigned int *pval; /* Firmware describe channels into a stream separated by a '\0'. */ - len = prom_getproperty(node, "channels-description", chnls_desc, - CHANNEL_DESC_SZ); - chnls_desc[CHANNEL_DESC_SZ - 1] = '\0'; + pos = of_get_property(dp, "channels-description", &len); while (len > 0) { int l = strlen(pos) + 1; @@ -787,10 +785,13 @@ static void envctrl_init_adc(struct i2c_child_t *pchild, int node) } /* Get optional properties. */ - len = prom_getproperty(node, "warning-temp", (char *)&warning_temperature, - sizeof(warning_temperature)); - len = prom_getproperty(node, "shutdown-temp", (char *)&shutdown_temperature, - sizeof(shutdown_temperature)); + pval = of_get_property(dp, "warning-temp", NULL); + if (pval) + warning_temperature = *pval; + + pval = of_get_property(dp, "shutdown-temp", NULL); + if (pval) + shutdown_temperature = *pval; } /* Function Description: Initialize child device monitoring fan status. @@ -864,21 +865,18 @@ static void envctrl_init_voltage_status(struct i2c_child_t *pchild) static void envctrl_init_i2c_child(struct linux_ebus_child *edev_child, struct i2c_child_t *pchild) { - int node, len, i, tbls_size = 0; - - node = edev_child->prom_node; + int len, i, tbls_size = 0; + struct device_node *dp = edev_child->prom_node; + void *pval; /* Get device address. */ - len = prom_getproperty(node, "reg", - (char *) &(pchild->addr), - sizeof(pchild->addr)); + pval = of_get_property(dp, "reg", &len); + memcpy(&pchild->addr, pval, len); /* Get tables property. Read firmware temperature tables. */ - len = prom_getproperty(node, "translation", - (char *) pchild->tblprop_array, - (PCF8584_MAX_CHANNELS * - sizeof(struct pcf8584_tblprop))); - if (len > 0) { + pval = of_get_property(dp, "translation", &len); + if (pval && len > 0) { + memcpy(pchild->tblprop_array, pval, len); pchild->total_tbls = len / sizeof(struct pcf8584_tblprop); for (i = 0; i < pchild->total_tbls; i++) { if ((pchild->tblprop_array[i].size + pchild->tblprop_array[i].offset) > tbls_size) { @@ -891,12 +889,12 @@ static void envctrl_init_i2c_child(struct linux_ebus_child *edev_child, printk("envctrl: Failed to allocate table.\n"); return; } - len = prom_getproperty(node, "tables", - (char *) pchild->tables, tbls_size); - if (len <= 0) { + pval = of_get_property(dp, "tables", &len); + if (!pval || len <= 0) { printk("envctrl: Failed to get table.\n"); return; } + memcpy(pchild->tables, pval, len); } /* SPARCengine ASM Reference Manual (ref. SMI doc 805-7581-04) @@ -907,12 +905,11 @@ static void envctrl_init_i2c_child(struct linux_ebus_child *edev_child, * 'NULL' monitor type. */ if (ENVCTRL_CPCI_IGNORED_NODE == pchild->addr) { + struct device_node *root_node; int len; - char prop[56]; - len = prom_getproperty(prom_root_node, "name", prop, sizeof(prop)); - if (0 < len && (0 == strncmp(prop, "SUNW,UltraSPARC-IIi-cEngine", len))) - { + root_node = of_find_node_by_path("/"); + if (!strcmp(root_node->name, "SUNW,UltraSPARC-IIi-cEngine")) { for (len = 0; len < PCF8584_MAX_CHANNELS; ++len) { pchild->mon_type[len] = ENVCTRL_NOMON; } @@ -921,16 +918,14 @@ static void envctrl_init_i2c_child(struct linux_ebus_child *edev_child, } /* Get the monitor channels. */ - len = prom_getproperty(node, "channels-in-use", - (char *) pchild->chnl_array, - (PCF8584_MAX_CHANNELS * - sizeof(struct pcf8584_channel))); + pval = of_get_property(dp, "channels-in-use", &len); + memcpy(pchild->chnl_array, pval, len); pchild->total_chnls = len / sizeof(struct pcf8584_channel); for (i = 0; i < pchild->total_chnls; i++) { switch (pchild->chnl_array[i].type) { case PCF8584_TEMP_TYPE: - envctrl_init_adc(pchild, node); + envctrl_init_adc(pchild, dp); break; case PCF8584_GLOBALADDR_TYPE: @@ -945,7 +940,7 @@ static void envctrl_init_i2c_child(struct linux_ebus_child *edev_child, case PCF8584_VOLTAGE_TYPE: if (pchild->i2ctype == I2C_ADC) { - envctrl_init_adc(pchild,node); + envctrl_init_adc(pchild,dp); } else { envctrl_init_voltage_status(pchild); } @@ -1046,7 +1041,7 @@ static int __init envctrl_init(void) for_each_ebus(ebus) { for_each_ebusdev(edev, ebus) { - if (!strcmp(edev->prom_name, "bbc")) { + if (!strcmp(edev->prom_node->name, "bbc")) { /* If we find a boot-bus controller node, * then this envctrl driver is not for us. */ @@ -1060,14 +1055,14 @@ static int __init envctrl_init(void) */ for_each_ebus(ebus) { for_each_ebusdev(edev, ebus) { - if (!strcmp(edev->prom_name, "i2c")) { + if (!strcmp(edev->prom_node->name, "i2c")) { i2c = ioremap(edev->resource[0].start, 0x2); for_each_edevchild(edev, edev_child) { - if (!strcmp("gpio", edev_child->prom_name)) { + if (!strcmp("gpio", edev_child->prom_node->name)) { i2c_childlist[i].i2ctype = I2C_GPIO; envctrl_init_i2c_child(edev_child, &(i2c_childlist[i++])); } - if (!strcmp("adc", edev_child->prom_name)) { + if (!strcmp("adc", edev_child->prom_node->name)) { i2c_childlist[i].i2ctype = I2C_ADC; envctrl_init_i2c_child(edev_child, &(i2c_childlist[i++])); } diff --git a/drivers/sbus/char/flash.c b/drivers/sbus/char/flash.c index 2beb3dded08..5ae684c011f 100644 --- a/drivers/sbus/char/flash.c +++ b/drivers/sbus/char/flash.c @@ -192,9 +192,11 @@ static int __init flash_init(void) } if (!sdev) { #ifdef CONFIG_PCI + struct linux_prom_registers *ebus_regs; + for_each_ebus(ebus) { for_each_ebusdev(edev, ebus) { - if (!strcmp(edev->prom_name, "flashprom")) + if (!strcmp(edev->prom_node->name, "flashprom")) goto ebus_done; } } @@ -202,23 +204,23 @@ static int __init flash_init(void) if (!edev) return -ENODEV; - len = prom_getproperty(edev->prom_node, "reg", (void *)regs, sizeof(regs)); - if ((len % sizeof(regs[0])) != 0) { + ebus_regs = of_get_property(edev->prom_node, "reg", &len); + if (!ebus_regs || (len % sizeof(regs[0])) != 0) { printk("flash: Strange reg property size %d\n", len); return -ENODEV; } - nregs = len / sizeof(regs[0]); + nregs = len / sizeof(ebus_regs[0]); flash.read_base = edev->resource[0].start; - flash.read_size = regs[0].reg_size; + flash.read_size = ebus_regs[0].reg_size; if (nregs == 1) { flash.write_base = edev->resource[0].start; - flash.write_size = regs[0].reg_size; + flash.write_size = ebus_regs[0].reg_size; } else if (nregs == 2) { flash.write_base = edev->resource[1].start; - flash.write_size = regs[1].reg_size; + flash.write_size = ebus_regs[1].reg_size; } else { printk("flash: Strange number of regs %d\n", nregs); return -ENODEV; diff --git a/drivers/serial/sunsab.c b/drivers/serial/sunsab.c index bfbe9dc90cc..e4c0fd2d6a9 100644 --- a/drivers/serial/sunsab.c +++ b/drivers/serial/sunsab.c @@ -984,19 +984,19 @@ static void __init for_each_sab_edev(void (*callback)(struct linux_ebus_device * for_each_ebus(ebus) { for_each_ebusdev(edev, ebus) { - if (!strcmp(edev->prom_name, "se")) { + if (!strcmp(edev->prom_node->name, "se")) { callback(edev, arg); continue; - } else if (!strcmp(edev->prom_name, "serial")) { - char compat[32]; + } else if (!strcmp(edev->prom_node->name, "serial")) { + char *compat; int clen; /* On RIO this can be an SE, check it. We could * just check ebus->is_rio, but this is more portable. */ - clen = prom_getproperty(edev->prom_node, "compatible", - compat, sizeof(compat)); - if (clen > 0) { + compat = of_get_property(edev->prom_node, + "compatible", &clen); + if (compat && clen > 0) { if (strncmp(compat, "sab82532", 8) == 0) { callback(edev, arg); continue; diff --git a/drivers/serial/sunsu.c b/drivers/serial/sunsu.c index 4cdb610cdd3..0268b307c01 100644 --- a/drivers/serial/sunsu.c +++ b/drivers/serial/sunsu.c @@ -1053,7 +1053,7 @@ static void sunsu_autoconfig(struct uart_sunsu_port *up) */ for_each_ebus(ebus) { for_each_ebusdev(dev, ebus) { - if (dev->prom_node == up->port_node) { + if (dev->prom_node->node == up->port_node) { /* * The EBus is broken on sparc; it delivers * virtual addresses in resources. Oh well... @@ -1073,7 +1073,7 @@ static void sunsu_autoconfig(struct uart_sunsu_port *up) #ifdef CONFIG_SPARC64 for_each_isa(isa_br) { for_each_isadev(isa_dev, isa_br) { - if (isa_dev->prom_node == up->port_node) { + if (isa_dev->prom_node->node == up->port_node) { /* Same on sparc64. Cool architecure... */ up->port.membase = (char *) isa_dev->resource.start; up->port.mapbase = isa_dev->resource.start; diff --git a/include/asm-sparc64/ebus.h b/include/asm-sparc64/ebus.h index 7a408a030f5..876912f4d83 100644 --- a/include/asm-sparc64/ebus.h +++ b/include/asm-sparc64/ebus.h @@ -10,13 +10,13 @@ #include #include +#include struct linux_ebus_child { struct linux_ebus_child *next; struct linux_ebus_device *parent; struct linux_ebus *bus; - int prom_node; - char prom_name[64]; + struct device_node *prom_node; struct resource resource[PROMREG_MAX]; int num_addrs; unsigned int irqs[PROMINTR_MAX]; @@ -27,8 +27,7 @@ struct linux_ebus_device { struct linux_ebus_device *next; struct linux_ebus_child *children; struct linux_ebus *bus; - int prom_node; - char prom_name[64]; + struct device_node *prom_node; struct resource resource[PROMREG_MAX]; int num_addrs; unsigned int irqs[PROMINTR_MAX]; @@ -42,8 +41,7 @@ struct linux_ebus { struct pci_dev *self; int index; int is_rio; - int prom_node; - char prom_name[64]; + struct device_node *prom_node; struct linux_prom_ebus_ranges ebus_ranges[PROMREG_MAX]; int num_ebus_ranges; struct linux_prom_ebus_intmap ebus_intmap[PROMREG_MAX]; diff --git a/include/asm-sparc64/floppy.h b/include/asm-sparc64/floppy.h index 07ccd6f04b5..f8d57bb5570 100644 --- a/include/asm-sparc64/floppy.h +++ b/include/asm-sparc64/floppy.h @@ -498,15 +498,14 @@ static int sun_pci_fd_test_drive(unsigned long port, int drive) #ifdef CONFIG_PCI static int __init ebus_fdthree_p(struct linux_ebus_device *edev) { - if (!strcmp(edev->prom_name, "fdthree")) + if (!strcmp(edev->prom_node->name, "fdthree")) return 1; - if (!strcmp(edev->prom_name, "floppy")) { - char compat[16]; - prom_getstring(edev->prom_node, - "compatible", - compat, sizeof(compat)); - compat[15] = '\0'; - if (!strcmp(compat, "fdthree")) + if (!strcmp(edev->prom_node->name, "floppy")) { + char *compat; + + compat = of_get_property(edev->prom_node, + "compatible", NULL); + if (compat && !strcmp(compat, "fdthree")) return 1; } return 0; @@ -524,12 +523,12 @@ static unsigned long __init isa_floppy_init(void) for_each_isa(isa_br) { for_each_isadev(isa_dev, isa_br) { - if (!strcmp(isa_dev->prom_name, "dma")) { + if (!strcmp(isa_dev->prom_node->name, "dma")) { struct sparc_isa_device *child = isa_dev->child; while (child) { - if (!strcmp(child->prom_name, + if (!strcmp(child->prom_node->name, "floppy")) { isa_dev = child; goto isa_done; @@ -614,6 +613,7 @@ static unsigned long __init sun_floppy_init(void) struct linux_ebus_device *edev = NULL; unsigned long config = 0; void __iomem *auxio_reg; + char *state_prop; for_each_ebus(ebus) { for_each_ebusdev(edev, ebus) { @@ -630,9 +630,8 @@ static unsigned long __init sun_floppy_init(void) #endif } - prom_getproperty(edev->prom_node, "status", - state, sizeof(state)); - if (!strncmp(state, "disabled", 8)) + state_prop = of_get_property(edev->prom_node, "status", NULL); + if (state_prop && !strncmp(state_prop, "disabled", 8)) return 0; FLOPPY_IRQ = edev->irqs[0]; @@ -703,7 +702,7 @@ static unsigned long __init sun_floppy_init(void) */ for_each_ebus(ebus) { for_each_ebusdev(edev, ebus) { - if (!strcmp(edev->prom_name, "ecpp")) { + if (!strcmp(edev->prom_node->name, "ecpp")) { config = edev->resource[1].start; goto config_done; } diff --git a/include/asm-sparc64/isa.h b/include/asm-sparc64/isa.h index 4601bbfc3e7..e110435b14e 100644 --- a/include/asm-sparc64/isa.h +++ b/include/asm-sparc64/isa.h @@ -9,6 +9,7 @@ #include #include +#include struct sparc_isa_bridge; @@ -16,9 +17,7 @@ struct sparc_isa_device { struct sparc_isa_device *next; struct sparc_isa_device *child; struct sparc_isa_bridge *bus; - int prom_node; - char prom_name[64]; - char compatible[64]; + struct device_node *prom_node; struct resource resource; unsigned int irq; }; @@ -29,8 +28,7 @@ struct sparc_isa_bridge { struct pci_pbm_info *parent; struct pci_dev *self; int index; - int prom_node; - char prom_name[64]; + struct device_node *prom_node; #define linux_prom_isa_ranges linux_prom_ebus_ranges struct linux_prom_isa_ranges isa_ranges[PROMREG_MAX]; int num_isa_ranges; diff --git a/include/asm-sparc64/parport.h b/include/asm-sparc64/parport.h index 56b5197d789..d3895873e4c 100644 --- a/include/asm-sparc64/parport.h +++ b/include/asm-sparc64/parport.h @@ -67,18 +67,17 @@ static __inline__ unsigned int get_dma_residue(unsigned int dmanr) static int ebus_ecpp_p(struct linux_ebus_device *edev) { - if (!strcmp(edev->prom_name, "ecpp")) + if (!strcmp(edev->prom_node->name, "ecpp")) return 1; - if (!strcmp(edev->prom_name, "parallel")) { - char compat[19]; - prom_getstring(edev->prom_node, - "compatible", - compat, sizeof(compat)); - compat[18] = '\0'; - if (!strcmp(compat, "ecpp")) - return 1; - if (!strcmp(compat, "ns87317-ecpp") && - !strcmp(compat + 13, "ecpp")) + if (!strcmp(edev->prom_node->name, "parallel")) { + char *compat; + + compat = of_get_property(edev->prom_node, + "compatible", NULL); + if (compat && + (!strcmp(compat, "ecpp") || + !strcmp(compat, "ns87317-ecpp") || + !strcmp(compat + 13, "ecpp"))) return 1; } return 0; @@ -94,12 +93,12 @@ static int parport_isa_probe(int count) struct sparc_isa_device *child; unsigned long base; - if (strcmp(isa_dev->prom_name, "dma")) + if (strcmp(isa_dev->prom_node->name, "dma")) continue; child = isa_dev->child; while (child) { - if (!strcmp(child->prom_name, "parallel")) + if (!strcmp(child->prom_node->name, "parallel")) break; child = child->next; } diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c index b3efc9aa291..da54d04a3e3 100644 --- a/sound/sparc/cs4231.c +++ b/sound/sparc/cs4231.c @@ -2284,15 +2284,14 @@ static int __init cs4231_init(void) for_each_ebusdev(edev, ebus) { int match = 0; - if (!strcmp(edev->prom_name, "SUNW,CS4231")) { + if (!strcmp(edev->prom_node->name, "SUNW,CS4231")) { match = 1; - } else if (!strcmp(edev->prom_name, "audio")) { - char compat[16]; + } else if (!strcmp(edev->prom_node->name, "audio")) { + char *compat; - prom_getstring(edev->prom_node, "compatible", - compat, sizeof(compat)); - compat[15] = '\0'; - if (!strcmp(compat, "SUNW,CS4231")) + compat = of_get_property(edev->prom_node, + "compatible", NULL); + if (compat && !strcmp(compat, "SUNW,CS4231")) match = 1; } -- cgit v1.2.3-70-g09d2 From f2a2279ffc0dfd27f6909184a29910e40ae7eebd Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sat, 24 Jun 2006 16:55:34 +1000 Subject: drm: radeon add a tcl state flush before accessing tcl vector space Do a tcl state flush before accessing tcl vector space. This fixes some more problems with flickering (bug #6637). drm may not be appropriate place for this, since doing that flush there might both be overkill and insufficient in some cases. However, it's hard to figure out when that flush is needed, so this has to suffice. There does not seem to be a performance penalty associated with it. From: Roland Scheidegger (DRM CVS) Signed-off-by: Dave Airlie --- drivers/char/drm/radeon_drv.h | 4 +++- drivers/char/drm/radeon_state.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/drm/radeon_drv.h b/drivers/char/drm/radeon_drv.h index 78345cee8f8..b2a6f92d1f0 100644 --- a/drivers/char/drm/radeon_drv.h +++ b/drivers/char/drm/radeon_drv.h @@ -38,7 +38,7 @@ #define DRIVER_NAME "radeon" #define DRIVER_DESC "ATI Radeon" -#define DRIVER_DATE "20060225" +#define DRIVER_DATE "20060519" /* Interface history: * @@ -884,6 +884,8 @@ extern int r300_do_cp_cmdbuf(drm_device_t * dev, DRMFILE filp, #define RADEON_PP_CUBIC_OFFSET_T1_0 0x1e00 #define RADEON_PP_CUBIC_OFFSET_T2_0 0x1e14 +#define RADEON_SE_TCL_STATE_FLUSH 0x2284 + #define SE_VAP_CNTL__TCL_ENA_MASK 0x00000001 #define SE_VAP_CNTL__FORCE_W_TO_ONE_MASK 0x00010000 #define SE_VAP_CNTL__VF_MAX_VTX_NUM__SHIFT 0x00000012 diff --git a/drivers/char/drm/radeon_state.c b/drivers/char/drm/radeon_state.c index c5b8f774a59..4ca6bd13d58 100644 --- a/drivers/char/drm/radeon_state.c +++ b/drivers/char/drm/radeon_state.c @@ -2595,7 +2595,8 @@ static __inline__ int radeon_emit_vectors(drm_radeon_private_t *dev_priv, int stride = header.vectors.stride; RING_LOCALS; - BEGIN_RING(3 + sz); + BEGIN_RING(5 + sz); + OUT_RING_REG(RADEON_SE_TCL_STATE_FLUSH, 0); OUT_RING(CP_PACKET0(RADEON_SE_TCL_VECTOR_INDX_REG, 0)); OUT_RING(start | (stride << RADEON_VEC_INDX_OCTWORD_STRIDE_SHIFT)); OUT_RING(CP_PACKET0_TABLE(RADEON_SE_TCL_VECTOR_DATA_REG, (sz - 1))); -- cgit v1.2.3-70-g09d2 From d6fece051a4ef330922bfafb9d64e3e133e3a8a6 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sat, 24 Jun 2006 17:04:07 +1000 Subject: drm: update radeon to 1.25 add r200 vertex program support Add support for r200 vertex programs (R200_EMIT_VAP_PVS_CNTL, and new packet type for making it possible to address whole tcl vector space and have a larger count) From: Roland Scheidegger (DRM CVS) Signed-off-by: Dave Airlie --- drivers/char/drm/radeon_drm.h | 7 ++++++- drivers/char/drm/radeon_drv.h | 8 ++++++-- drivers/char/drm/radeon_state.c | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 3 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/drm/radeon_drm.h b/drivers/char/drm/radeon_drm.h index c8e279e89c2..8d6350dd536 100644 --- a/drivers/char/drm/radeon_drm.h +++ b/drivers/char/drm/radeon_drm.h @@ -161,7 +161,8 @@ #define R200_EMIT_PP_TXCTLALL_3 91 #define R200_EMIT_PP_TXCTLALL_4 92 #define R200_EMIT_PP_TXCTLALL_5 93 -#define RADEON_MAX_STATE_PACKETS 94 +#define R200_EMIT_VAP_PVS_CNTL 94 +#define RADEON_MAX_STATE_PACKETS 95 /* Commands understood by cmd_buffer ioctl. More can be added but * obviously these can't be removed or changed: @@ -176,6 +177,7 @@ #define RADEON_CMD_WAIT 8 /* emit hw wait commands -- note: * doesn't make the cpu wait, just * the graphics hardware */ +#define RADEON_CMD_VECLINEAR 9 /* another r200 stopgap */ typedef union { int i; @@ -191,6 +193,9 @@ typedef union { struct { unsigned char cmd_type, offset, stride, count; } vectors; + struct { + unsigned char cmd_type, addr_lo, addr_hi, count; + } veclinear; struct { unsigned char cmd_type, buf_idx, pad0, pad1; } dma; diff --git a/drivers/char/drm/radeon_drv.h b/drivers/char/drm/radeon_drv.h index b2a6f92d1f0..e5a256f5429 100644 --- a/drivers/char/drm/radeon_drv.h +++ b/drivers/char/drm/radeon_drv.h @@ -38,7 +38,7 @@ #define DRIVER_NAME "radeon" #define DRIVER_DESC "ATI Radeon" -#define DRIVER_DATE "20060519" +#define DRIVER_DATE "20060524" /* Interface history: * @@ -93,9 +93,11 @@ * 1.22- Add support for texture cache flushes (R300_TX_CNTL) * 1.23- Add new radeon memory map work from benh * 1.24- Add general-purpose packet for manipulating scratch registers (r300) + * 1.25- Add support for r200 vertex programs (R200_EMIT_VAP_PVS_CNTL, + * new packet type) */ #define DRIVER_MAJOR 1 -#define DRIVER_MINOR 24 +#define DRIVER_MINOR 25 #define DRIVER_PATCHLEVEL 0 /* @@ -907,6 +909,8 @@ extern int r300_do_cp_cmdbuf(drm_device_t * dev, DRMFILE filp, #define R200_PP_AFS_0 0x2f80 #define R200_PP_AFS_1 0x2f00 /* same as txcblend_0 */ +#define R200_VAP_PVS_CNTL_1 0x22D0 + /* Constants */ #define RADEON_MAX_USEC_TIMEOUT 100000 /* 100 ms */ diff --git a/drivers/char/drm/radeon_state.c b/drivers/char/drm/radeon_state.c index 4ca6bd13d58..5bb2234a909 100644 --- a/drivers/char/drm/radeon_state.c +++ b/drivers/char/drm/radeon_state.c @@ -249,6 +249,7 @@ static __inline__ int radeon_check_and_fixup_packets(drm_radeon_private_t * case R200_EMIT_PP_TXCTLALL_3: case R200_EMIT_PP_TXCTLALL_4: case R200_EMIT_PP_TXCTLALL_5: + case R200_EMIT_VAP_PVS_CNTL: /* These packets don't contain memory offsets */ break; @@ -626,6 +627,7 @@ static struct { {R200_PP_TXFILTER_3, 8, "R200_PP_TXCTLALL_3"}, {R200_PP_TXFILTER_4, 8, "R200_PP_TXCTLALL_4"}, {R200_PP_TXFILTER_5, 8, "R200_PP_TXCTLALL_5"}, + {R200_VAP_PVS_CNTL_1, 2, "R200_VAP_PVS_CNTL"}, }; /* ================================================================ @@ -2608,6 +2610,32 @@ static __inline__ int radeon_emit_vectors(drm_radeon_private_t *dev_priv, return 0; } +static __inline__ int radeon_emit_veclinear(drm_radeon_private_t *dev_priv, + drm_radeon_cmd_header_t header, + drm_radeon_kcmd_buffer_t *cmdbuf) +{ + int sz = header.veclinear.count * 4; + int start = header.veclinear.addr_lo | (header.veclinear.addr_hi << 8); + RING_LOCALS; + + if (!sz) + return 0; + if (sz * 4 > cmdbuf->bufsz) + return DRM_ERR(EINVAL); + + BEGIN_RING(5 + sz); + OUT_RING_REG(RADEON_SE_TCL_STATE_FLUSH, 0); + OUT_RING(CP_PACKET0(RADEON_SE_TCL_VECTOR_INDX_REG, 0)); + OUT_RING(start | (1 << RADEON_VEC_INDX_OCTWORD_STRIDE_SHIFT)); + OUT_RING(CP_PACKET0_TABLE(RADEON_SE_TCL_VECTOR_DATA_REG, (sz - 1))); + OUT_RING_TABLE(cmdbuf->buf, sz); + ADVANCE_RING(); + + cmdbuf->buf += sz * sizeof(int); + cmdbuf->bufsz -= sz * sizeof(int); + return 0; +} + static int radeon_emit_packet3(drm_device_t * dev, drm_file_t * filp_priv, drm_radeon_kcmd_buffer_t *cmdbuf) @@ -2866,6 +2894,14 @@ static int radeon_cp_cmdbuf(DRM_IOCTL_ARGS) goto err; } break; + case RADEON_CMD_VECLINEAR: + DRM_DEBUG("RADEON_CMD_VECLINEAR\n"); + if (radeon_emit_veclinear(dev_priv, header, &cmdbuf)) { + DRM_ERROR("radeon_emit_veclinear failed\n"); + goto err; + } + break; + default: DRM_ERROR("bad cmd_type %d at %p\n", header.header.cmd_type, -- cgit v1.2.3-70-g09d2 From 702880f24373dfb31edb0bcd997ff924d07decc3 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sat, 24 Jun 2006 17:07:34 +1000 Subject: Add i915 ioctls to configure pipes for vblank interrupt. i915 vblanks can be generated from either pipe a or b, however a disabled pipe generates no interrupts. This change allows the X server to select which pipe generates vblank interrupts. From: Keith Packard via DRM CVS Signed-off-by: Dave Airlie --- drivers/char/drm/i915_dma.c | 4 ++- drivers/char/drm/i915_drm.h | 13 +++++++++ drivers/char/drm/i915_drv.h | 6 +++- drivers/char/drm/i915_irq.c | 69 +++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 87 insertions(+), 5 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/drm/i915_dma.c b/drivers/char/drm/i915_dma.c index 9f4b8ce4c05..a94233bdbc0 100644 --- a/drivers/char/drm/i915_dma.c +++ b/drivers/char/drm/i915_dma.c @@ -758,7 +758,9 @@ drm_ioctl_desc_t i915_ioctls[] = { [DRM_IOCTL_NR(DRM_I915_FREE)] = {i915_mem_free, DRM_AUTH}, [DRM_IOCTL_NR(DRM_I915_INIT_HEAP)] = {i915_mem_init_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, [DRM_IOCTL_NR(DRM_I915_CMDBUFFER)] = {i915_cmdbuffer, DRM_AUTH}, - [DRM_IOCTL_NR(DRM_I915_DESTROY_HEAP)] = { i915_mem_destroy_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY } + [DRM_IOCTL_NR(DRM_I915_DESTROY_HEAP)] = { i915_mem_destroy_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY }, + [DRM_IOCTL_NR(DRM_I915_SET_VBLANK_PIPE)] = { i915_vblank_pipe_set, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY }, + [DRM_IOCTL_NR(DRM_I915_GET_VBLANK_PIPE)] = { i915_vblank_pipe_get, DRM_AUTH }, }; int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls); diff --git a/drivers/char/drm/i915_drm.h b/drivers/char/drm/i915_drm.h index 4cb3da57833..5aa3e0e3bb4 100644 --- a/drivers/char/drm/i915_drm.h +++ b/drivers/char/drm/i915_drm.h @@ -124,6 +124,8 @@ typedef struct _drm_i915_sarea { #define DRM_I915_INIT_HEAP 0x0a #define DRM_I915_CMDBUFFER 0x0b #define DRM_I915_DESTROY_HEAP 0x0c +#define DRM_I915_SET_VBLANK_PIPE 0x0d +#define DRM_I915_GET_VBLANK_PIPE 0x0e #define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t) #define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH) @@ -138,6 +140,8 @@ typedef struct _drm_i915_sarea { #define DRM_IOCTL_I915_INIT_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT_HEAP, drm_i915_mem_init_heap_t) #define DRM_IOCTL_I915_CMDBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_I915_CMDBUFFER, drm_i915_cmdbuffer_t) #define DRM_IOCTL_I915_DESTROY_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_I915_DESTROY_HEAP, drm_i915_mem_destroy_heap_t) +#define DRM_IOCTL_I915_SET_VBLANK_PIPE DRM_IOW( DRM_COMMAND_BASE + DRM_I915_SET_VBLANK_PIPE, drm_i915_vblank_pipe_t) +#define DRM_IOCTL_I915_GET_VBLANK_PIPE DRM_IOR( DRM_COMMAND_BASE + DRM_I915_GET_VBLANK_PIPE, drm_i915_vblank_pipe_t) /* Allow drivers to submit batchbuffers directly to hardware, relying * on the security mechanisms provided by hardware. @@ -224,4 +228,13 @@ typedef struct drm_i915_mem_destroy_heap { int region; } drm_i915_mem_destroy_heap_t; +/* Allow X server to configure which pipes to monitor for vblank signals + */ +#define DRM_I915_VBLANK_PIPE_A 1 +#define DRM_I915_VBLANK_PIPE_B 2 + +typedef struct drm_i915_vblank_pipe { + int pipe; +} drm_i915_vblank_pipe_t; + #endif /* _I915_DRM_H_ */ diff --git a/drivers/char/drm/i915_drv.h b/drivers/char/drm/i915_drv.h index 7a65666899e..2d565031c00 100644 --- a/drivers/char/drm/i915_drv.h +++ b/drivers/char/drm/i915_drv.h @@ -45,9 +45,10 @@ * 1.2: Add Power Management * 1.3: Add vblank support * 1.4: Fix cmdbuffer path, add heap destroy + * 1.5: Add vblank pipe configuration */ #define DRIVER_MAJOR 1 -#define DRIVER_MINOR 4 +#define DRIVER_MINOR 5 #define DRIVER_PATCHLEVEL 0 typedef struct _drm_i915_ring_buffer { @@ -96,6 +97,7 @@ typedef struct drm_i915_private { int allow_batchbuffer; struct mem_block *agp_heap; unsigned int sr01, adpa, ppcr, dvob, dvoc, lvds; + int vblank_pipe; } drm_i915_private_t; extern drm_ioctl_desc_t i915_ioctls[]; @@ -119,6 +121,8 @@ extern irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS); extern void i915_driver_irq_preinstall(drm_device_t * dev); extern void i915_driver_irq_postinstall(drm_device_t * dev); extern void i915_driver_irq_uninstall(drm_device_t * dev); +extern int i915_vblank_pipe_set(DRM_IOCTL_ARGS); +extern int i915_vblank_pipe_get(DRM_IOCTL_ARGS); /* i915_mem.c */ extern int i915_mem_alloc(DRM_IOCTL_ARGS); diff --git a/drivers/char/drm/i915_irq.c b/drivers/char/drm/i915_irq.c index a752afd86ab..cd96cfa430d 100644 --- a/drivers/char/drm/i915_irq.c +++ b/drivers/char/drm/i915_irq.c @@ -44,7 +44,8 @@ irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS) u16 temp; temp = I915_READ16(I915REG_INT_IDENTITY_R); - temp &= (USER_INT_FLAG | VSYNC_PIPEA_FLAG); + + temp &= (USER_INT_FLAG | VSYNC_PIPEA_FLAG | VSYNC_PIPEB_FLAG); DRM_DEBUG("%s flag=%08x\n", __FUNCTION__, temp); @@ -58,7 +59,7 @@ irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS) if (temp & USER_INT_FLAG) DRM_WAKEUP(&dev_priv->irq_queue); - if (temp & VSYNC_PIPEA_FLAG) { + if (temp & (VSYNC_PIPEA_FLAG | VSYNC_PIPEB_FLAG)) { atomic_inc(&dev->vbl_received); DRM_WAKEUP(&dev->vbl_queue); drm_vbl_send_signals(dev); @@ -182,6 +183,68 @@ int i915_irq_wait(DRM_IOCTL_ARGS) return i915_wait_irq(dev, irqwait.irq_seq); } +static int i915_enable_interrupt (drm_device_t *dev) +{ + drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; + u16 flag; + + flag = 0; + if (dev_priv->vblank_pipe & DRM_I915_VBLANK_PIPE_A) + flag |= VSYNC_PIPEA_FLAG; + if (dev_priv->vblank_pipe & DRM_I915_VBLANK_PIPE_B) + flag |= VSYNC_PIPEB_FLAG; + if (dev_priv->vblank_pipe & ~(DRM_I915_VBLANK_PIPE_A|DRM_I915_VBLANK_PIPE_B)) { + DRM_ERROR("%s called with invalid pipe 0x%x\n", + __FUNCTION__, dev_priv->vblank_pipe); + return DRM_ERR(EINVAL); + } + I915_WRITE16(I915REG_INT_ENABLE_R, USER_INT_FLAG | flag); + return 0; +} + +/* Set the vblank monitor pipe + */ +int i915_vblank_pipe_set(DRM_IOCTL_ARGS) +{ + DRM_DEVICE; + drm_i915_private_t *dev_priv = dev->dev_private; + drm_i915_vblank_pipe_t pipe; + + if (!dev_priv) { + DRM_ERROR("%s called with no initialization\n", __FUNCTION__); + return DRM_ERR(EINVAL); + } + + DRM_COPY_FROM_USER_IOCTL(pipe, (drm_i915_vblank_pipe_t __user *) data, + sizeof(pipe)); + + dev_priv->vblank_pipe = pipe.pipe; + return i915_enable_interrupt (dev); +} + +int i915_vblank_pipe_get(DRM_IOCTL_ARGS) +{ + DRM_DEVICE; + drm_i915_private_t *dev_priv = dev->dev_private; + drm_i915_vblank_pipe_t pipe; + u16 flag; + + if (!dev_priv) { + DRM_ERROR("%s called with no initialization\n", __FUNCTION__); + return DRM_ERR(EINVAL); + } + + flag = I915_READ(I915REG_INT_ENABLE_R); + pipe.pipe = 0; + if (flag & VSYNC_PIPEA_FLAG) + pipe.pipe |= DRM_I915_VBLANK_PIPE_A; + if (flag & VSYNC_PIPEB_FLAG) + pipe.pipe |= DRM_I915_VBLANK_PIPE_B; + DRM_COPY_TO_USER_IOCTL((drm_i915_vblank_pipe_t __user *) data, pipe, + sizeof(pipe)); + return 0; +} + /* drm_dma.h hooks */ void i915_driver_irq_preinstall(drm_device_t * dev) @@ -197,7 +260,7 @@ void i915_driver_irq_postinstall(drm_device_t * dev) { drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; - I915_WRITE16(I915REG_INT_ENABLE_R, USER_INT_FLAG | VSYNC_PIPEA_FLAG); + i915_enable_interrupt(dev); DRM_INIT_WAITQUEUE(&dev_priv->irq_queue); } -- cgit v1.2.3-70-g09d2 From c499aeb08cb24bed60e5bfc80720597bcf1a720d Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sat, 24 Jun 2006 17:37:48 +1000 Subject: drm: radeon constify radeon microcode From: Tilman (DRM CVS) Signed-off-by: Dave Airlie --- drivers/char/drm/radeon_cp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/drm/radeon_cp.c b/drivers/char/drm/radeon_cp.c index 7f949c9c969..5ad43ba7b5a 100644 --- a/drivers/char/drm/radeon_cp.c +++ b/drivers/char/drm/radeon_cp.c @@ -39,7 +39,7 @@ static int radeon_do_cleanup_cp(drm_device_t * dev); /* CP microcode (from ATI) */ -static u32 R200_cp_microcode[][2] = { +static const u32 R200_cp_microcode[][2] = { {0x21007000, 0000000000}, {0x20007000, 0000000000}, {0x000000ab, 0x00000004}, @@ -298,7 +298,7 @@ static u32 R200_cp_microcode[][2] = { {0000000000, 0000000000}, }; -static u32 radeon_cp_microcode[][2] = { +static const u32 radeon_cp_microcode[][2] = { {0x21007000, 0000000000}, {0x20007000, 0000000000}, {0x000000b4, 0x00000004}, @@ -557,7 +557,7 @@ static u32 radeon_cp_microcode[][2] = { {0000000000, 0000000000}, }; -static u32 R300_cp_microcode[][2] = { +static const u32 R300_cp_microcode[][2] = { {0x4200e000, 0000000000}, {0x4000e000, 0000000000}, {0x000000af, 0x00000008}, -- cgit v1.2.3-70-g09d2 From 68402ddc677005ed1b1359bbc1f279548cfc0928 Mon Sep 17 00:00:00 2001 From: Christoph Lameter Date: Sun, 25 Jun 2006 05:46:47 -0700 Subject: [PATCH] mm: remove VM_LOCKED before remap_pfn_range and drop VM_SHM Remove VM_LOCKED before remap_pfn range from device drivers and get rid of VM_SHM. remap_pfn_range() already sets VM_IO. There is no need to set VM_SHM since it does nothing. VM_LOCKED is of no use since the remap_pfn_range does not place pages on the LRU. The pages are therefore never subject to swap anyways. Remove all the vm_flags settings before calling remap_pfn_range. After removing all the vm_flag settings no use of VM_SHM is left. Drop it. Signed-off-by: Christoph Lameter Acked-by: Hugh Dickins Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/arm/kernel/bios32.c | 1 - arch/cris/arch-v32/drivers/pci/bios.c | 2 -- arch/i386/pci/i386.c | 2 -- arch/ia64/pci/pci.c | 3 --- arch/powerpc/kernel/pci_32.c | 1 - arch/powerpc/kernel/pci_64.c | 1 - arch/powerpc/kernel/proc_ppc64.c | 2 -- arch/ppc/kernel/pci.c | 1 - arch/xtensa/kernel/pci.c | 12 ------------ drivers/char/mmtimer.c | 1 - drivers/sbus/char/flash.c | 1 - drivers/sbus/char/vfc_dev.c | 2 +- drivers/video/igafb.c | 3 --- include/linux/mm.h | 1 - 14 files changed, 1 insertion(+), 32 deletions(-) (limited to 'drivers/char') diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c index de606dfa8db..302fc140154 100644 --- a/arch/arm/kernel/bios32.c +++ b/arch/arm/kernel/bios32.c @@ -702,7 +702,6 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, /* * Mark this as IO */ - vma->vm_flags |= VM_SHM | VM_LOCKED | VM_IO; vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); if (remap_pfn_range(vma, vma->vm_start, phys, diff --git a/arch/cris/arch-v32/drivers/pci/bios.c b/arch/cris/arch-v32/drivers/pci/bios.c index 24bc149889b..1e9d062103a 100644 --- a/arch/cris/arch-v32/drivers/pci/bios.c +++ b/arch/cris/arch-v32/drivers/pci/bios.c @@ -27,8 +27,6 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, /* Leave vm_pgoff as-is, the PCI space address is the physical * address on this platform. */ - vma->vm_flags |= (VM_SHM | VM_LOCKED | VM_IO); - prot = pgprot_val(vma->vm_page_prot); vma->vm_page_prot = __pgprot(prot); diff --git a/arch/i386/pci/i386.c b/arch/i386/pci/i386.c index 7852827a599..a151f7a99f5 100644 --- a/arch/i386/pci/i386.c +++ b/arch/i386/pci/i386.c @@ -285,8 +285,6 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, /* Leave vm_pgoff as-is, the PCI space address is the physical * address on this platform. */ - vma->vm_flags |= (VM_SHM | VM_LOCKED | VM_IO); - prot = pgprot_val(vma->vm_page_prot); if (boot_cpu_data.x86 > 3) prot |= _PAGE_PCD | _PAGE_PWT; diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c index 61dd8608da4..77375a55da3 100644 --- a/arch/ia64/pci/pci.c +++ b/arch/ia64/pci/pci.c @@ -602,8 +602,6 @@ pci_mmap_page_range (struct pci_dev *dev, struct vm_area_struct *vma, * Leave vm_pgoff as-is, the PCI space address is the physical * address on this platform. */ - vma->vm_flags |= (VM_SHM | VM_RESERVED | VM_IO); - if (write_combine && efi_range_is_wc(vma->vm_start, vma->vm_end - vma->vm_start)) vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); @@ -666,7 +664,6 @@ pci_mmap_legacy_page_range(struct pci_bus *bus, struct vm_area_struct *vma) vma->vm_pgoff += (unsigned long)addr >> PAGE_SHIFT; vma->vm_page_prot = prot; - vma->vm_flags |= (VM_SHM | VM_RESERVED | VM_IO); if (remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff, size, vma->vm_page_prot)) diff --git a/arch/powerpc/kernel/pci_32.c b/arch/powerpc/kernel/pci_32.c index c858eb4bef1..b5431ccf114 100644 --- a/arch/powerpc/kernel/pci_32.c +++ b/arch/powerpc/kernel/pci_32.c @@ -1654,7 +1654,6 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, return -EINVAL; vma->vm_pgoff = offset >> PAGE_SHIFT; - vma->vm_flags |= VM_SHM | VM_LOCKED | VM_IO; vma->vm_page_prot = __pci_mmap_set_pgprot(dev, rp, vma->vm_page_prot, mmap_state, write_combine); diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c index 5ad87c426be..247937dd8b7 100644 --- a/arch/powerpc/kernel/pci_64.c +++ b/arch/powerpc/kernel/pci_64.c @@ -877,7 +877,6 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, return -EINVAL; vma->vm_pgoff = offset >> PAGE_SHIFT; - vma->vm_flags |= VM_SHM | VM_LOCKED | VM_IO; vma->vm_page_prot = __pci_mmap_set_pgprot(dev, rp, vma->vm_page_prot, mmap_state, write_combine); diff --git a/arch/powerpc/kernel/proc_ppc64.c b/arch/powerpc/kernel/proc_ppc64.c index 2b87f82df13..2ab8f2be911 100644 --- a/arch/powerpc/kernel/proc_ppc64.c +++ b/arch/powerpc/kernel/proc_ppc64.c @@ -115,8 +115,6 @@ static int page_map_mmap( struct file *file, struct vm_area_struct *vma ) { struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode); - vma->vm_flags |= VM_SHM | VM_LOCKED; - if ((vma->vm_end - vma->vm_start) > dp->size) return -EINVAL; diff --git a/arch/ppc/kernel/pci.c b/arch/ppc/kernel/pci.c index 809673a36f7..d20accf9650 100644 --- a/arch/ppc/kernel/pci.c +++ b/arch/ppc/kernel/pci.c @@ -1032,7 +1032,6 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, return -EINVAL; vma->vm_pgoff = offset >> PAGE_SHIFT; - vma->vm_flags |= VM_SHM | VM_LOCKED | VM_IO; vma->vm_page_prot = __pci_mmap_set_pgprot(dev, rp, vma->vm_page_prot, mmap_state, write_combine); diff --git a/arch/xtensa/kernel/pci.c b/arch/xtensa/kernel/pci.c index de19501aa80..c6f471b9eaa 100644 --- a/arch/xtensa/kernel/pci.c +++ b/arch/xtensa/kernel/pci.c @@ -349,17 +349,6 @@ __pci_mmap_make_offset(struct pci_dev *dev, struct vm_area_struct *vma, return -EINVAL; } -/* - * Set vm_flags of VMA, as appropriate for this architecture, for a pci device - * mapping. - */ -static __inline__ void -__pci_mmap_set_flags(struct pci_dev *dev, struct vm_area_struct *vma, - enum pci_mmap_state mmap_state) -{ - vma->vm_flags |= VM_SHM | VM_LOCKED | VM_IO; -} - /* * Set vm_page_prot of VMA, as appropriate for this architecture, for a pci * device mapping. @@ -399,7 +388,6 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, if (ret < 0) return ret; - __pci_mmap_set_flags(dev, vma, mmap_state); __pci_mmap_set_pgprot(dev, vma, mmap_state, write_combine); ret = io_remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff, diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c index 1b05fa68899..d65b3109318 100644 --- a/drivers/char/mmtimer.c +++ b/drivers/char/mmtimer.c @@ -329,7 +329,6 @@ static int mmtimer_mmap(struct file *file, struct vm_area_struct *vma) if (PAGE_SIZE > (1 << 16)) return -ENOSYS; - vma->vm_flags |= (VM_IO | VM_SHM | VM_LOCKED ); vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); mmtimer_addr = __pa(RTC_COUNTER_ADDR); diff --git a/drivers/sbus/char/flash.c b/drivers/sbus/char/flash.c index 5ae684c011f..31b8a5f6116 100644 --- a/drivers/sbus/char/flash.c +++ b/drivers/sbus/char/flash.c @@ -71,7 +71,6 @@ flash_mmap(struct file *file, struct vm_area_struct *vma) if (vma->vm_end - (vma->vm_start + (vma->vm_pgoff << PAGE_SHIFT)) > size) size = vma->vm_end - (vma->vm_start + (vma->vm_pgoff << PAGE_SHIFT)); - vma->vm_flags |= (VM_SHM | VM_LOCKED); vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); if (io_remap_pfn_range(vma, vma->vm_start, addr, size, vma->vm_page_prot)) diff --git a/drivers/sbus/char/vfc_dev.c b/drivers/sbus/char/vfc_dev.c index dfdd6be551f..ddcd330b9e8 100644 --- a/drivers/sbus/char/vfc_dev.c +++ b/drivers/sbus/char/vfc_dev.c @@ -623,7 +623,7 @@ static int vfc_mmap(struct file *file, struct vm_area_struct *vma) map_size = sizeof(struct vfc_regs); vma->vm_flags |= - (VM_SHM | VM_LOCKED | VM_IO | VM_MAYREAD | VM_MAYWRITE | VM_MAYSHARE); + (VM_MAYREAD | VM_MAYWRITE | VM_MAYSHARE); map_offset = (unsigned int) (long)dev->phys_regs; ret = io_remap_pfn_range(vma, vma->vm_start, MK_IOSPACE_PFN(dev->which_io, diff --git a/drivers/video/igafb.c b/drivers/video/igafb.c index 6b88050d21b..8a0c2d3d380 100644 --- a/drivers/video/igafb.c +++ b/drivers/video/igafb.c @@ -232,9 +232,6 @@ static int igafb_mmap(struct fb_info *info, size = vma->vm_end - vma->vm_start; - /* To stop the swapper from even considering these pages. */ - vma->vm_flags |= (VM_SHM | VM_LOCKED); - /* Each page, see which map applies */ for (page = 0; page < size; ) { map_size = 0; diff --git a/include/linux/mm.h b/include/linux/mm.h index 3b09444121d..71c5d2f667e 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -145,7 +145,6 @@ extern unsigned int kobjsize(const void *objp); #define VM_GROWSDOWN 0x00000100 /* general info on the segment */ #define VM_GROWSUP 0x00000200 -#define VM_SHM 0x00000000 /* Means nothing: delete it later */ #define VM_PFNMAP 0x00000400 /* Page-ranges managed without "struct page", just pure PFN */ #define VM_DENYWRITE 0x00000800 /* ETXTBSY on write attempts.. */ -- cgit v1.2.3-70-g09d2 From 2e6113908fe76a06295cb243f1f2f0eea055b0c2 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Sun, 25 Jun 2006 05:47:34 -0700 Subject: [PATCH] drivers/char/applicom.c: proper module_{init,exit} Convert the driver to use module_{init,exit}. Signed-off-by: Adrian Bunk Acked-by: David Woodhouse Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/applicom.c | 40 ++++------------------------------------ 1 file changed, 4 insertions(+), 36 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/applicom.c b/drivers/char/applicom.c index a370e7a0bad..9275d5e52e6 100644 --- a/drivers/char/applicom.c +++ b/drivers/char/applicom.c @@ -166,11 +166,7 @@ static int ac_register_board(unsigned long physloc, void __iomem *loc, return boardno + 1; } -#ifdef MODULE - -#define applicom_init init_module - -void cleanup_module(void) +static void __exit applicom_exit(void) { unsigned int i; @@ -188,9 +184,7 @@ void cleanup_module(void) } } -#endif /* MODULE */ - -int __init applicom_init(void) +static int __init applicom_init(void) { int i, numisa = 0; struct pci_dev *dev = NULL; @@ -355,10 +349,9 @@ out: return ret; } +module_init(applicom_init); +module_exit(applicom_exit); -#ifndef MODULE -__initcall(applicom_init); -#endif static ssize_t ac_write(struct file *file, const char __user *buf, size_t count, loff_t * ppos) { @@ -851,28 +844,3 @@ static int ac_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un return 0; } -#ifndef MODULE -static int __init applicom_setup(char *str) -{ - int ints[4]; - - (void) get_options(str, 4, ints); - - if (ints[0] > 2) { - printk(KERN_WARNING "Too many arguments to 'applicom=', expected mem,irq only.\n"); - } - - if (ints[0] < 2) { - printk(KERN_INFO"applicom numargs: %d\n", ints[0]); - return 0; - } - - mem = ints[1]; - irq = ints[2]; - return 1; -} - -__setup("applicom=", applicom_setup); - -#endif /* MODULE */ - -- cgit v1.2.3-70-g09d2 From 83cc5ed3c4c65fc4c3729a5cec2111ede1ebf85e Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Sun, 25 Jun 2006 05:47:41 -0700 Subject: [PATCH] kernel/sys.c: cleanups - proper prototypes for the following functions: - ctrl_alt_del() (in include/linux/reboot.h) - getrusage() (in include/linux/resource.h) - make the following needlessly global functions static: - kernel_restart_prepare() - kernel_kexec() [akpm@osdl.org: compile fix] Signed-off-by: Adrian Bunk Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/arm/mach-ixp4xx/nas100d-power.c | 3 +-- arch/arm/mach-ixp4xx/nslu2-power.c | 3 +-- arch/mips/kernel/irixsig.c | 3 +-- arch/mips/kernel/sysirix.c | 2 +- arch/um/drivers/mconsole_kern.c | 2 -- drivers/char/keyboard.c | 1 + drivers/s390/char/sclp_quiesce.c | 3 +-- include/linux/reboot.h | 4 ++-- include/linux/resource.h | 4 ++++ kernel/exit.c | 3 +-- kernel/sys.c | 5 ++--- 11 files changed, 15 insertions(+), 18 deletions(-) (limited to 'drivers/char') diff --git a/arch/arm/mach-ixp4xx/nas100d-power.c b/arch/arm/mach-ixp4xx/nas100d-power.c index 99d333d7ebd..a3745ed37f9 100644 --- a/arch/arm/mach-ixp4xx/nas100d-power.c +++ b/arch/arm/mach-ixp4xx/nas100d-power.c @@ -20,11 +20,10 @@ #include #include #include +#include #include -extern void ctrl_alt_del(void); - static irqreturn_t nas100d_reset_handler(int irq, void *dev_id, struct pt_regs *regs) { /* Signal init to do the ctrlaltdel action, this will bypass init if diff --git a/arch/arm/mach-ixp4xx/nslu2-power.c b/arch/arm/mach-ixp4xx/nslu2-power.c index d80c362bc53..6d38e97142c 100644 --- a/arch/arm/mach-ixp4xx/nslu2-power.c +++ b/arch/arm/mach-ixp4xx/nslu2-power.c @@ -20,11 +20,10 @@ #include #include #include +#include #include -extern void ctrl_alt_del(void); - static irqreturn_t nslu2_power_handler(int irq, void *dev_id, struct pt_regs *regs) { /* Signal init to do the ctrlaltdel action, this will bypass init if diff --git a/arch/mips/kernel/irixsig.c b/arch/mips/kernel/irixsig.c index a9bf6cc3abd..676e868d26f 100644 --- a/arch/mips/kernel/irixsig.c +++ b/arch/mips/kernel/irixsig.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -540,8 +541,6 @@ out: #define IRIX_P_PGID 2 #define IRIX_P_ALL 7 -extern int getrusage(struct task_struct *, int, struct rusage __user *); - #define W_EXITED 1 #define W_TRAPPED 2 #define W_STOPPED 4 diff --git a/arch/mips/kernel/sysirix.c b/arch/mips/kernel/sysirix.c index 19e1ef43eb4..1137dd6ea7a 100644 --- a/arch/mips/kernel/sysirix.c +++ b/arch/mips/kernel/sysirix.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -235,7 +236,6 @@ asmlinkage int irix_prctl(unsigned option, ...) #undef DEBUG_PROCGRPS extern unsigned long irix_mapelf(int fd, struct elf_phdr __user *user_phdrp, int cnt); -extern int getrusage(struct task_struct *p, int who, struct rusage __user *ru); extern char *prom_getenv(char *name); extern long prom_setenv(char *name, char *value); diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c index 6d7173fc55a..79149314ed0 100644 --- a/arch/um/drivers/mconsole_kern.c +++ b/arch/um/drivers/mconsole_kern.c @@ -300,8 +300,6 @@ void mconsole_reboot(struct mc_request *req) machine_restart(NULL); } -extern void ctrl_alt_del(void); - void mconsole_cad(struct mc_request *req) { mconsole_reply(req, "", 0, 0); diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c index 5755b7e5f18..edd996f6fb8 100644 --- a/drivers/char/keyboard.c +++ b/drivers/char/keyboard.c @@ -39,6 +39,7 @@ #include #include #include +#include static void kbd_disconnect(struct input_handle *handle); extern void ctrl_alt_del(void); diff --git a/drivers/s390/char/sclp_quiesce.c b/drivers/s390/char/sclp_quiesce.c index 56fa6916889..a4c53c172db 100644 --- a/drivers/s390/char/sclp_quiesce.c +++ b/drivers/s390/char/sclp_quiesce.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -66,8 +67,6 @@ do_machine_quiesce(void) } #endif -extern void ctrl_alt_del(void); - /* Handler for quiesce event. Start shutdown procedure. */ static void sclp_quiesce_handler(struct evbuf_header *evbuf) diff --git a/include/linux/reboot.h b/include/linux/reboot.h index 015297ff73f..1dd1c707311 100644 --- a/include/linux/reboot.h +++ b/include/linux/reboot.h @@ -59,13 +59,13 @@ extern void machine_crash_shutdown(struct pt_regs *); * Architecture independent implemenations of sys_reboot commands. */ -extern void kernel_restart_prepare(char *cmd); extern void kernel_shutdown_prepare(enum system_states state); extern void kernel_restart(char *cmd); extern void kernel_halt(void); extern void kernel_power_off(void); -extern void kernel_kexec(void); + +void ctrl_alt_del(void); /* * Emergency restart, callable from an interrupt handler. diff --git a/include/linux/resource.h b/include/linux/resource.h index 21a86cb6acd..ae13db71474 100644 --- a/include/linux/resource.h +++ b/include/linux/resource.h @@ -3,6 +3,8 @@ #include +struct task_struct; + /* * Resource control/accounting header file for linux */ @@ -67,4 +69,6 @@ struct rlimit { */ #include +int getrusage(struct task_struct *p, int who, struct rusage __user *ru); + #endif diff --git a/kernel/exit.c b/kernel/exit.c index a3baf92462b..b12a4706f73 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -36,6 +36,7 @@ #include #include #include /* for audit_free() */ +#include #include #include @@ -45,8 +46,6 @@ extern void sem_exit (void); extern struct task_struct *child_reaper; -int getrusage(struct task_struct *, int, struct rusage __user *); - static void exit_mm(struct task_struct * tsk); static void __unhash_process(struct task_struct *p) diff --git a/kernel/sys.c b/kernel/sys.c index 7e0927bad71..2d5179c67ce 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -589,7 +589,7 @@ void emergency_restart(void) } EXPORT_SYMBOL_GPL(emergency_restart); -void kernel_restart_prepare(char *cmd) +static void kernel_restart_prepare(char *cmd) { blocking_notifier_call_chain(&reboot_notifier_list, SYS_RESTART, cmd); system_state = SYSTEM_RESTART; @@ -623,7 +623,7 @@ EXPORT_SYMBOL_GPL(kernel_restart); * Move into place and start executing a preloaded standalone * executable. If nothing was preloaded return an error. */ -void kernel_kexec(void) +static void kernel_kexec(void) { #ifdef CONFIG_KEXEC struct kimage *image; @@ -637,7 +637,6 @@ void kernel_kexec(void) machine_kexec(image); #endif } -EXPORT_SYMBOL_GPL(kernel_kexec); void kernel_shutdown_prepare(enum system_states state) { -- cgit v1.2.3-70-g09d2 From 56e139f62bd7b82430cfcf01fcbd42e1d84fb738 Mon Sep 17 00:00:00 2001 From: Jesper Juhl Date: Sun, 25 Jun 2006 05:47:52 -0700 Subject: [PATCH] moxa: remove pointless casts Signed-off-by: Jesper Juhl Acked-by: Alan Cox Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/mxser.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c index 0fb2fb9fb02..5ddbd5b2a4c 100644 --- a/drivers/char/mxser.c +++ b/drivers/char/mxser.c @@ -877,7 +877,7 @@ static int mxser_init(void) static void mxser_do_softint(void *private_) { - struct mxser_struct *info = (struct mxser_struct *) private_; + struct mxser_struct *info = private_; struct tty_struct *tty; tty = info->tty; @@ -972,7 +972,7 @@ static int mxser_open(struct tty_struct *tty, struct file *filp) */ static void mxser_close(struct tty_struct *tty, struct file *filp) { - struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; + struct mxser_struct *info = tty->driver_data; unsigned long timeout; unsigned long flags; @@ -1078,7 +1078,7 @@ static void mxser_close(struct tty_struct *tty, struct file *filp) static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int count) { int c, total = 0; - struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; + struct mxser_struct *info = tty->driver_data; unsigned long flags; if (!tty || !info->xmit_buf) @@ -1114,7 +1114,7 @@ static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int cou static void mxser_put_char(struct tty_struct *tty, unsigned char ch) { - struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; + struct mxser_struct *info = tty->driver_data; unsigned long flags; if (!tty || !info->xmit_buf) @@ -1141,7 +1141,7 @@ static void mxser_put_char(struct tty_struct *tty, unsigned char ch) static void mxser_flush_chars(struct tty_struct *tty) { - struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; + struct mxser_struct *info = tty->driver_data; unsigned long flags; if (info->xmit_cnt <= 0 || tty->stopped || !info->xmit_buf || (tty->hw_stopped && (info->type != PORT_16550A) && (!info->IsMoxaMustChipFlag))) @@ -1157,7 +1157,7 @@ static void mxser_flush_chars(struct tty_struct *tty) static int mxser_write_room(struct tty_struct *tty) { - struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; + struct mxser_struct *info = tty->driver_data; int ret; ret = SERIAL_XMIT_SIZE - info->xmit_cnt - 1; @@ -1168,13 +1168,13 @@ static int mxser_write_room(struct tty_struct *tty) static int mxser_chars_in_buffer(struct tty_struct *tty) { - struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; + struct mxser_struct *info = tty->driver_data; return info->xmit_cnt; } static void mxser_flush_buffer(struct tty_struct *tty) { - struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; + struct mxser_struct *info = tty->driver_data; char fcr; unsigned long flags; @@ -1197,7 +1197,7 @@ static void mxser_flush_buffer(struct tty_struct *tty) static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) { - struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; + struct mxser_struct *info = tty->driver_data; int retval; struct async_icount cprev, cnow; /* kernel counter temps */ struct serial_icounter_struct __user *p_cuser; @@ -1581,7 +1581,7 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp) static void mxser_stoprx(struct tty_struct *tty) { - struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; + struct mxser_struct *info = tty->driver_data; //unsigned long flags; @@ -1615,7 +1615,7 @@ static void mxser_stoprx(struct tty_struct *tty) static void mxser_startrx(struct tty_struct *tty) { - struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; + struct mxser_struct *info = tty->driver_data; //unsigned long flags; info->ldisc_stop_rx = 0; @@ -1656,7 +1656,7 @@ static void mxser_startrx(struct tty_struct *tty) */ static void mxser_throttle(struct tty_struct *tty) { - //struct mxser_struct *info = (struct mxser_struct *)tty->driver_data; + //struct mxser_struct *info = tty->driver_data; //unsigned long flags; //MX_LOCK(&info->slock); mxser_stoprx(tty); @@ -1665,7 +1665,7 @@ static void mxser_throttle(struct tty_struct *tty) static void mxser_unthrottle(struct tty_struct *tty) { - //struct mxser_struct *info = (struct mxser_struct *)tty->driver_data; + //struct mxser_struct *info = tty->driver_data; //unsigned long flags; //MX_LOCK(&info->slock); mxser_startrx(tty); @@ -1674,7 +1674,7 @@ static void mxser_unthrottle(struct tty_struct *tty) static void mxser_set_termios(struct tty_struct *tty, struct termios *old_termios) { - struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; + struct mxser_struct *info = tty->driver_data; unsigned long flags; if ((tty->termios->c_cflag != old_termios->c_cflag) || (RELEVANT_IFLAG(tty->termios->c_iflag) != RELEVANT_IFLAG(old_termios->c_iflag))) { @@ -1711,7 +1711,7 @@ static void mxser_set_termios(struct tty_struct *tty, struct termios *old_termio */ static void mxser_stop(struct tty_struct *tty) { - struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; + struct mxser_struct *info = tty->driver_data; unsigned long flags; spin_lock_irqsave(&info->slock, flags); @@ -1724,7 +1724,7 @@ static void mxser_stop(struct tty_struct *tty) static void mxser_start(struct tty_struct *tty) { - struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; + struct mxser_struct *info = tty->driver_data; unsigned long flags; spin_lock_irqsave(&info->slock, flags); @@ -1740,7 +1740,7 @@ static void mxser_start(struct tty_struct *tty) */ static void mxser_wait_until_sent(struct tty_struct *tty, int timeout) { - struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; + struct mxser_struct *info = tty->driver_data; unsigned long orig_jiffies, char_time; int lsr; @@ -1803,7 +1803,7 @@ static void mxser_wait_until_sent(struct tty_struct *tty, int timeout) */ void mxser_hangup(struct tty_struct *tty) { - struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; + struct mxser_struct *info = tty->driver_data; mxser_flush_buffer(tty); mxser_shutdown(info); @@ -1821,7 +1821,7 @@ void mxser_hangup(struct tty_struct *tty) */ static void mxser_rs_break(struct tty_struct *tty, int break_state) { - struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; + struct mxser_struct *info = tty->driver_data; unsigned long flags; spin_lock_irqsave(&info->slock, flags); @@ -2886,7 +2886,7 @@ static void mxser_send_break(struct mxser_struct *info, int duration) static int mxser_tiocmget(struct tty_struct *tty, struct file *file) { - struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; + struct mxser_struct *info = tty->driver_data; unsigned char control, status; unsigned long flags; @@ -2909,7 +2909,7 @@ static int mxser_tiocmget(struct tty_struct *tty, struct file *file) static int mxser_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) { - struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; + struct mxser_struct *info = tty->driver_data; unsigned long flags; -- cgit v1.2.3-70-g09d2 From 8a7f7c9307962ffdf81561ec8742fde1fad9fe10 Mon Sep 17 00:00:00 2001 From: Jesper Juhl Date: Sun, 25 Jun 2006 05:47:53 -0700 Subject: [PATCH] moxa: remove pointless check of 'tty' argument vs NULL Remove pointless check of 'tty' argument vs NULL from moxa driver. Signed-off-by: Jesper Juhl Cc: Alan Cox Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/mxser.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c index 5ddbd5b2a4c..2ad9dc80cae 100644 --- a/drivers/char/mxser.c +++ b/drivers/char/mxser.c @@ -1081,7 +1081,7 @@ static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int cou struct mxser_struct *info = tty->driver_data; unsigned long flags; - if (!tty || !info->xmit_buf) + if (!info->xmit_buf) return (0); while (1) { @@ -1117,7 +1117,7 @@ static void mxser_put_char(struct tty_struct *tty, unsigned char ch) struct mxser_struct *info = tty->driver_data; unsigned long flags; - if (!tty || !info->xmit_buf) + if (!info->xmit_buf) return; if (info->xmit_cnt >= SERIAL_XMIT_SIZE - 1) -- cgit v1.2.3-70-g09d2 From 8ea2c2ecfcc1f31eaba8d1995b2e734ba821806a Mon Sep 17 00:00:00 2001 From: Jesper Juhl Date: Sun, 25 Jun 2006 05:47:54 -0700 Subject: [PATCH] moxa: partial CodingStyle cleanup & spelling fixes Do a *partial* CodingStyle cleanup, correct some spelling in printk()'s && convert C++ comments to C comments - in moxa driver. Signed-off-by: Jesper Juhl Cc: Alan Cox Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/mxser.c | 794 +++++++++++++++++++++++++++++---------------------- 1 file changed, 450 insertions(+), 344 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c index 2ad9dc80cae..645d9d713ae 100644 --- a/drivers/char/mxser.c +++ b/drivers/char/mxser.c @@ -9,7 +9,7 @@ * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -71,8 +71,8 @@ #define MXSERMAJOR 174 #define MXSERCUMAJOR 175 -#define MXSER_EVENT_TXLOW 1 -#define MXSER_EVENT_HANGUP 2 +#define MXSER_EVENT_TXLOW 1 +#define MXSER_EVENT_HANGUP 2 #define MXSER_BOARDS 4 /* Max. boards */ #define MXSER_PORTS 32 /* Max. ports */ @@ -92,7 +92,8 @@ #define UART_MCR_AFE 0x20 #define UART_LSR_SPECIAL 0x1E -#define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK|IXON|IXOFF)) +#define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK|\ + IXON|IXOFF)) #define IRQ_T(info) ((info->flags & ASYNC_SHARE_IRQ) ? SA_SHIRQ : SA_INTERRUPT) @@ -152,27 +153,27 @@ static char *mxser_brdname[] = { }; static int mxser_numports[] = { - 8, // C168-ISA - 4, // C104-ISA - 4, // CI104J - 8, // C168-PCI - 4, // C104-PCI - 2, // C102-ISA - 2, // CI132 - 4, // CI134 - 2, // CP132 - 4, // CP114 - 4, // CT114 - 2, // CP102 - 4, // CP104U - 8, // CP168U - 2, // CP132U - 4, // CP134U - 4, // CP104JU - 8, // RC7000 - 8, // CP118U - 2, // CP102UL - 2, // CP102U + 8, /* C168-ISA */ + 4, /* C104-ISA */ + 4, /* CI104J */ + 8, /* C168-PCI */ + 4, /* C104-PCI */ + 2, /* C102-ISA */ + 2, /* CI132 */ + 4, /* CI134 */ + 2, /* CP132 */ + 4, /* CP114 */ + 4, /* CT114 */ + 2, /* CP102 */ + 4, /* CP104U */ + 8, /* CP168U */ + 2, /* CP132U */ + 4, /* CP134U */ + 4, /* CP104JU */ + 8, /* RC7000 */ + 8, /* CP118U */ + 2, /* CP102UL */ + 2, /* CP102U */ }; #define UART_TYPE_NUM 2 @@ -182,7 +183,7 @@ static const unsigned int Gmoxa_uart_id[UART_TYPE_NUM] = { MOXA_MUST_MU860_HWID }; -// This is only for PCI +/* This is only for PCI */ #define UART_INFO_NUM 3 struct mxpciuart_info { int type; @@ -231,7 +232,7 @@ MODULE_DEVICE_TABLE(pci, mxser_pcibrds); typedef struct _moxa_pci_info { unsigned short busNum; unsigned short devNum; - struct pci_dev *pdev; // add by Victor Yu. 06-23-2003 + struct pci_dev *pdev; /* add by Victor Yu. 06-23-2003 */ } moxa_pci_info; static int ioaddr[MXSER_BOARDS] = { 0, 0, 0, 0 }; @@ -280,6 +281,7 @@ struct mxser_mon_ext { int fifo[32]; int iftype[32]; }; + struct mxser_hwconf { int board_type; int ports; @@ -290,9 +292,9 @@ struct mxser_hwconf { int ioaddr[MXSER_PORTS_PER_BOARD]; int baud_base[MXSER_PORTS_PER_BOARD]; moxa_pci_info pciInfo; - int IsMoxaMustChipFlag; // add by Victor Yu. 08-30-2002 - int MaxCanSetBaudRate[MXSER_PORTS_PER_BOARD]; // add by Victor Yu. 09-04-2002 - int opmode_ioaddr[MXSER_PORTS_PER_BOARD]; // add by Victor Yu. 01-05-2004 + int IsMoxaMustChipFlag; /* add by Victor Yu. 08-30-2002 */ + int MaxCanSetBaudRate[MXSER_PORTS_PER_BOARD]; /* add by Victor Yu. 09-04-2002 */ + int opmode_ioaddr[MXSER_PORTS_PER_BOARD]; /* add by Victor Yu. 01-05-2004 */ }; struct mxser_struct { @@ -334,9 +336,9 @@ struct mxser_struct { wait_queue_head_t delta_msr_wait; struct async_icount icount; /* kernel counters for the 4 input interrupts */ int timeout; - int IsMoxaMustChipFlag; // add by Victor Yu. 08-30-2002 - int MaxCanSetBaudRate; // add by Victor Yu. 09-04-2002 - int opmode_ioaddr; // add by Victor Yu. 01-05-2004 + int IsMoxaMustChipFlag; /* add by Victor Yu. 08-30-2002 */ + int MaxCanSetBaudRate; /* add by Victor Yu. 09-04-2002 */ + int opmode_ioaddr; /* add by Victor Yu. 01-05-2004 */ unsigned char stop_rx; unsigned char ldisc_stop_rx; long realbaud; @@ -345,7 +347,6 @@ struct mxser_struct { spinlock_t slock; }; - struct mxser_mstatus { tcflag_t cflag; int cts; @@ -358,7 +359,7 @@ static struct mxser_mstatus GMStatus[MXSER_PORTS]; static int mxserBoardCAP[MXSER_BOARDS] = { 0, 0, 0, 0 - /* 0x180, 0x280, 0x200, 0x320 */ + /* 0x180, 0x280, 0x200, 0x320 */ }; static struct tty_driver *mxvar_sdriver; @@ -386,7 +387,7 @@ static struct mxser_hwconf mxsercfg[MXSER_BOARDS]; static void mxser_getcfg(int board, struct mxser_hwconf *hwconf); static int mxser_init(void); -//static void mxser_poll(unsigned long); +/* static void mxser_poll(unsigned long); */ static int mxser_get_ISA_conf(int, struct mxser_hwconf *); static int mxser_get_PCI_conf(int, int, int, struct mxser_hwconf *); static void mxser_do_softint(void *); @@ -440,18 +441,18 @@ static int CheckIsMoxaMust(int io) SET_MOXA_MUST_XON1_VALUE(io, 0x11); if ((hwid = inb(io + UART_MCR)) != 0) { outb(oldmcr, io + UART_MCR); - return (MOXA_OTHER_UART); + return MOXA_OTHER_UART; } GET_MOXA_MUST_HARDWARE_ID(io, &hwid); for (i = 0; i < UART_TYPE_NUM; i++) { if (hwid == Gmoxa_uart_id[i]) - return (int) hwid; + return (int)hwid; } return MOXA_OTHER_UART; } -// above is modified by Victor Yu. 08-15-2002 +/* above is modified by Victor Yu. 08-15-2002 */ static struct tty_operations mxser_ops = { .open = mxser_open, @@ -504,7 +505,6 @@ static void __exit mxser_module_exit(void) else printk(KERN_ERR "Couldn't unregister MOXA Smartio/Industio family serial driver\n"); - for (i = 0; i < MXSER_BOARDS; i++) { struct pci_dev *pdev; @@ -513,7 +513,7 @@ static void __exit mxser_module_exit(void) else { pdev = mxsercfg[i].pciInfo.pdev; free_irq(mxsercfg[i].irq, &mxvar_table[i * MXSER_PORTS_PER_BOARD]); - if (pdev != NULL) { //PCI + if (pdev != NULL) { /* PCI */ release_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2)); release_region(pci_resource_start(pdev, 3), pci_resource_len(pdev, 3)); } else { @@ -524,7 +524,6 @@ static void __exit mxser_module_exit(void) } if (verbose) printk(KERN_DEBUG "Done.\n"); - } static void process_txrx_fifo(struct mxser_struct *info) @@ -558,8 +557,10 @@ static int mxser_initbrd(int board, struct mxser_hwconf *hwconf) n = board * MXSER_PORTS_PER_BOARD; info = &mxvar_table[n]; /*if (verbose) */ { - printk(KERN_DEBUG " ttyM%d - ttyM%d ", n, n + hwconf->ports - 1); - printk(" max. baud rate = %d bps.\n", hwconf->MaxCanSetBaudRate[0]); + printk(KERN_DEBUG " ttyM%d - ttyM%d ", + n, n + hwconf->ports - 1); + printk(" max. baud rate = %d bps.\n", + hwconf->MaxCanSetBaudRate[0]); } for (i = 0; i < hwconf->ports; i++, n++, info++) { @@ -568,12 +569,12 @@ static int mxser_initbrd(int board, struct mxser_hwconf *hwconf) info->irq = hwconf->irq; info->vector = hwconf->vector; info->vectormask = hwconf->vector_mask; - info->opmode_ioaddr = hwconf->opmode_ioaddr[i]; // add by Victor Yu. 01-05-2004 + info->opmode_ioaddr = hwconf->opmode_ioaddr[i]; /* add by Victor Yu. 01-05-2004 */ info->stop_rx = 0; info->ldisc_stop_rx = 0; info->IsMoxaMustChipFlag = hwconf->IsMoxaMustChipFlag; - //Enhance mode enabled here + /* Enhance mode enabled here */ if (info->IsMoxaMustChipFlag != MOXA_OTHER_UART) { ENABLE_MOXA_MUST_ENCHANCE_MODE(info->base); } @@ -606,22 +607,25 @@ static int mxser_initbrd(int board, struct mxser_hwconf *hwconf) /* before set INT ISR, disable all int */ for (i = 0; i < hwconf->ports; i++) { - outb(inb(hwconf->ioaddr[i] + UART_IER) & 0xf0, hwconf->ioaddr[i] + UART_IER); + outb(inb(hwconf->ioaddr[i] + UART_IER) & 0xf0, + hwconf->ioaddr[i] + UART_IER); } n = board * MXSER_PORTS_PER_BOARD; info = &mxvar_table[n]; - retval = request_irq(hwconf->irq, mxser_interrupt, IRQ_T(info), "mxser", info); + retval = request_irq(hwconf->irq, mxser_interrupt, IRQ_T(info), + "mxser", info); if (retval) { - printk(KERN_ERR "Board %d: %s", board, mxser_brdname[hwconf->board_type - 1]); - printk(" Request irq fail,IRQ (%d) may be conflit with another device.\n", info->irq); + printk(KERN_ERR "Board %d: %s", + board, mxser_brdname[hwconf->board_type - 1]); + printk(" Request irq failed, IRQ (%d) may conflict with" + " another device.\n", info->irq); return retval; } return 0; } - static void mxser_getcfg(int board, struct mxser_hwconf *hwconf) { mxsercfg[board] = *hwconf; @@ -631,26 +635,27 @@ static void mxser_getcfg(int board, struct mxser_hwconf *hwconf) static int mxser_get_PCI_conf(int busnum, int devnum, int board_type, struct mxser_hwconf *hwconf) { int i, j; -// unsigned int val; + /* unsigned int val; */ unsigned int ioaddress; struct pci_dev *pdev = hwconf->pciInfo.pdev; - //io address + /* io address */ hwconf->board_type = board_type; hwconf->ports = mxser_numports[board_type - 1]; ioaddress = pci_resource_start(pdev, 2); - request_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2), "mxser(IO)"); + request_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2), + "mxser(IO)"); - for (i = 0; i < hwconf->ports; i++) { + for (i = 0; i < hwconf->ports; i++) hwconf->ioaddr[i] = ioaddress + 8 * i; - } - //vector + /* vector */ ioaddress = pci_resource_start(pdev, 3); - request_region(pci_resource_start(pdev, 3), pci_resource_len(pdev, 3), "mxser(vector)"); + request_region(pci_resource_start(pdev, 3), pci_resource_len(pdev, 3), + "mxser(vector)"); hwconf->vector = ioaddress; - //irq + /* irq */ hwconf->irq = hwconf->pciInfo.pdev->irq; hwconf->IsMoxaMustChipFlag = CheckIsMoxaMust(hwconf->ioaddr[0]); @@ -663,7 +668,7 @@ static int mxser_get_PCI_conf(int busnum, int devnum, int board_type, struct mxs if (Gpci_uart_info[j].type == hwconf->IsMoxaMustChipFlag) { hwconf->MaxCanSetBaudRate[i] = Gpci_uart_info[j].max_baud; - //exception....CP-102 + /* exception....CP-102 */ if (board_type == MXSER_BOARD_CP102) hwconf->MaxCanSetBaudRate[i] = 921600; break; @@ -678,15 +683,15 @@ static int mxser_get_PCI_conf(int busnum, int devnum, int board_type, struct mxs else hwconf->opmode_ioaddr[i] = ioaddress + 0x0c; } - outb(0, ioaddress + 4); // default set to RS232 mode - outb(0, ioaddress + 0x0c); //default set to RS232 mode + outb(0, ioaddress + 4); /* default set to RS232 mode */ + outb(0, ioaddress + 0x0c); /* default set to RS232 mode */ } for (i = 0; i < hwconf->ports; i++) { hwconf->vector_mask |= (1 << i); hwconf->baud_base[i] = 921600; } - return (0); + return 0; } #endif @@ -707,7 +712,8 @@ static int mxser_init(void) mxsercfg[i].board_type = -1; } - printk(KERN_INFO "MOXA Smartio/Industio family driver version %s\n", MXSER_VERSION); + printk(KERN_INFO "MOXA Smartio/Industio family driver version %s\n", + MXSER_VERSION); /* Initialize the tty_driver structure */ memset(mxvar_sdriver, 0, sizeof(struct tty_driver)); @@ -719,7 +725,7 @@ static int mxser_init(void) mxvar_sdriver->type = TTY_DRIVER_TYPE_SERIAL; mxvar_sdriver->subtype = SERIAL_TYPE_NORMAL; mxvar_sdriver->init_termios = tty_std_termios; - mxvar_sdriver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; + mxvar_sdriver->init_termios.c_cflag = B9600|CS8|CREAD|HUPCL|CLOCAL; mxvar_sdriver->flags = TTY_DRIVER_REAL_RAW; tty_set_operations(mxvar_sdriver, &mxser_ops); mxvar_sdriver->ttys = mxvar_tty; @@ -739,23 +745,29 @@ static int mxser_init(void) /* Start finding ISA boards here */ for (b = 0; b < MXSER_BOARDS && m < MXSER_BOARDS; b++) { int cap; + if (!(cap = mxserBoardCAP[b])) continue; retval = mxser_get_ISA_conf(cap, &hwconf); if (retval != 0) - printk(KERN_INFO "Found MOXA %s board (CAP=0x%x)\n", mxser_brdname[hwconf.board_type - 1], ioaddr[b]); + printk(KERN_INFO "Found MOXA %s board (CAP=0x%x)\n", + mxser_brdname[hwconf.board_type - 1], ioaddr[b]); if (retval <= 0) { if (retval == MXSER_ERR_IRQ) - printk(KERN_ERR "Invalid interrupt number,board not configured\n"); + printk(KERN_ERR "Invalid interrupt number, " + "board not configured\n"); else if (retval == MXSER_ERR_IRQ_CONFLIT) - printk(KERN_ERR "Invalid interrupt number,board not configured\n"); + printk(KERN_ERR "Invalid interrupt number, " + "board not configured\n"); else if (retval == MXSER_ERR_VECTOR) - printk(KERN_ERR "Invalid interrupt vector,board not configured\n"); + printk(KERN_ERR "Invalid interrupt vector, " + "board not configured\n"); else if (retval == MXSER_ERR_IOADDR) - printk(KERN_ERR "Invalid I/O address,board not configured\n"); + printk(KERN_ERR "Invalid I/O address, " + "board not configured\n"); continue; } @@ -765,35 +777,43 @@ static int mxser_init(void) hwconf.pciInfo.pdev = NULL; mxser_getcfg(m, &hwconf); - //init mxsercfg first, or mxsercfg data is not correct on ISR. - //mxser_initbrd will hook ISR. + /* + * init mxsercfg first, + * or mxsercfg data is not correct on ISR. + */ + /* mxser_initbrd will hook ISR. */ if (mxser_initbrd(m, &hwconf) < 0) continue; - m++; } /* Start finding ISA boards from module arg */ for (b = 0; b < MXSER_BOARDS && m < MXSER_BOARDS; b++) { int cap; + if (!(cap = ioaddr[b])) continue; retval = mxser_get_ISA_conf(cap, &hwconf); if (retval != 0) - printk(KERN_INFO "Found MOXA %s board (CAP=0x%x)\n", mxser_brdname[hwconf.board_type - 1], ioaddr[b]); + printk(KERN_INFO "Found MOXA %s board (CAP=0x%x)\n", + mxser_brdname[hwconf.board_type - 1], ioaddr[b]); if (retval <= 0) { if (retval == MXSER_ERR_IRQ) - printk(KERN_ERR "Invalid interrupt number,board not configured\n"); + printk(KERN_ERR "Invalid interrupt number, " + "board not configured\n"); else if (retval == MXSER_ERR_IRQ_CONFLIT) - printk(KERN_ERR "Invalid interrupt number,board not configured\n"); + printk(KERN_ERR "Invalid interrupt number, " + "board not configured\n"); else if (retval == MXSER_ERR_VECTOR) - printk(KERN_ERR "Invalid interrupt vector,board not configured\n"); + printk(KERN_ERR "Invalid interrupt vector, " + "board not configured\n"); else if (retval == MXSER_ERR_IOADDR) - printk(KERN_ERR "Invalid I/O address,board not configured\n"); + printk(KERN_ERR "Invalid I/O address, " + "board not configured\n"); continue; } @@ -803,8 +823,11 @@ static int mxser_init(void) hwconf.pciInfo.pdev = NULL; mxser_getcfg(m, &hwconf); - //init mxsercfg first, or mxsercfg data is not correct on ISR. - //mxser_initbrd will hook ISR. + /* + * init mxsercfg first, + * or mxsercfg data is not correct on ISR. + */ + /* mxser_initbrd will hook ISR. */ if (mxser_initbrd(m, &hwconf) < 0) continue; @@ -817,7 +840,8 @@ static int mxser_init(void) index = 0; b = 0; while (b < n) { - pdev = pci_find_device(mxser_pcibrds[b].vendor, mxser_pcibrds[b].device, pdev); + pdev = pci_find_device(mxser_pcibrds[b].vendor, + mxser_pcibrds[b].device, pdev); if (pdev == NULL) { b++; continue; @@ -825,30 +849,48 @@ static int mxser_init(void) hwconf.pciInfo.busNum = busnum = pdev->bus->number; hwconf.pciInfo.devNum = devnum = PCI_SLOT(pdev->devfn) << 3; hwconf.pciInfo.pdev = pdev; - printk(KERN_INFO "Found MOXA %s board(BusNo=%d,DevNo=%d)\n", mxser_brdname[(int) (mxser_pcibrds[b].driver_data) - 1], busnum, devnum >> 3); + printk(KERN_INFO "Found MOXA %s board(BusNo=%d,DevNo=%d)\n", + mxser_brdname[(int) (mxser_pcibrds[b].driver_data) - 1], + busnum, devnum >> 3); index++; - if (m >= MXSER_BOARDS) { - printk(KERN_ERR "Too many Smartio/Industio family boards find (maximum %d),board not configured\n", MXSER_BOARDS); - } else { + if (m >= MXSER_BOARDS) + printk(KERN_ERR + "Too many Smartio/Industio family boards find " + "(maximum %d), board not configured\n", + MXSER_BOARDS); + else { if (pci_enable_device(pdev)) { - printk(KERN_ERR "Moxa SmartI/O PCI enable fail !\n"); + printk(KERN_ERR "Moxa SmartI/O PCI enable " + "fail !\n"); continue; } - retval = mxser_get_PCI_conf(busnum, devnum, (int) mxser_pcibrds[b].driver_data, &hwconf); + retval = mxser_get_PCI_conf(busnum, devnum, + (int)mxser_pcibrds[b].driver_data, + &hwconf); if (retval < 0) { if (retval == MXSER_ERR_IRQ) - printk(KERN_ERR "Invalid interrupt number,board not configured\n"); + printk(KERN_ERR + "Invalid interrupt number, " + "board not configured\n"); else if (retval == MXSER_ERR_IRQ_CONFLIT) - printk(KERN_ERR "Invalid interrupt number,board not configured\n"); + printk(KERN_ERR + "Invalid interrupt number, " + "board not configured\n"); else if (retval == MXSER_ERR_VECTOR) - printk(KERN_ERR "Invalid interrupt vector,board not configured\n"); + printk(KERN_ERR + "Invalid interrupt vector, " + "board not configured\n"); else if (retval == MXSER_ERR_IOADDR) - printk(KERN_ERR "Invalid I/O address,board not configured\n"); + printk(KERN_ERR + "Invalid I/O address, " + "board not configured\n"); continue; } mxser_getcfg(m, &hwconf); - //init mxsercfg first, or mxsercfg data is not correct on ISR. - //mxser_initbrd will hook ISR. + /* init mxsercfg first, + * or mxsercfg data is not correct on ISR. + */ + /* mxser_initbrd will hook ISR. */ if (mxser_initbrd(m, &hwconf) < 0) continue; m++; @@ -858,7 +900,8 @@ static int mxser_init(void) retval = tty_register_driver(mxvar_sdriver); if (retval) { - printk(KERN_ERR "Couldn't install MOXA Smartio/Industio family driver !\n"); + printk(KERN_ERR "Couldn't install MOXA Smartio/Industio family" + " driver !\n"); put_tty_driver(mxvar_sdriver); for (i = 0; i < MXSER_BOARDS; i++) { @@ -866,7 +909,7 @@ static int mxser_init(void) continue; else { free_irq(mxsercfg[i].irq, &mxvar_table[i * MXSER_PORTS_PER_BOARD]); - //todo: release io, vector + /* todo: release io, vector */ } } return retval; @@ -926,7 +969,7 @@ static int mxser_open(struct tty_struct *tty, struct file *filp) return -ENODEV; info = mxvar_table + line; if (!info->base) - return (-ENODEV); + return -ENODEV; tty->driver_data = info; info->tty = tty; @@ -935,11 +978,11 @@ static int mxser_open(struct tty_struct *tty, struct file *filp) */ retval = mxser_startup(info); if (retval) - return (retval); + return retval; retval = mxser_block_til_ready(tty, filp, info); if (retval) - return (retval); + return retval; info->count++; @@ -955,11 +998,12 @@ static int mxser_open(struct tty_struct *tty, struct file *filp) info->pgrp = process_group(current); clear_bit(TTY_DONT_FLIP, &tty->flags); - //status = mxser_get_msr(info->base, 0, info->port); - //mxser_check_modem_status(info, status); + /* + status = mxser_get_msr(info->base, 0, info->port); + mxser_check_modem_status(info, status); + */ -/* unmark here for very high baud rate (ex. 921600 bps) used -*/ +/* unmark here for very high baud rate (ex. 921600 bps) used */ tty->low_latency = 1; return 0; } @@ -997,11 +1041,13 @@ static void mxser_close(struct tty_struct *tty, struct file *filp) * one, we've got real problems, since it means the * serial port won't be shutdown. */ - printk(KERN_ERR "mxser_close: bad serial port count; tty->count is 1, " "info->count is %d\n", info->count); + printk(KERN_ERR "mxser_close: bad serial port count; " + "tty->count is 1, info->count is %d\n", info->count); info->count = 1; } if (--info->count < 0) { - printk(KERN_ERR "mxser_close: bad serial port count for ttys%d: %d\n", info->port, info->count); + printk(KERN_ERR "mxser_close: bad serial port count for " + "ttys%d: %d\n", info->port, info->count); info->count = 0; } if (info->count) { @@ -1056,7 +1102,7 @@ static void mxser_close(struct tty_struct *tty, struct file *filp) ld = tty_ldisc_ref(tty); if (ld) { - if(ld->flush_buffer) + if (ld->flush_buffer) ld->flush_buffer(tty); tty_ldisc_deref(ld); } @@ -1082,27 +1128,30 @@ static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int cou unsigned long flags; if (!info->xmit_buf) - return (0); + return 0; while (1) { - c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1, SERIAL_XMIT_SIZE - info->xmit_head)); + c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1, + SERIAL_XMIT_SIZE - info->xmit_head)); if (c <= 0) break; memcpy(info->xmit_buf + info->xmit_head, buf, c); spin_lock_irqsave(&info->slock, flags); - info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE - 1); + info->xmit_head = (info->xmit_head + c) & + (SERIAL_XMIT_SIZE - 1); info->xmit_cnt += c; spin_unlock_irqrestore(&info->slock, flags); buf += c; count -= c; total += c; - } if (info->xmit_cnt && !tty->stopped && !(info->IER & UART_IER_THRI)) { - if (!tty->hw_stopped || (info->type == PORT_16550A) || (info->IsMoxaMustChipFlag)) { + if (!tty->hw_stopped || + (info->type == PORT_16550A) || + (info->IsMoxaMustChipFlag)) { spin_lock_irqsave(&info->slock, flags); info->IER |= UART_IER_THRI; outb(info->IER, info->base + UART_IER); @@ -1129,7 +1178,9 @@ static void mxser_put_char(struct tty_struct *tty, unsigned char ch) info->xmit_cnt++; spin_unlock_irqrestore(&info->slock, flags); if (!tty->stopped && !(info->IER & UART_IER_THRI)) { - if (!tty->hw_stopped || (info->type == PORT_16550A) || info->IsMoxaMustChipFlag) { + if (!tty->hw_stopped || + (info->type == PORT_16550A) || + info->IsMoxaMustChipFlag) { spin_lock_irqsave(&info->slock, flags); info->IER |= UART_IER_THRI; outb(info->IER, info->base + UART_IER); @@ -1144,7 +1195,13 @@ static void mxser_flush_chars(struct tty_struct *tty) struct mxser_struct *info = tty->driver_data; unsigned long flags; - if (info->xmit_cnt <= 0 || tty->stopped || !info->xmit_buf || (tty->hw_stopped && (info->type != PORT_16550A) && (!info->IsMoxaMustChipFlag))) + if (info->xmit_cnt <= 0 || + tty->stopped || + !info->xmit_buf || + (tty->hw_stopped && + (info->type != PORT_16550A) && + (!info->IsMoxaMustChipFlag) + )) return; spin_lock_irqsave(&info->slock, flags); @@ -1163,7 +1220,7 @@ static int mxser_write_room(struct tty_struct *tty) ret = SERIAL_XMIT_SIZE - info->xmit_cnt - 1; if (ret < 0) ret = 0; - return (ret); + return ret; } static int mxser_chars_in_buffer(struct tty_struct *tty) @@ -1184,7 +1241,8 @@ static void mxser_flush_buffer(struct tty_struct *tty) /* below added by shinhay */ fcr = inb(info->base + UART_FCR); - outb((fcr | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT), info->base + UART_FCR); + outb((fcr | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT), + info->base + UART_FCR); outb(fcr, info->base + UART_FCR); spin_unlock_irqrestore(&info->slock, flags); @@ -1206,9 +1264,9 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c void __user *argp = (void __user *)arg; if (tty->index == MXSER_PORTS) - return (mxser_ioctl_special(cmd, argp)); + return mxser_ioctl_special(cmd, argp); - // following add by Victor Yu. 01-05-2004 + /* following add by Victor Yu. 01-05-2004 */ if (cmd == MOXA_SET_OP_MODE || cmd == MOXA_GET_OP_MODE) { int opmode, p; static unsigned char ModeMask[] = { 0xfc, 0xf3, 0xcf, 0x3f }; @@ -1219,7 +1277,10 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c if (cmd == MOXA_SET_OP_MODE) { if (get_user(opmode, (int __user *) argp)) return -EFAULT; - if (opmode != RS232_MODE && opmode != RS485_2WIRE_MODE && opmode != RS422_MODE && opmode != RS485_4WIRE_MODE) + if (opmode != RS232_MODE && + opmode != RS485_2WIRE_MODE && + opmode != RS422_MODE && + opmode != RS485_4WIRE_MODE) return -EFAULT; mask = ModeMask[p]; shiftbit = p * 2; @@ -1236,36 +1297,36 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c } return 0; } - // above add by Victor Yu. 01-05-2004 + /* above add by Victor Yu. 01-05-2004 */ if ((cmd != TIOCGSERIAL) && (cmd != TIOCMIWAIT) && (cmd != TIOCGICOUNT)) { if (tty->flags & (1 << TTY_IO_ERROR)) - return (-EIO); + return -EIO; } switch (cmd) { case TCSBRK: /* SVID version: non-zero arg --> no break */ retval = tty_check_change(tty); if (retval) - return (retval); + return retval; tty_wait_until_sent(tty, 0); if (!arg) mxser_send_break(info, HZ / 4); /* 1/4 second */ - return (0); + return 0; case TCSBRKP: /* support for POSIX tcsendbreak() */ retval = tty_check_change(tty); if (retval) - return (retval); + return retval; tty_wait_until_sent(tty, 0); mxser_send_break(info, arg ? arg * (HZ / 10) : HZ / 4); - return (0); + return 0; case TIOCGSOFTCAR: - return put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long __user *) argp); + return put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long __user *)argp); case TIOCSSOFTCAR: if (get_user(templ, (unsigned long __user *) argp)) return -EFAULT; arg = templ; tty->termios->c_cflag = ((tty->termios->c_cflag & ~CLOCAL) | (arg ? CLOCAL : 0)); - return (0); + return 0; case TIOCGSERIAL: return mxser_get_serial_info(info, argp); case TIOCSSERIAL: @@ -1278,7 +1339,7 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c * (use |'ed TIOCM_RNG/DSR/CD/CTS for masking) * Caller should use TIOCGICOUNT to see which one it was */ - case TIOCMIWAIT:{ + case TIOCMIWAIT: { DECLARE_WAITQUEUE(wait, current); int ret; spin_lock_irqsave(&info->slock, flags); @@ -1292,7 +1353,14 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c spin_unlock_irqrestore(&info->slock, flags); set_current_state(TASK_INTERRUPTIBLE); - if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) || ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) || ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) || ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts))) { + if (((arg & TIOCM_RNG) && + (cnow.rng != cprev.rng)) || + ((arg & TIOCM_DSR) && + (cnow.dsr != cprev.dsr)) || + ((arg & TIOCM_CD) && + (cnow.dcd != cprev.dcd)) || + ((arg & TIOCM_CTS) && + (cnow.cts != cprev.cts))) { ret = 0; break; } @@ -1338,21 +1406,18 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c put_user(cnow.dsr, &p_cuser->dsr); put_user(cnow.rng, &p_cuser->rng); put_user(cnow.dcd, &p_cuser->dcd); - -/* */ return 0; case MOXA_HighSpeedOn: - return put_user(info->baud_base != 115200 ? 1 : 0, (int __user *) argp); - - case MOXA_SDS_RSTICOUNTER:{ + return put_user(info->baud_base != 115200 ? 1 : 0, (int __user *)argp); + case MOXA_SDS_RSTICOUNTER: { info->mon_data.rxcnt = 0; info->mon_data.txcnt = 0; return 0; } -// (above) added by James. +/* (above) added by James. */ case MOXA_ASPP_SETBAUD:{ long baud; - if (get_user(baud, (long __user *) argp)) + if (get_user(baud, (long __user *)argp)) return -EFAULT; mxser_set_baud(info, baud); return 0; @@ -1377,9 +1442,10 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c return 0; } - case MOXA_ASPP_MON:{ + case MOXA_ASPP_MON: { int mcr, status; -// info->mon_data.ser_param = tty->termios->c_cflag; + + /* info->mon_data.ser_param = tty->termios->c_cflag; */ status = mxser_get_msr(info->base, 1, info->port, info); mxser_check_modem_status(info, status); @@ -1400,25 +1466,25 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c else info->mon_data.hold_reason &= ~NPPI_NOTIFY_CTSHOLD; - - if (copy_to_user(argp, &info->mon_data, sizeof(struct mxser_mon))) + if (copy_to_user(argp, &info->mon_data, + sizeof(struct mxser_mon))) return -EFAULT; return 0; - } - case MOXA_ASPP_LSTATUS:{ - if (copy_to_user(argp, &info->err_shadow, sizeof(unsigned char))) + case MOXA_ASPP_LSTATUS: { + if (copy_to_user(argp, &info->err_shadow, + sizeof(unsigned char))) return -EFAULT; info->err_shadow = 0; return 0; - } - case MOXA_SET_BAUD_METHOD:{ + case MOXA_SET_BAUD_METHOD: { int method; - if (get_user(method, (int __user *) argp)) + + if (get_user(method, (int __user *)argp)) return -EFAULT; mxser_set_baud_method[info->port] = method; if (copy_to_user(argp, &method, sizeof(int))) @@ -1442,7 +1508,8 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp) switch (cmd) { case MOXA_GET_CONF: - if (copy_to_user(argp, mxsercfg, sizeof(struct mxser_hwconf) * 4)) + if (copy_to_user(argp, mxsercfg, + sizeof(struct mxser_hwconf) * 4)) return -EFAULT; return 0; case MOXA_GET_MAJOR: @@ -1461,11 +1528,11 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp) if (mxvar_table[i].base) result |= (1 << i); } - return put_user(result, (unsigned long __user *) argp); + return put_user(result, (unsigned long __user *)argp); case MOXA_GETDATACOUNT: if (copy_to_user(argp, &mxvar_log, sizeof(mxvar_log))) return -EFAULT; - return (0); + return 0; case MOXA_GETMSTATUS: for (i = 0; i < MXSER_PORTS; i++) { GMStatus[i].ri = 0; @@ -1498,22 +1565,26 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp) else GMStatus[i].cts = 0; } - if (copy_to_user(argp, GMStatus, sizeof(struct mxser_mstatus) * MXSER_PORTS)) + if (copy_to_user(argp, GMStatus, + sizeof(struct mxser_mstatus) * MXSER_PORTS)) return -EFAULT; return 0; - case MOXA_ASPP_MON_EXT:{ + case MOXA_ASPP_MON_EXT: { int status; int opmode, p; int shiftbit; unsigned cflag, iflag; for (i = 0; i < MXSER_PORTS; i++) { - if (!mxvar_table[i].base) continue; - status = mxser_get_msr(mxvar_table[i].base, 0, i, &(mxvar_table[i])); -// mxser_check_modem_status(&mxvar_table[i], status); + status = mxser_get_msr(mxvar_table[i].base, 0, + i, &(mxvar_table[i])); + /* + mxser_check_modem_status(&mxvar_table[i], + status); + */ if (status & UART_MSR_TERI) mxvar_table[i].icount.rng++; if (status & UART_MSR_DDSR) @@ -1578,75 +1649,76 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp) return 0; } - static void mxser_stoprx(struct tty_struct *tty) { struct mxser_struct *info = tty->driver_data; - //unsigned long flags; - + /* unsigned long flags; */ info->ldisc_stop_rx = 1; if (I_IXOFF(tty)) { - - //MX_LOCK(&info->slock); - // following add by Victor Yu. 09-02-2002 + /* MX_LOCK(&info->slock); */ + /* following add by Victor Yu. 09-02-2002 */ if (info->IsMoxaMustChipFlag) { info->IER &= ~MOXA_MUST_RECV_ISR; outb(info->IER, info->base + UART_IER); } else { - // above add by Victor Yu. 09-02-2002 - + /* above add by Victor Yu. 09-02-2002 */ info->x_char = STOP_CHAR(tty); - // outb(info->IER, 0); // mask by Victor Yu. 09-02-2002 + /* mask by Victor Yu. 09-02-2002 */ + /* outb(info->IER, 0); */ outb(0, info->base + UART_IER); info->IER |= UART_IER_THRI; - outb(info->IER, info->base + UART_IER); /* force Tx interrupt */ - } // add by Victor Yu. 09-02-2002 - //MX_UNLOCK(&info->slock); + /* force Tx interrupt */ + outb(info->IER, info->base + UART_IER); + } /* add by Victor Yu. 09-02-2002 */ + /* MX_UNLOCK(&info->slock); */ } if (info->tty->termios->c_cflag & CRTSCTS) { - //MX_LOCK(&info->slock); + /* MX_LOCK(&info->slock); */ info->MCR &= ~UART_MCR_RTS; outb(info->MCR, info->base + UART_MCR); - //MX_UNLOCK(&info->slock); + /* MX_UNLOCK(&info->slock); */ } } static void mxser_startrx(struct tty_struct *tty) { struct mxser_struct *info = tty->driver_data; - //unsigned long flags; + /* unsigned long flags; */ info->ldisc_stop_rx = 0; if (I_IXOFF(tty)) { if (info->x_char) info->x_char = 0; else { - //MX_LOCK(&info->slock); + /* MX_LOCK(&info->slock); */ - // following add by Victor Yu. 09-02-2002 + /* following add by Victor Yu. 09-02-2002 */ if (info->IsMoxaMustChipFlag) { info->IER |= MOXA_MUST_RECV_ISR; outb(info->IER, info->base + UART_IER); } else { - // above add by Victor Yu. 09-02-2002 + /* above add by Victor Yu. 09-02-2002 */ info->x_char = START_CHAR(tty); - // outb(info->IER, 0); // mask by Victor Yu. 09-02-2002 - outb(0, info->base + UART_IER); // add by Victor Yu. 09-02-2002 - info->IER |= UART_IER_THRI; /* force Tx interrupt */ + /* mask by Victor Yu. 09-02-2002 */ + /* outb(info->IER, 0); */ + /* add by Victor Yu. 09-02-2002 */ + outb(0, info->base + UART_IER); + /* force Tx interrupt */ + info->IER |= UART_IER_THRI; outb(info->IER, info->base + UART_IER); - } // add by Victor Yu. 09-02-2002 - //MX_UNLOCK(&info->slock); + } /* add by Victor Yu. 09-02-2002 */ + /* MX_UNLOCK(&info->slock); */ } } if (info->tty->termios->c_cflag & CRTSCTS) { - //MX_LOCK(&info->slock); + /* MX_LOCK(&info->slock); */ info->MCR |= UART_MCR_RTS; outb(info->MCR, info->base + UART_MCR); - //MX_UNLOCK(&info->slock); + /* MX_UNLOCK(&info->slock); */ } } @@ -1656,20 +1728,22 @@ static void mxser_startrx(struct tty_struct *tty) */ static void mxser_throttle(struct tty_struct *tty) { - //struct mxser_struct *info = tty->driver_data; - //unsigned long flags; - //MX_LOCK(&info->slock); + /* struct mxser_struct *info = tty->driver_data; */ + /* unsigned long flags; */ + + /* MX_LOCK(&info->slock); */ mxser_stoprx(tty); - //MX_UNLOCK(&info->slock); + /* MX_UNLOCK(&info->slock); */ } static void mxser_unthrottle(struct tty_struct *tty) { - //struct mxser_struct *info = tty->driver_data; - //unsigned long flags; - //MX_LOCK(&info->slock); + /* struct mxser_struct *info = tty->driver_data; */ + /* unsigned long flags; */ + + /* MX_LOCK(&info->slock); */ mxser_startrx(tty); - //MX_UNLOCK(&info->slock); + /* MX_UNLOCK(&info->slock); */ } static void mxser_set_termios(struct tty_struct *tty, struct termios *old_termios) @@ -1677,27 +1751,30 @@ static void mxser_set_termios(struct tty_struct *tty, struct termios *old_termio struct mxser_struct *info = tty->driver_data; unsigned long flags; - if ((tty->termios->c_cflag != old_termios->c_cflag) || (RELEVANT_IFLAG(tty->termios->c_iflag) != RELEVANT_IFLAG(old_termios->c_iflag))) { + if ((tty->termios->c_cflag != old_termios->c_cflag) || + (RELEVANT_IFLAG(tty->termios->c_iflag) != RELEVANT_IFLAG(old_termios->c_iflag))) { mxser_change_speed(info, old_termios); - if ((old_termios->c_cflag & CRTSCTS) && !(tty->termios->c_cflag & CRTSCTS)) { + if ((old_termios->c_cflag & CRTSCTS) && + !(tty->termios->c_cflag & CRTSCTS)) { tty->hw_stopped = 0; mxser_start(tty); } } /* Handle sw stopped */ - if ((old_termios->c_iflag & IXON) && !(tty->termios->c_iflag & IXON)) { + if ((old_termios->c_iflag & IXON) && + !(tty->termios->c_iflag & IXON)) { tty->stopped = 0; - // following add by Victor Yu. 09-02-2002 + /* following add by Victor Yu. 09-02-2002 */ if (info->IsMoxaMustChipFlag) { spin_lock_irqsave(&info->slock, flags); DISABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(info->base); spin_unlock_irqrestore(&info->slock, flags); } - // above add by Victor Yu. 09-02-2002 + /* above add by Victor Yu. 09-02-2002 */ mxser_start(tty); } @@ -1777,7 +1854,8 @@ static void mxser_wait_until_sent(struct tty_struct *tty, int timeout) if (!timeout || timeout > 2 * info->timeout) timeout = 2 * info->timeout; #ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT - printk(KERN_DEBUG "In rs_wait_until_sent(%d) check=%lu...", timeout, char_time); + printk(KERN_DEBUG "In rs_wait_until_sent(%d) check=%lu...", + timeout, char_time); printk("jiff=%lu...", jiffies); #endif while (!((lsr = inb(info->base + UART_LSR)) & UART_LSR_TEMT)) { @@ -1815,7 +1893,7 @@ void mxser_hangup(struct tty_struct *tty) } -// added by James 03-12-2004. +/* added by James 03-12-2004. */ /* * mxser_rs_break() --- routine which turns the break handling on or off */ @@ -1826,13 +1904,15 @@ static void mxser_rs_break(struct tty_struct *tty, int break_state) spin_lock_irqsave(&info->slock, flags); if (break_state == -1) - outb(inb(info->base + UART_LCR) | UART_LCR_SBC, info->base + UART_LCR); + outb(inb(info->base + UART_LCR) | UART_LCR_SBC, + info->base + UART_LCR); else - outb(inb(info->base + UART_LCR) & ~UART_LCR_SBC, info->base + UART_LCR); + outb(inb(info->base + UART_LCR) & ~UART_LCR_SBC, + info->base + UART_LCR); spin_unlock_irqrestore(&info->slock, flags); } -// (above) added by James. +/* (above) added by James. */ /* @@ -1848,7 +1928,7 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id, struct pt_regs *regs) int handled = IRQ_NONE; port = NULL; - //spin_lock(&gm_lock); + /* spin_lock(&gm_lock); */ for (i = 0; i < MXSER_BOARDS; i++) { if (dev_id == &(mxvar_table[i * MXSER_PORTS_PER_BOARD])) { @@ -1857,29 +1937,25 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id, struct pt_regs *regs) } } - if (i == MXSER_BOARDS) { + if (i == MXSER_BOARDS) goto irq_stop; - } - if (port == 0) { + if (port == 0) goto irq_stop; - } max = mxser_numports[mxsercfg[i].board_type - 1]; while (1) { irqbits = inb(port->vector) & port->vectormask; - if (irqbits == port->vectormask) { + if (irqbits == port->vectormask) break; - } handled = IRQ_HANDLED; for (i = 0, bits = 1; i < max; i++, irqbits |= bits, bits <<= 1) { - if (irqbits == port->vectormask) { + if (irqbits == port->vectormask) break; - } if (bits & irqbits) continue; info = port + i; - // following add by Victor Yu. 09-13-2002 + /* following add by Victor Yu. 09-13-2002 */ iir = inb(info->base + UART_IIR); if (iir & UART_IIR_NO_INT) continue; @@ -1890,9 +1966,9 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id, struct pt_regs *regs) inb(info->base + UART_MSR); continue; } - // above add by Victor Yu. 09-13-2002 + /* above add by Victor Yu. 09-13-2002 */ /* - if ( info->tty->flip.count < TTY_FLIPBUF_SIZE/4 ){ + if (info->tty->flip.count < TTY_FLIPBUF_SIZE / 4) { info->IER |= MOXA_MUST_RECV_ISR; outb(info->IER, info->base + UART_IER); } @@ -1908,18 +1984,15 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id, struct pt_regs *regs) status = inb(info->base + UART_LSR) & info->read_status_mask; */ - // following add by Victor Yu. 09-02-2002 + /* following add by Victor Yu. 09-02-2002 */ status = inb(info->base + UART_LSR); - if (status & UART_LSR_PE) { + if (status & UART_LSR_PE) info->err_shadow |= NPPI_NOTIFY_PARITY; - } - if (status & UART_LSR_FE) { + if (status & UART_LSR_FE) info->err_shadow |= NPPI_NOTIFY_FRAMING; - } - if (status & UART_LSR_OE) { + if (status & UART_LSR_OE) info->err_shadow |= NPPI_NOTIFY_HW_OVERRUN; - } if (status & UART_LSR_BI) info->err_shadow |= NPPI_NOTIFY_BREAK; @@ -1930,11 +2003,14 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id, struct pt_regs *regs) continue; } */ - if (iir == MOXA_MUST_IIR_GDA || iir == MOXA_MUST_IIR_RDA || iir == MOXA_MUST_IIR_RTO || iir == MOXA_MUST_IIR_LSR) + if (iir == MOXA_MUST_IIR_GDA || + iir == MOXA_MUST_IIR_RDA || + iir == MOXA_MUST_IIR_RTO || + iir == MOXA_MUST_IIR_LSR) mxser_receive_chars(info, &status); } else { - // above add by Victor Yu. 09-02-2002 + /* above add by Victor Yu. 09-02-2002 */ status &= info->read_status_mask; if (status & UART_LSR_DR) @@ -1944,13 +2020,13 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id, struct pt_regs *regs) if (msr & UART_MSR_ANY_DELTA) { mxser_check_modem_status(info, msr); } - // following add by Victor Yu. 09-13-2002 + /* following add by Victor Yu. 09-13-2002 */ if (info->IsMoxaMustChipFlag) { if ((iir == 0x02) && (status & UART_LSR_THRE)) { mxser_transmit_chars(info); } } else { - // above add by Victor Yu. 09-13-2002 + /* above add by Victor Yu. 09-13-2002 */ if (status & UART_LSR_THRE) { /* 8-2-99 by William @@ -1966,7 +2042,7 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id, struct pt_regs *regs) } irq_stop: - //spin_unlock(&gm_lock); + /* spin_unlock(&gm_lock); */ return handled; } @@ -1984,56 +2060,58 @@ static void mxser_receive_chars(struct mxser_struct *info, int *status) recv_room = tty->receive_room; if ((recv_room == 0) && (!info->ldisc_stop_rx)) { - //mxser_throttle(tty); + /* mxser_throttle(tty); */ mxser_stoprx(tty); - //return; + /* return; */ } - // following add by Victor Yu. 09-02-2002 + /* following add by Victor Yu. 09-02-2002 */ if (info->IsMoxaMustChipFlag != MOXA_OTHER_UART) { if (*status & UART_LSR_SPECIAL) { goto intr_old; } - // following add by Victor Yu. 02-11-2004 - if (info->IsMoxaMustChipFlag == MOXA_MUST_MU860_HWID && (*status & MOXA_MUST_LSR_RERR)) + /* following add by Victor Yu. 02-11-2004 */ + if (info->IsMoxaMustChipFlag == MOXA_MUST_MU860_HWID && + (*status & MOXA_MUST_LSR_RERR)) goto intr_old; - // above add by Victor Yu. 02-14-2004 + /* above add by Victor Yu. 02-14-2004 */ if (*status & MOXA_MUST_LSR_RERR) goto intr_old; gdl = inb(info->base + MOXA_MUST_GDL_REGISTER); - if (info->IsMoxaMustChipFlag == MOXA_MUST_MU150_HWID) // add by Victor Yu. 02-11-2004 + /* add by Victor Yu. 02-11-2004 */ + if (info->IsMoxaMustChipFlag == MOXA_MUST_MU150_HWID) gdl &= MOXA_MUST_GDL_MASK; if (gdl >= recv_room) { if (!info->ldisc_stop_rx) { - //mxser_throttle(tty); + /* mxser_throttle(tty); */ mxser_stoprx(tty); } - //return; + /* return; */ } while (gdl--) { ch = inb(info->base + UART_RX); tty_insert_flip_char(tty, ch, 0); cnt++; /* - if((cnt>=HI_WATER) && (info->stop_rx==0)){ + if ((cnt >= HI_WATER) && (info->stop_rx == 0)) { mxser_stoprx(tty); - info->stop_rx=1; + info->stop_rx = 1; break; } */ } goto end_intr; } -intr_old: - // above add by Victor Yu. 09-02-2002 + intr_old: + /* above add by Victor Yu. 09-02-2002 */ do { if (max-- < 0) break; /* - if((cnt>=HI_WATER) && (info->stop_rx==0)){ + if ((cnt >= HI_WATER) && (info->stop_rx == 0)) { mxser_stoprx(tty); info->stop_rx=1; break; @@ -2041,11 +2119,11 @@ intr_old: */ ch = inb(info->base + UART_RX); - // following add by Victor Yu. 09-02-2002 + /* following add by Victor Yu. 09-02-2002 */ if (info->IsMoxaMustChipFlag && (*status & UART_LSR_OE) /*&& !(*status&UART_LSR_DR) */ ) outb(0x23, info->base + UART_FCR); *status &= info->read_status_mask; - // above add by Victor Yu. 09-02-2002 + /* above add by Victor Yu. 09-02-2002 */ if (*status & info->ignore_status_mask) { if (++ignored > 100) break; @@ -2080,7 +2158,7 @@ intr_old: cnt++; if (cnt >= recv_room) { if (!info->ldisc_stop_rx) { - //mxser_throttle(tty); + /* mxser_throttle(tty); */ mxser_stoprx(tty); } break; @@ -2088,21 +2166,20 @@ intr_old: } - // following add by Victor Yu. 09-02-2002 + /* following add by Victor Yu. 09-02-2002 */ if (info->IsMoxaMustChipFlag) break; - // above add by Victor Yu. 09-02-2002 + /* above add by Victor Yu. 09-02-2002 */ /* mask by Victor Yu. 09-02-2002 *status = inb(info->base + UART_LSR) & info->read_status_mask; */ - // following add by Victor Yu. 09-02-2002 + /* following add by Victor Yu. 09-02-2002 */ *status = inb(info->base + UART_LSR); - // above add by Victor Yu. 09-02-2002 + /* above add by Victor Yu. 09-02-2002 */ } while (*status & UART_LSR_DR); -end_intr: // add by Victor Yu. 09-02-2002 - +end_intr: /* add by Victor Yu. 09-02-2002 */ mxvar_log.rxcnt[info->port] += cnt; info->mon_data.rxcnt += cnt; info->mon_data.up_rxcnt += cnt; @@ -2137,7 +2214,10 @@ static void mxser_transmit_chars(struct mxser_struct *info) return; } - if ((info->xmit_cnt <= 0) || info->tty->stopped || (info->tty->hw_stopped && (info->type != PORT_16550A) && (!info->IsMoxaMustChipFlag))) { + if ((info->xmit_cnt <= 0) || info->tty->stopped || + (info->tty->hw_stopped && + (info->type != PORT_16550A) && + (!info->IsMoxaMustChipFlag))) { info->IER &= ~UART_IER_THRI; outb(info->IER, info->base + UART_IER); spin_unlock_irqrestore(&info->slock, flags); @@ -2147,17 +2227,18 @@ static void mxser_transmit_chars(struct mxser_struct *info) cnt = info->xmit_cnt; count = info->xmit_fifo_size; do { - outb(info->xmit_buf[info->xmit_tail++], info->base + UART_TX); + outb(info->xmit_buf[info->xmit_tail++], + info->base + UART_TX); info->xmit_tail = info->xmit_tail & (SERIAL_XMIT_SIZE - 1); if (--info->xmit_cnt <= 0) break; } while (--count > 0); mxvar_log.txcnt[info->port] += (cnt - info->xmit_cnt); -// added by James 03-12-2004. +/* added by James 03-12-2004. */ info->mon_data.txcnt += (cnt - info->xmit_cnt); info->mon_data.up_txcnt += (cnt - info->xmit_cnt); -// (above) added by James. +/* (above) added by James. */ /* added by casper 1/11/2000 */ info->icount.tx += (cnt - info->xmit_cnt); @@ -2188,7 +2269,6 @@ static void mxser_check_modem_status(struct mxser_struct *info, int status) info->mon_data.modem_status = status; wake_up_interruptible(&info->delta_msr_wait); - if ((info->flags & ASYNC_CHECK_CD) && (status & UART_MSR_DDCD)) { if (status & UART_MSR_DCD) wake_up_interruptible(&info->open_wait); @@ -2200,7 +2280,8 @@ static void mxser_check_modem_status(struct mxser_struct *info, int status) if (status & UART_MSR_CTS) { info->tty->hw_stopped = 0; - if ((info->type != PORT_16550A) && (!info->IsMoxaMustChipFlag)) { + if ((info->type != PORT_16550A) && + (!info->IsMoxaMustChipFlag)) { info->IER |= UART_IER_THRI; outb(info->IER, info->base + UART_IER); } @@ -2209,7 +2290,8 @@ static void mxser_check_modem_status(struct mxser_struct *info, int status) } else { if (!(status & UART_MSR_CTS)) { info->tty->hw_stopped = 1; - if ((info->type != PORT_16550A) && (!info->IsMoxaMustChipFlag)) { + if ((info->type != PORT_16550A) && + (!info->IsMoxaMustChipFlag)) { info->IER &= ~UART_IER_THRI; outb(info->IER, info->base + UART_IER); } @@ -2231,7 +2313,7 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp, stru */ if ((filp->f_flags & O_NONBLOCK) || (tty->flags & (1 << TTY_IO_ERROR))) { info->flags |= ASYNC_NORMAL_ACTIVE; - return (0); + return 0; } if (tty->termios->c_cflag & CLOCAL) @@ -2254,7 +2336,8 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp, stru info->blocked_open++; while (1) { spin_lock_irqsave(&info->slock, flags); - outb(inb(info->base + UART_MCR) | UART_MCR_DTR | UART_MCR_RTS, info->base + UART_MCR); + outb(inb(info->base + UART_MCR) | + UART_MCR_DTR | UART_MCR_RTS, info->base + UART_MCR); spin_unlock_irqrestore(&info->slock, flags); set_current_state(TASK_INTERRUPTIBLE); if (tty_hung_up_p(filp) || !(info->flags & ASYNC_INITIALIZED)) { @@ -2264,7 +2347,9 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp, stru retval = -ERESTARTSYS; break; } - if (!(info->flags & ASYNC_CLOSING) && (do_clocal || (inb(info->base + UART_MSR) & UART_MSR_DCD))) + if (!(info->flags & ASYNC_CLOSING) && + (do_clocal || + (inb(info->base + UART_MSR) & UART_MSR_DCD))) break; if (signal_pending(current)) { retval = -ERESTARTSYS; @@ -2278,27 +2363,26 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp, stru info->count++; info->blocked_open--; if (retval) - return (retval); + return retval; info->flags |= ASYNC_NORMAL_ACTIVE; - return (0); + return 0; } static int mxser_startup(struct mxser_struct *info) { - unsigned long page; unsigned long flags; page = __get_free_page(GFP_KERNEL); if (!page) - return (-ENOMEM); + return -ENOMEM; spin_lock_irqsave(&info->slock, flags); if (info->flags & ASYNC_INITIALIZED) { free_page(page); spin_unlock_irqrestore(&info->slock, flags); - return (0); + return 0; } if (!info->base || !info->type) { @@ -2306,7 +2390,7 @@ static int mxser_startup(struct mxser_struct *info) set_bit(TTY_IO_ERROR, &info->tty->flags); free_page(page); spin_unlock_irqrestore(&info->slock, flags); - return (0); + return 0; } if (info->xmit_buf) free_page(page); @@ -2318,9 +2402,12 @@ static int mxser_startup(struct mxser_struct *info) * (they will be reenabled in mxser_change_speed()) */ if (info->IsMoxaMustChipFlag) - outb((UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT | MOXA_MUST_FCR_GDA_MODE_ENABLE), info->base + UART_FCR); + outb((UART_FCR_CLEAR_RCVR | + UART_FCR_CLEAR_XMIT | + MOXA_MUST_FCR_GDA_MODE_ENABLE), info->base + UART_FCR); else - outb((UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT), info->base + UART_FCR); + outb((UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT), + info->base + UART_FCR); /* * At this point there's no way the LSR could still be 0xFF; @@ -2332,9 +2419,9 @@ static int mxser_startup(struct mxser_struct *info) if (capable(CAP_SYS_ADMIN)) { if (info->tty) set_bit(TTY_IO_ERROR, &info->tty->flags); - return (0); + return 0; } else - return (-ENODEV); + return -ENODEV; } /* @@ -2356,12 +2443,12 @@ static int mxser_startup(struct mxser_struct *info) * Finally, enable interrupts */ info->IER = UART_IER_MSI | UART_IER_RLSI | UART_IER_RDI; -// info->IER = UART_IER_RLSI | UART_IER_RDI; + /* info->IER = UART_IER_RLSI | UART_IER_RDI; */ - // following add by Victor Yu. 08-30-2002 + /* following add by Victor Yu. 08-30-2002 */ if (info->IsMoxaMustChipFlag) info->IER |= MOXA_MUST_IER_EGDAI; - // above add by Victor Yu. 08-30-2002 + /* above add by Victor Yu. 08-30-2002 */ outb(info->IER, info->base + UART_IER); /* enable interrupts */ /* @@ -2383,7 +2470,7 @@ static int mxser_startup(struct mxser_struct *info) mxser_change_speed(info, NULL); info->flags |= ASYNC_INITIALIZED; - return (0); + return 0; } /* @@ -2421,12 +2508,15 @@ static void mxser_shutdown(struct mxser_struct *info) outb(info->MCR, info->base + UART_MCR); /* clear Rx/Tx FIFO's */ - // following add by Victor Yu. 08-30-2002 + /* following add by Victor Yu. 08-30-2002 */ if (info->IsMoxaMustChipFlag) - outb((UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT | MOXA_MUST_FCR_GDA_MODE_ENABLE), info->base + UART_FCR); + outb((UART_FCR_CLEAR_RCVR | + UART_FCR_CLEAR_XMIT | + MOXA_MUST_FCR_GDA_MODE_ENABLE), info->base + UART_FCR); else - // above add by Victor Yu. 08-30-2002 - outb((UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT), info->base + UART_FCR); + /* above add by Victor Yu. 08-30-2002 */ + outb((UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT), + info->base + UART_FCR); /* read data port to reset things */ (void) inb(info->base + UART_RX); @@ -2436,11 +2526,10 @@ static void mxser_shutdown(struct mxser_struct *info) info->flags &= ~ASYNC_INITIALIZED; - // following add by Victor Yu. 09-23-2002 - if (info->IsMoxaMustChipFlag) { + /* following add by Victor Yu. 09-23-2002 */ + if (info->IsMoxaMustChipFlag) SET_MOXA_MUST_NO_SOFTWARE_FLOW_CONTROL(info->base); - } - // above add by Victor Yu. 09-23-2002 + /* above add by Victor Yu. 09-23-2002 */ spin_unlock_irqrestore(&info->slock, flags); } @@ -2457,14 +2546,12 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter long baud; unsigned long flags; - if (!info->tty || !info->tty->termios) return ret; cflag = info->tty->termios->c_cflag; if (!(info->base)) return ret; - #ifndef B921600 #define B921600 (B460800 +1) #endif @@ -2559,9 +2646,8 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter cval |= 0x04; if (cflag & PARENB) cval |= UART_LCR_PARITY; - if (!(cflag & PARODD)) { + if (!(cflag & PARODD)) cval |= UART_LCR_EPAR; - } if (cflag & CMSPAR) cval |= UART_LCR_SPAR; @@ -2574,13 +2660,12 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter fcr = 0; } else { fcr = UART_FCR_ENABLE_FIFO; - // following add by Victor Yu. 08-30-2002 + /* following add by Victor Yu. 08-30-2002 */ if (info->IsMoxaMustChipFlag) { fcr |= MOXA_MUST_FCR_GDA_MODE_ENABLE; SET_MOXA_MUST_FIFO_VALUE(info); } else { - // above add by Victor Yu. 08-30-2002 - + /* above add by Victor Yu. 08-30-2002 */ switch (info->rx_trigger) { case 1: fcr |= UART_FCR_TRIGGER_1; @@ -2606,22 +2691,24 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter info->IER |= UART_IER_MSI; if ((info->type == PORT_16550A) || (info->IsMoxaMustChipFlag)) { info->MCR |= UART_MCR_AFE; - //status = mxser_get_msr(info->base, 0, info->port); -/* save_flags(flags); + /* status = mxser_get_msr(info->base, 0, info->port); */ +/* + save_flags(flags); cli(); status = inb(baseaddr + UART_MSR); - restore_flags(flags);*/ - //mxser_check_modem_status(info, status); + restore_flags(flags); +*/ + /* mxser_check_modem_status(info, status); */ } else { - //status = mxser_get_msr(info->base, 0, info->port); - - //MX_LOCK(&info->slock); + /* status = mxser_get_msr(info->base, 0, info->port); */ + /* MX_LOCK(&info->slock); */ status = inb(info->base + UART_MSR); - //MX_UNLOCK(&info->slock); + /* MX_UNLOCK(&info->slock); */ if (info->tty->hw_stopped) { if (status & UART_MSR_CTS) { info->tty->hw_stopped = 0; - if ((info->type != PORT_16550A) && (!info->IsMoxaMustChipFlag)) { + if ((info->type != PORT_16550A) && + (!info->IsMoxaMustChipFlag)) { info->IER |= UART_IER_THRI; outb(info->IER, info->base + UART_IER); } @@ -2630,7 +2717,8 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter } else { if (!(status & UART_MSR_CTS)) { info->tty->hw_stopped = 1; - if ((info->type != PORT_16550A) && (!info->IsMoxaMustChipFlag)) { + if ((info->type != PORT_16550A) && + (!info->IsMoxaMustChipFlag)) { info->IER &= ~UART_IER_THRI; outb(info->IER, info->base + UART_IER); } @@ -2668,11 +2756,17 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter * overruns too. (For real raw support). */ if (I_IGNPAR(info->tty)) { - info->ignore_status_mask |= UART_LSR_OE | UART_LSR_PE | UART_LSR_FE; - info->read_status_mask |= UART_LSR_OE | UART_LSR_PE | UART_LSR_FE; + info->ignore_status_mask |= + UART_LSR_OE | + UART_LSR_PE | + UART_LSR_FE; + info->read_status_mask |= + UART_LSR_OE | + UART_LSR_PE | + UART_LSR_FE; } } - // following add by Victor Yu. 09-02-2002 + /* following add by Victor Yu. 09-02-2002 */ if (info->IsMoxaMustChipFlag) { spin_lock_irqsave(&info->slock, flags); SET_MOXA_MUST_XON1_VALUE(info->base, START_CHAR(info->tty)); @@ -2698,7 +2792,7 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter */ spin_unlock_irqrestore(&info->slock, flags); } - // above add by Victor Yu. 09-02-2002 + /* above add by Victor Yu. 09-02-2002 */ outb(fcr, info->base + UART_FCR); /* set fcr */ @@ -2729,10 +2823,8 @@ static int mxser_set_baud(struct mxser_struct *info, long newspd) quot = (2 * info->baud_base / 269); } else if (newspd) { quot = info->baud_base / newspd; - if (quot == 0) quot = 1; - } else { quot = 0; } @@ -2765,8 +2857,6 @@ static int mxser_set_baud(struct mxser_struct *info, long newspd) return ret; } - - /* * ------------------------------------------------------------ * friends of mxser_ioctl() @@ -2777,7 +2867,7 @@ static int mxser_get_serial_info(struct mxser_struct *info, struct serial_struct struct serial_struct tmp; if (!retinfo) - return (-EFAULT); + return -EFAULT; memset(&tmp, 0, sizeof(tmp)); tmp.type = info->type; tmp.line = info->port; @@ -2791,7 +2881,7 @@ static int mxser_get_serial_info(struct mxser_struct *info, struct serial_struct tmp.hub6 = 0; if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) return -EFAULT; - return (0); + return 0; } static int mxser_set_serial_info(struct mxser_struct *info, struct serial_struct __user *new_info) @@ -2801,29 +2891,37 @@ static int mxser_set_serial_info(struct mxser_struct *info, struct serial_struct int retval = 0; if (!new_info || !info->base) - return (-EFAULT); + return -EFAULT; if (copy_from_user(&new_serial, new_info, sizeof(new_serial))) return -EFAULT; - if ((new_serial.irq != info->irq) || (new_serial.port != info->base) || (new_serial.custom_divisor != info->custom_divisor) || (new_serial.baud_base != info->baud_base)) - return (-EPERM); + if ((new_serial.irq != info->irq) || + (new_serial.port != info->base) || + (new_serial.custom_divisor != info->custom_divisor) || + (new_serial.baud_base != info->baud_base)) + return -EPERM; flags = info->flags & ASYNC_SPD_MASK; if (!capable(CAP_SYS_ADMIN)) { - if ((new_serial.baud_base != info->baud_base) || (new_serial.close_delay != info->close_delay) || ((new_serial.flags & ~ASYNC_USR_MASK) != (info->flags & ~ASYNC_USR_MASK))) - return (-EPERM); - info->flags = ((info->flags & ~ASYNC_USR_MASK) | (new_serial.flags & ASYNC_USR_MASK)); + if ((new_serial.baud_base != info->baud_base) || + (new_serial.close_delay != info->close_delay) || + ((new_serial.flags & ~ASYNC_USR_MASK) != (info->flags & ~ASYNC_USR_MASK))) + return -EPERM; + info->flags = ((info->flags & ~ASYNC_USR_MASK) | + (new_serial.flags & ASYNC_USR_MASK)); } else { /* * OK, past this point, all the error checking has been done. * At this point, we start making changes..... */ - info->flags = ((info->flags & ~ASYNC_FLAGS) | (new_serial.flags & ASYNC_FLAGS)); + info->flags = ((info->flags & ~ASYNC_FLAGS) | + (new_serial.flags & ASYNC_FLAGS)); info->close_delay = new_serial.close_delay * HZ / 100; info->closing_wait = new_serial.closing_wait * HZ / 100; - info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0; - info->tty->low_latency = 0; //(info->flags & ASYNC_LOW_LATENCY) ? 1 : 0; + info->tty->low_latency = + (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0; + info->tty->low_latency = 0; /* (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0; */ } /* added by casper, 3/17/2000, for mouse */ @@ -2831,7 +2929,6 @@ static int mxser_set_serial_info(struct mxser_struct *info, struct serial_struct process_txrx_fifo(info); - /* */ if (info->flags & ASYNC_INITIALIZED) { if (flags != (info->flags & ASYNC_SPD_MASK)) { mxser_change_speed(info, NULL); @@ -2839,7 +2936,7 @@ static int mxser_set_serial_info(struct mxser_struct *info, struct serial_struct } else { retval = mxser_startup(info); } - return (retval); + return retval; } /* @@ -2876,11 +2973,13 @@ static void mxser_send_break(struct mxser_struct *info, int duration) return; set_current_state(TASK_INTERRUPTIBLE); spin_lock_irqsave(&info->slock, flags); - outb(inb(info->base + UART_LCR) | UART_LCR_SBC, info->base + UART_LCR); + outb(inb(info->base + UART_LCR) | UART_LCR_SBC, + info->base + UART_LCR); spin_unlock_irqrestore(&info->slock, flags); schedule_timeout(duration); spin_lock_irqsave(&info->slock, flags); - outb(inb(info->base + UART_LCR) & ~UART_LCR_SBC, info->base + UART_LCR); + outb(inb(info->base + UART_LCR) & ~UART_LCR_SBC, + info->base + UART_LCR); spin_unlock_irqrestore(&info->slock, flags); } @@ -2892,9 +2991,9 @@ static int mxser_tiocmget(struct tty_struct *tty, struct file *file) if (tty->index == MXSER_PORTS) - return (-ENOIOCTLCMD); + return -ENOIOCTLCMD; if (tty->flags & (1 << TTY_IO_ERROR)) - return (-EIO); + return -EIO; control = info->MCR; @@ -2904,7 +3003,11 @@ static int mxser_tiocmget(struct tty_struct *tty, struct file *file) mxser_check_modem_status(info, status); spin_unlock_irqrestore(&info->slock, flags); return ((control & UART_MCR_RTS) ? TIOCM_RTS : 0) | - ((control & UART_MCR_DTR) ? TIOCM_DTR : 0) | ((status & UART_MSR_DCD) ? TIOCM_CAR : 0) | ((status & UART_MSR_RI) ? TIOCM_RNG : 0) | ((status & UART_MSR_DSR) ? TIOCM_DSR : 0) | ((status & UART_MSR_CTS) ? TIOCM_CTS : 0); + ((control & UART_MCR_DTR) ? TIOCM_DTR : 0) | + ((status & UART_MSR_DCD) ? TIOCM_CAR : 0) | + ((status & UART_MSR_RI) ? TIOCM_RNG : 0) | + ((status & UART_MSR_DSR) ? TIOCM_DSR : 0) | + ((status & UART_MSR_CTS) ? TIOCM_CTS : 0); } static int mxser_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) @@ -2968,38 +3071,36 @@ static int mxser_get_ISA_conf(int cap, struct mxser_hwconf *hwconf) hwconf->board_type = MXSER_BOARD_CI104J; hwconf->ports = 4; } else - return (0); + return 0; irq = 0; if (hwconf->ports == 2) { irq = regs[9] & 0xF000; irq = irq | (irq >> 4); if (irq != (regs[9] & 0xFF00)) - return (MXSER_ERR_IRQ_CONFLIT); + return MXSER_ERR_IRQ_CONFLIT; } else if (hwconf->ports == 4) { irq = regs[9] & 0xF000; irq = irq | (irq >> 4); irq = irq | (irq >> 8); if (irq != regs[9]) - return (MXSER_ERR_IRQ_CONFLIT); + return MXSER_ERR_IRQ_CONFLIT; } else if (hwconf->ports == 8) { irq = regs[9] & 0xF000; irq = irq | (irq >> 4); irq = irq | (irq >> 8); if ((irq != regs[9]) || (irq != regs[10])) - return (MXSER_ERR_IRQ_CONFLIT); + return MXSER_ERR_IRQ_CONFLIT; } - if (!irq) { - return (MXSER_ERR_IRQ); - } - hwconf->irq = ((int) (irq & 0xF000) >> 12); + if (!irq) + return MXSER_ERR_IRQ; + hwconf->irq = ((int)(irq & 0xF000) >> 12); for (i = 0; i < 8; i++) hwconf->ioaddr[i] = (int) regs[i + 1] & 0xFFF8; - if ((regs[12] & 0x80) == 0) { - return (MXSER_ERR_VECTOR); - } - hwconf->vector = (int) regs[11]; /* interrupt vector */ + if ((regs[12] & 0x80) == 0) + return MXSER_ERR_VECTOR; + hwconf->vector = (int)regs[11]; /* interrupt vector */ if (id == 1) hwconf->vector_mask = 0x00FF; else @@ -3007,10 +3108,10 @@ static int mxser_get_ISA_conf(int cap, struct mxser_hwconf *hwconf) for (i = 7, bits = 0x0100; i >= 0; i--, bits <<= 1) { if (regs[12] & bits) { hwconf->baud_base[i] = 921600; - hwconf->MaxCanSetBaudRate[i] = 921600; // add by Victor Yu. 09-04-2002 + hwconf->MaxCanSetBaudRate[i] = 921600; /* add by Victor Yu. 09-04-2002 */ } else { hwconf->baud_base[i] = 115200; - hwconf->MaxCanSetBaudRate[i] = 115200; // add by Victor Yu. 09-04-2002 + hwconf->MaxCanSetBaudRate[i] = 115200; /* add by Victor Yu. 09-04-2002 */ } } scratch2 = inb(cap + UART_LCR) & (~UART_LCR_DLAB); @@ -3030,7 +3131,7 @@ static int mxser_get_ISA_conf(int cap, struct mxser_hwconf *hwconf) hwconf->ports = 4; request_region(hwconf->ioaddr[0], 8 * hwconf->ports, "mxser(IO)"); request_region(hwconf->vector, 1, "mxser(vector)"); - return (hwconf->ports); + return hwconf->ports; } #define CHIP_SK 0x01 /* Serial Data Clock in Eprom */ @@ -3053,7 +3154,7 @@ static int mxser_read_register(int port, unsigned short *regs) id = mxser_program_mode(port); if (id < 0) - return (id); + return id; for (i = 0; i < 14; i++) { k = (i & 0x3F) | 0x180; for (j = 0x100; j > 0; j >>= 1) { @@ -3066,7 +3167,7 @@ static int mxser_read_register(int port, unsigned short *regs) outb(CHIP_CS | CHIP_SK, port); /* A? bit of read */ } } - (void) inb(port); + (void)inb(port); value = 0; for (k = 0, j = 0x8000; k < 16; k++, j >>= 1) { outb(CHIP_CS, port); @@ -3078,28 +3179,33 @@ static int mxser_read_register(int port, unsigned short *regs) outb(0, port); } mxser_normal_mode(port); - return (id); + return id; } static int mxser_program_mode(int port) { int id, i, j, n; - //unsigned long flags; + /* unsigned long flags; */ spin_lock(&gm_lock); outb(0, port); outb(0, port); outb(0, port); - (void) inb(port); - (void) inb(port); + (void)inb(port); + (void)inb(port); outb(0, port); - (void) inb(port); - //restore_flags(flags); + (void)inb(port); + /* restore_flags(flags); */ spin_unlock(&gm_lock); id = inb(port + 1) & 0x1F; - if ((id != C168_ASIC_ID) && (id != C104_ASIC_ID) && (id != C102_ASIC_ID) && (id != CI132_ASIC_ID) && (id != CI134_ASIC_ID) && (id != CI104J_ASIC_ID)) - return (-1); + if ((id != C168_ASIC_ID) && + (id != C104_ASIC_ID) && + (id != C102_ASIC_ID) && + (id != CI132_ASIC_ID) && + (id != CI134_ASIC_ID) && + (id != CI104J_ASIC_ID)) + return -1; for (i = 0, j = 0; i < 4; i++) { n = inb(port + 2); if (n == 'M') { @@ -3112,7 +3218,7 @@ static int mxser_program_mode(int port) } if (j != 2) id = -2; - return (id); + return id; } static void mxser_normal_mode(int port) @@ -3130,7 +3236,7 @@ static void mxser_normal_mode(int port) if ((n & 0x61) == 0x60) break; if ((n & 1) == 1) - (void) inb(port); + (void)inb(port); } outb(0x00, port + 4); } -- cgit v1.2.3-70-g09d2 From 673e321cf9a12ecc2d6ce683fa9105f3443c1cbd Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Sun, 25 Jun 2006 05:48:39 -0700 Subject: [PATCH] char/ip2: more section fixes (replacement) Priority: tossup. In theory some of these (previously) __init functions could be called after init, but that problem has not been observed AFAIK. There were 2 cases of cleanup_module() (module_exit) calling __init functions (clear_requested_irq() & have_requested_irq()). These are more serious, but still not observed AFAIK. Fix sections mismatch: WARNING: drivers/char/ip2/ip2main.o - Section mismatch: reference to .init.text: from .text between 'cleanup_module' (at offset 0x228b) and 'ip2_loadmain' WARNING: drivers/char/ip2/ip2main.o - Section mismatch: reference to .init.text: from .text between 'cleanup_module' (at offset 0x22ae) and 'ip2_loadmain' WARNING: drivers/char/ip2/ip2main.o - Section mismatch: reference to .init.text: from .text between 'ip2_loadmain' (at offset 0x2501) and 'set_irq' WARNING: drivers/char/ip2/ip2main.o - Section mismatch: reference to .init.text: from .text between 'ip2_loadmain' (at offset 0x25de) and 'set_irq' WARNING: drivers/char/ip2/ip2main.o - Section mismatch: reference to .init.text: from .text between 'ip2_loadmain' (at offset 0x2698) and 'set_irq' WARNING: drivers/char/ip2/ip2main.o - Section mismatch: reference to .init.text: from .text between 'ip2_loadmain' (at offset 0x2922) and 'set_irq' WARNING: drivers/char/ip2/ip2main.o - Section mismatch: reference to .init.text: from .text between 'ip2_loadmain' (at offset 0x299e) and 'set_irq' Signed-off-by: Randy Dunlap Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/ip2/ip2main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/ip2/ip2main.c b/drivers/char/ip2/ip2main.c index 03db1cb3fa9..9ab33c3d359 100644 --- a/drivers/char/ip2/ip2main.c +++ b/drivers/char/ip2/ip2main.c @@ -305,7 +305,7 @@ static struct class *ip2_class; // Some functions to keep track of what irq's we have -static int __init +static int is_valid_irq(int irq) { int *i = Valid_Irqs; @@ -316,14 +316,14 @@ is_valid_irq(int irq) return (*i); } -static void __init +static void mark_requested_irq( char irq ) { rirqs[iindx++] = irq; } #ifdef MODULE -static int __init +static int clear_requested_irq( char irq ) { int i; @@ -337,7 +337,7 @@ clear_requested_irq( char irq ) } #endif -static int __init +static int have_requested_irq( char irq ) { // array init to zeros so 0 irq will not be requested as a side effect @@ -818,7 +818,7 @@ EXPORT_SYMBOL(ip2_loadmain); /* the board, the channel structures are initialized, and the board details */ /* are reported on the console. */ /******************************************************************************/ -static void __init +static void ip2_init_board( int boardnum ) { int i; @@ -961,7 +961,7 @@ err_initialize: /* EISA motherboard, or no valid board ID is selected it returns 0. Otherwise */ /* it returns the base address of the controller. */ /******************************************************************************/ -static unsigned short __init +static unsigned short find_eisa_board( int start_slot ) { int i, j; -- cgit v1.2.3-70-g09d2 From 78dbe706e22f54bce61571ad837238382e1ba5f9 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Sun, 25 Jun 2006 05:48:41 -0700 Subject: [PATCH] R3964: fix GFP_KERNEL allocations in timer function In the error case, add_msg() gets called from timer functions, so should be using GFP_ATOMIC instead of GFP_KERNEL. Ref: http://bugzilla.kernel.org/show_bug.cgi?id=6659. Thanks to Christian Werner for reporting, and for the initial fix. Signed-off-by: David Woodhouse Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/n_r3964.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/char') diff --git a/drivers/char/n_r3964.c b/drivers/char/n_r3964.c index c48de09d68f..203dc2b661d 100644 --- a/drivers/char/n_r3964.c +++ b/drivers/char/n_r3964.c @@ -951,7 +951,8 @@ static void add_msg(struct r3964_client_info *pClient, int msg_id, int arg, { queue_the_message: - pMsg = kmalloc(sizeof(struct r3964_message), GFP_KERNEL); + pMsg = kmalloc(sizeof(struct r3964_message), + error_code?GFP_ATOMIC:GFP_KERNEL); TRACE_M("add_msg - kmalloc %p",pMsg); if(pMsg==NULL) { return; -- cgit v1.2.3-70-g09d2 From 969dd061d81d9e2bc7f954859452ac81cc639711 Mon Sep 17 00:00:00 2001 From: Eric Sesterhenn Date: Sun, 25 Jun 2006 05:48:45 -0700 Subject: [PATCH] Cyclades Cleanup coverity choked at two !tty checks, in places where tty can never be NULL. Since it removes some code we should remove these checks. (Coverity ids #763,#762) [akpm@osdl.org: even cleaner!] Signed-off-by: Eric Sesterhenn Acked-by: Alan Cox Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/cyclades.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c index cc7acf877dc..122e7a72a4e 100644 --- a/drivers/char/cyclades.c +++ b/drivers/char/cyclades.c @@ -2833,9 +2833,8 @@ cy_write(struct tty_struct * tty, const unsigned char *buf, int count) return 0; } - if (!tty || !info->xmit_buf || !tmp_buf){ - return 0; - } + if (!info->xmit_buf || !tmp_buf) + return 0; CY_LOCK(info, flags); while (1) { @@ -2884,7 +2883,7 @@ cy_put_char(struct tty_struct *tty, unsigned char ch) if (serial_paranoia_check(info, tty->name, "cy_put_char")) return; - if (!tty || !info->xmit_buf) + if (!info->xmit_buf) return; CY_LOCK(info, flags); -- cgit v1.2.3-70-g09d2 From a2f20c7c274b6241767330c902b3111b9326d901 Mon Sep 17 00:00:00 2001 From: Eric Sesterhenn Date: Sun, 25 Jun 2006 05:48:46 -0700 Subject: [PATCH] Clean up char/esp.c coverity choked at another two !tty checks, in places where tty can never be NULL. Since it removes some code we should remove these checks. (Coverity ids #763,#762) Signed-off-by Eric Sesterhenn Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/esp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/esp.c b/drivers/char/esp.c index 09dc4b01232..922174d527a 100644 --- a/drivers/char/esp.c +++ b/drivers/char/esp.c @@ -1212,7 +1212,7 @@ static void rs_put_char(struct tty_struct *tty, unsigned char ch) if (serial_paranoia_check(info, tty->name, "rs_put_char")) return; - if (!tty || !info->xmit_buf) + if (!info->xmit_buf) return; spin_lock_irqsave(&info->lock, flags); @@ -1256,7 +1256,7 @@ static int rs_write(struct tty_struct * tty, if (serial_paranoia_check(info, tty->name, "rs_write")) return 0; - if (!tty || !info->xmit_buf) + if (!info->xmit_buf) return 0; while (1) { -- cgit v1.2.3-70-g09d2 From 326f28e9ec4b2619c2fd410593fc95fcb0ba6b41 Mon Sep 17 00:00:00 2001 From: Eric Sesterhenn Date: Sun, 25 Jun 2006 05:48:48 -0700 Subject: [PATCH] More !tty cleanups in drivers/char Another bunch of checks in the char drivers .put_char() and .write() routines, where tty can never be NULL. This patch removes these checks to save some code. Coverity choked at those with the following bug ids: isicom.c 767, 766 specialix.c 773, 774 synclink_cs.c 779, 781 synclink_gt.c 784, 785 synclinkmp.c 784, 785 Signed-off-by: Eric Sesterhenn Cc: Paul Fulghum Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/isicom.c | 4 ++-- drivers/char/pcmcia/synclink_cs.c | 4 ++-- drivers/char/specialix.c | 4 ++-- drivers/char/synclink_gt.c | 4 ++-- drivers/char/synclinkmp.c | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/isicom.c b/drivers/char/isicom.c index e9ebabaf8cb..efaaa1937ab 100644 --- a/drivers/char/isicom.c +++ b/drivers/char/isicom.c @@ -1145,7 +1145,7 @@ static int isicom_write(struct tty_struct *tty, const unsigned char *buf, if (isicom_paranoia_check(port, tty->name, "isicom_write")) return 0; - if (!tty || !port->xmit_buf) + if (!port->xmit_buf) return 0; spin_lock_irqsave(&card->card_lock, flags); @@ -1180,7 +1180,7 @@ static void isicom_put_char(struct tty_struct *tty, unsigned char ch) if (isicom_paranoia_check(port, tty->name, "isicom_put_char")) return; - if (!tty || !port->xmit_buf) + if (!port->xmit_buf) return; spin_lock_irqsave(&card->card_lock, flags); diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index 0c141c295fb..17bc8abd5df 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c @@ -1582,7 +1582,7 @@ static void mgslpc_put_char(struct tty_struct *tty, unsigned char ch) if (mgslpc_paranoia_check(info, tty->name, "mgslpc_put_char")) return; - if (!tty || !info->tx_buf) + if (!info->tx_buf) return; spin_lock_irqsave(&info->lock,flags); @@ -1649,7 +1649,7 @@ static int mgslpc_write(struct tty_struct * tty, __FILE__,__LINE__,info->device_name,count); if (mgslpc_paranoia_check(info, tty->name, "mgslpc_write") || - !tty || !info->tx_buf) + !info->tx_buf) goto cleanup; if (info->params.mode == MGSL_MODE_HDLC) { diff --git a/drivers/char/specialix.c b/drivers/char/specialix.c index 5343e9fc6ab..1b5330299e3 100644 --- a/drivers/char/specialix.c +++ b/drivers/char/specialix.c @@ -1683,7 +1683,7 @@ static int sx_write(struct tty_struct * tty, bp = port_Board(port); - if (!tty || !port->xmit_buf || !tmp_buf) { + if (!port->xmit_buf || !tmp_buf) { func_exit(); return 0; } @@ -1733,7 +1733,7 @@ static void sx_put_char(struct tty_struct * tty, unsigned char ch) return; } dprintk (SX_DEBUG_TX, "check tty: %p %p\n", tty, port->xmit_buf); - if (!tty || !port->xmit_buf) { + if (!port->xmit_buf) { func_exit(); return; } diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c index b4d1f4eea43..b4f1a5a435a 100644 --- a/drivers/char/synclink_gt.c +++ b/drivers/char/synclink_gt.c @@ -870,7 +870,7 @@ static int write(struct tty_struct *tty, goto cleanup; DBGINFO(("%s write count=%d\n", info->device_name, count)); - if (!tty || !info->tx_buf) + if (!info->tx_buf) goto cleanup; if (count > info->max_frame_size) { @@ -924,7 +924,7 @@ static void put_char(struct tty_struct *tty, unsigned char ch) if (sanity_check(info, tty->name, "put_char")) return; DBGINFO(("%s put_char(%d)\n", info->device_name, ch)); - if (!tty || !info->tx_buf) + if (!info->tx_buf) return; spin_lock_irqsave(&info->lock,flags); if (!info->tx_active && (info->tx_count < info->max_frame_size)) diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c index 85874013111..21bf15ad998 100644 --- a/drivers/char/synclinkmp.c +++ b/drivers/char/synclinkmp.c @@ -988,7 +988,7 @@ static int write(struct tty_struct *tty, if (sanity_check(info, tty->name, "write")) goto cleanup; - if (!tty || !info->tx_buf) + if (!info->tx_buf) goto cleanup; if (info->params.mode == MGSL_MODE_HDLC) { @@ -1067,7 +1067,7 @@ static void put_char(struct tty_struct *tty, unsigned char ch) if (sanity_check(info, tty->name, "put_char")) return; - if (!tty || !info->tx_buf) + if (!info->tx_buf) return; spin_lock_irqsave(&info->lock,flags); -- cgit v1.2.3-70-g09d2 From 584e1236bbcdfec3f64c751908b8b4fe868c2d20 Mon Sep 17 00:00:00 2001 From: Yoichi Yuasa Date: Sun, 25 Jun 2006 05:49:11 -0700 Subject: [PATCH] add "select GPIO_VR41XX" for TANBAC_TB0229 TANBAC_TB0229 requires GPIO_VR41XX. This patch adds "select GPIO_VR41XX" for TANBAC_TB0229. Signed-off-by: Yoichi Yuasa Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/Kconfig | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/char') diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index 78d928f9d9f..63f28d169b3 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -865,6 +865,7 @@ config SONYPI config TANBAC_TB0219 tristate "TANBAC TB0219 base board support" depends TANBAC_TB022X + select GPIO_VR41XX menu "Ftape, the floppy tape device driver" -- cgit v1.2.3-70-g09d2 From cc44a817f65f9b4651643d334f6351b6d1f5e6c2 Mon Sep 17 00:00:00 2001 From: Paul Fulghum Date: Sun, 25 Jun 2006 05:49:12 -0700 Subject: [PATCH] fix memory leak in rocketport rp_do_receive Fix memory leak caused by incorrect use of tty buffer facility. tty buffers are allocated but never processed by call to tty_flip_buffer_push so they accumulate on the full buffer list. Current code uses the buffers as a temporary storage for data before passing it directly to the line discipline. Signed-off-by: Paul Fulghum Cc: Alan Cox Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/rocket.c | 62 +++++++++++++++++++-------------------------------- 1 file changed, 23 insertions(+), 39 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/rocket.c b/drivers/char/rocket.c index 7edc6a4dbdc..0708c5164c8 100644 --- a/drivers/char/rocket.c +++ b/drivers/char/rocket.c @@ -324,35 +324,15 @@ static void rp_do_receive(struct r_port *info, CHANNEL_t * cp, unsigned int ChanStatus) { unsigned int CharNStat; - int ToRecv, wRecv, space = 0, count; - unsigned char *cbuf, *chead; - char *fbuf, *fhead; - struct tty_ldisc *ld; - - ld = tty_ldisc_ref(tty); + int ToRecv, wRecv, space; + unsigned char *cbuf; ToRecv = sGetRxCnt(cp); - space = tty->receive_room; - if (space > 2 * TTY_FLIPBUF_SIZE) - space = 2 * TTY_FLIPBUF_SIZE; - count = 0; #ifdef ROCKET_DEBUG_INTR - printk(KERN_INFO "rp_do_receive(%d, %d)...", ToRecv, space); + printk(KERN_INFO "rp_do_receive(%d)...", ToRecv); #endif - - /* - * determine how many we can actually read in. If we can't - * read any in then we have a software overrun condition. - */ - if (ToRecv > space) - ToRecv = space; - - ToRecv = tty_prepare_flip_string_flags(tty, &chead, &fhead, ToRecv); - if (ToRecv <= 0) - goto done; - - cbuf = chead; - fbuf = fhead; + if (ToRecv == 0) + return; /* * if status indicates there are errored characters in the @@ -380,6 +360,8 @@ static void rp_do_receive(struct r_port *info, info->read_status_mask); #endif while (ToRecv) { + char flag; + CharNStat = sInW(sGetTxRxDataIO(cp)); #ifdef ROCKET_DEBUG_RECEIVE printk(KERN_INFO "%x...", CharNStat); @@ -392,17 +374,16 @@ static void rp_do_receive(struct r_port *info, } CharNStat &= info->read_status_mask; if (CharNStat & STMBREAKH) - *fbuf++ = TTY_BREAK; + flag = TTY_BREAK; else if (CharNStat & STMPARITYH) - *fbuf++ = TTY_PARITY; + flag = TTY_PARITY; else if (CharNStat & STMFRAMEH) - *fbuf++ = TTY_FRAME; + flag = TTY_FRAME; else if (CharNStat & STMRCVROVRH) - *fbuf++ = TTY_OVERRUN; + flag = TTY_OVERRUN; else - *fbuf++ = TTY_NORMAL; - *cbuf++ = CharNStat & 0xff; - count++; + flag = TTY_NORMAL; + tty_insert_flip_char(tty, CharNStat & 0xff, flag); ToRecv--; } @@ -422,20 +403,23 @@ static void rp_do_receive(struct r_port *info, * characters at time by doing repeated word IO * transfer. */ + space = tty_prepare_flip_string(tty, &cbuf, ToRecv); + if (space < ToRecv) { +#ifdef ROCKET_DEBUG_RECEIVE + printk(KERN_INFO "rp_do_receive:insufficient space ToRecv=%d space=%d\n", ToRecv, space); +#endif + if (space <= 0) + return; + ToRecv = space; + } wRecv = ToRecv >> 1; if (wRecv) sInStrW(sGetTxRxDataIO(cp), (unsigned short *) cbuf, wRecv); if (ToRecv & 1) cbuf[ToRecv - 1] = sInB(sGetTxRxDataIO(cp)); - memset(fbuf, TTY_NORMAL, ToRecv); - cbuf += ToRecv; - fbuf += ToRecv; - count += ToRecv; } /* Push the data up to the tty layer */ - ld->receive_buf(tty, chead, fhead, count); -done: - tty_ldisc_deref(ld); + tty_flip_buffer_push(tty); } /* -- cgit v1.2.3-70-g09d2 From 643f3319b9132c768081ce94f938a29139a16de9 Mon Sep 17 00:00:00 2001 From: Paul Fulghum Date: Sun, 25 Jun 2006 05:49:20 -0700 Subject: [PATCH] add synclink_gt custom hdlc idle Add custom HDLC idle pattern feature. It allows the user to specify an arbitrary 8 or 16 bit repeating pattern on the transmit data pin between HDLC frames. In most cases the idle pattern is continuous ones or flags as supported by off the shelf synchronous controllers and defined in the ISO3309 standard. Some applications (radio/satellite modems, connections to legacy military hardware) require non-standard patterns. Signed-off-by: Paul Fulghum Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/synclink_gt.c | 46 +++++++++++++++++++++++++++++++++------------- include/linux/synclink.h | 4 +++- 2 files changed, 36 insertions(+), 14 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c index b4f1a5a435a..6f93a0149fb 100644 --- a/drivers/char/synclink_gt.c +++ b/drivers/char/synclink_gt.c @@ -2515,7 +2515,8 @@ static int set_txidle(struct slgt_info *info, int idle_mode) DBGINFO(("%s set_txidle(%d)\n", info->device_name, idle_mode)); spin_lock_irqsave(&info->lock,flags); info->idle_mode = idle_mode; - tx_set_idle(info); + if (info->params.mode != MGSL_MODE_ASYNC) + tx_set_idle(info); spin_unlock_irqrestore(&info->lock,flags); return 0; } @@ -3940,8 +3941,6 @@ static void async_mode(struct slgt_info *info) msc_set_vcr(info); - tx_set_idle(info); - /* SCR (serial control) * * 15 1=tx req on FIFO half empty @@ -4175,17 +4174,38 @@ static void hdlc_mode(struct slgt_info *info) */ static void tx_set_idle(struct slgt_info *info) { - unsigned char val = 0xff; + unsigned char val; + unsigned short tcr; - switch(info->idle_mode) - { - case HDLC_TXIDLE_FLAGS: val = 0x7e; break; - case HDLC_TXIDLE_ALT_ZEROS_ONES: val = 0xaa; break; - case HDLC_TXIDLE_ZEROS: val = 0x00; break; - case HDLC_TXIDLE_ONES: val = 0xff; break; - case HDLC_TXIDLE_ALT_MARK_SPACE: val = 0xaa; break; - case HDLC_TXIDLE_SPACE: val = 0x00; break; - case HDLC_TXIDLE_MARK: val = 0xff; break; + /* if preamble enabled (tcr[6] == 1) then tx idle size = 8 bits + * else tcr[5:4] = tx idle size: 00 = 8 bits, 01 = 16 bits + */ + tcr = rd_reg16(info, TCR); + if (info->idle_mode & HDLC_TXIDLE_CUSTOM_16) { + /* disable preamble, set idle size to 16 bits */ + tcr = (tcr & ~(BIT6 + BIT5)) | BIT4; + /* MSB of 16 bit idle specified in tx preamble register (TPR) */ + wr_reg8(info, TPR, (unsigned char)((info->idle_mode >> 8) & 0xff)); + } else if (!(tcr & BIT6)) { + /* preamble is disabled, set idle size to 8 bits */ + tcr &= ~(BIT5 + BIT4); + } + wr_reg16(info, TCR, tcr); + + if (info->idle_mode & (HDLC_TXIDLE_CUSTOM_8 | HDLC_TXIDLE_CUSTOM_16)) { + /* LSB of custom tx idle specified in tx idle register */ + val = (unsigned char)(info->idle_mode & 0xff); + } else { + /* standard 8 bit idle patterns */ + switch(info->idle_mode) + { + case HDLC_TXIDLE_FLAGS: val = 0x7e; break; + case HDLC_TXIDLE_ALT_ZEROS_ONES: + case HDLC_TXIDLE_ALT_MARK_SPACE: val = 0xaa; break; + case HDLC_TXIDLE_ZEROS: + case HDLC_TXIDLE_SPACE: val = 0x00; break; + default: val = 0xff; + } } wr_reg8(info, TIR, val); diff --git a/include/linux/synclink.h b/include/linux/synclink.h index 2993302f792..b0e3535c38b 100644 --- a/include/linux/synclink.h +++ b/include/linux/synclink.h @@ -1,7 +1,7 @@ /* * SyncLink Multiprotocol Serial Adapter Driver * - * $Id: synclink.h,v 3.11 2006/02/06 21:20:29 paulkf Exp $ + * $Id: synclink.h,v 3.13 2006/05/23 18:25:06 paulkf Exp $ * * Copyright (C) 1998-2000 by Microgate Corporation * @@ -97,6 +97,8 @@ #define HDLC_TXIDLE_ALT_MARK_SPACE 4 #define HDLC_TXIDLE_SPACE 5 #define HDLC_TXIDLE_MARK 6 +#define HDLC_TXIDLE_CUSTOM_8 0x10000000 +#define HDLC_TXIDLE_CUSTOM_16 0x20000000 #define HDLC_ENCODING_NRZ 0 #define HDLC_ENCODING_NRZB 1 -- cgit v1.2.3-70-g09d2 From 04b374d0f5a97761b91a0c3ff6d10f80abd206b0 Mon Sep 17 00:00:00 2001 From: Paul Fulghum Date: Sun, 25 Jun 2006 05:49:21 -0700 Subject: [PATCH] add synclink_gt crc return feature Add ability to return HDLC CRC to user application. Signed-off-by: Paul Fulghum Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/synclink_gt.c | 55 +++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 22 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c index 6f93a0149fb..03a7f20db49 100644 --- a/drivers/char/synclink_gt.c +++ b/drivers/char/synclink_gt.c @@ -3077,7 +3077,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, static int alloc_tmp_rbuf(struct slgt_info *info) { - info->tmp_rbuf = kmalloc(info->max_frame_size, GFP_KERNEL); + info->tmp_rbuf = kmalloc(info->max_frame_size + 5, GFP_KERNEL); if (info->tmp_rbuf == NULL) return -ENOMEM; return 0; @@ -4011,7 +4011,7 @@ static void hdlc_mode(struct slgt_info *info) case HDLC_ENCODING_DIFF_BIPHASE_LEVEL: val |= BIT12 + BIT11 + BIT10; break; } - switch (info->params.crc_type) + switch (info->params.crc_type & HDLC_CRC_MASK) { case HDLC_CRC_16_CCITT: val |= BIT9; break; case HDLC_CRC_32_CCITT: val |= BIT9 + BIT8; break; @@ -4072,7 +4072,7 @@ static void hdlc_mode(struct slgt_info *info) case HDLC_ENCODING_DIFF_BIPHASE_LEVEL: val |= BIT12 + BIT11 + BIT10; break; } - switch (info->params.crc_type) + switch (info->params.crc_type & HDLC_CRC_MASK) { case HDLC_CRC_16_CCITT: val |= BIT9; break; case HDLC_CRC_32_CCITT: val |= BIT9 + BIT8; break; @@ -4333,6 +4333,12 @@ static int rx_get_frame(struct slgt_info *info) unsigned long flags; struct tty_struct *tty = info->tty; unsigned char addr_field = 0xff; + unsigned int crc_size = 0; + + switch (info->params.crc_type & HDLC_CRC_MASK) { + case HDLC_CRC_16_CCITT: crc_size = 2; break; + case HDLC_CRC_32_CCITT: crc_size = 4; break; + } check_again: @@ -4377,7 +4383,7 @@ check_again: status = desc_status(info->rbufs[end]); /* ignore CRC bit if not using CRC (bit is undefined) */ - if (info->params.crc_type == HDLC_CRC_NONE) + if ((info->params.crc_type & HDLC_CRC_MASK) == HDLC_CRC_NONE) status &= ~BIT1; if (framesize == 0 || @@ -4386,34 +4392,34 @@ check_again: goto check_again; } - if (framesize < 2 || status & (BIT1+BIT0)) { - if (framesize < 2 || (status & BIT0)) - info->icount.rxshort++; - else - info->icount.rxcrc++; + if (framesize < (2 + crc_size) || status & BIT0) { + info->icount.rxshort++; framesize = 0; + } else if (status & BIT1) { + info->icount.rxcrc++; + if (!(info->params.crc_type & HDLC_CRC_RETURN_EX)) + framesize = 0; + } #ifdef CONFIG_HDLC - { - struct net_device_stats *stats = hdlc_stats(info->netdev); - stats->rx_errors++; - stats->rx_frame_errors++; - } -#endif - } else { - /* adjust frame size for CRC, if any */ - if (info->params.crc_type == HDLC_CRC_16_CCITT) - framesize -= 2; - else if (info->params.crc_type == HDLC_CRC_32_CCITT) - framesize -= 4; + if (framesize == 0) { + struct net_device_stats *stats = hdlc_stats(info->netdev); + stats->rx_errors++; + stats->rx_frame_errors++; } +#endif DBGBH(("%s rx frame status=%04X size=%d\n", info->device_name, status, framesize)); DBGDATA(info, info->rbufs[start].buf, min_t(int, framesize, DMABUFSIZE), "rx"); if (framesize) { - if (framesize > info->max_frame_size) + if (!(info->params.crc_type & HDLC_CRC_RETURN_EX)) { + framesize -= crc_size; + crc_size = 0; + } + + if (framesize > info->max_frame_size + crc_size) info->icount.rxlong++; else { /* copy dma buffer(s) to contiguous temp buffer */ @@ -4433,6 +4439,11 @@ check_again: i = 0; } + if (info->params.crc_type & HDLC_CRC_RETURN_EX) { + *p = (status & BIT1) ? RX_CRC_ERROR : RX_OK; + framesize++; + } + #ifdef CONFIG_HDLC if (info->netcount) hdlcdev_rx(info,info->tmp_rbuf, framesize); -- cgit v1.2.3-70-g09d2 From 294dad05311416718c2a172738e1ca4071449877 Mon Sep 17 00:00:00 2001 From: Paul Fulghum Date: Sun, 25 Jun 2006 05:49:21 -0700 Subject: [PATCH] fix synclink_gt diagnostics error reporting Fix diagnostics error reporting that was being overwritten by incorrect use of return codes from individual diagnostic functions. Signed-off-by: Paul Fulghum Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/synclink_gt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c index 03a7f20db49..41eab9831ad 100644 --- a/drivers/char/synclink_gt.c +++ b/drivers/char/synclink_gt.c @@ -4702,13 +4702,13 @@ static int loopback_test(struct slgt_info *info) static int adapter_test(struct slgt_info *info) { DBGINFO(("testing %s\n", info->device_name)); - if ((info->init_error = register_test(info)) < 0) { + if (register_test(info) < 0) { printk("register test failure %s addr=%08X\n", info->device_name, info->phys_reg_addr); - } else if ((info->init_error = irq_test(info)) < 0) { + } else if (irq_test(info) < 0) { printk("IRQ test failure %s IRQ=%d\n", info->device_name, info->irq_level); - } else if ((info->init_error = loopback_test(info)) < 0) { + } else if (loopback_test(info) < 0) { printk("loopback test failure %s\n", info->device_name); } return info->init_error; -- cgit v1.2.3-70-g09d2 From 6f84be84b4cde72fa2a2f0d10ac284a31e923200 Mon Sep 17 00:00:00 2001 From: Paul Fulghum Date: Sun, 25 Jun 2006 05:49:22 -0700 Subject: [PATCH] synclink_gt: add GT2 adapter support Add support for SyncLink GT2 adapter to driver. Signed-off-by: Paul Fulghum Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/synclink_gt.c | 8 +++++++- include/linux/synclink.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'drivers/char') diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c index 41eab9831ad..4e35d418122 100644 --- a/drivers/char/synclink_gt.c +++ b/drivers/char/synclink_gt.c @@ -101,6 +101,7 @@ MODULE_LICENSE("GPL"); static struct pci_device_id pci_table[] = { {PCI_VENDOR_ID_MICROGATE, SYNCLINK_GT_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, + {PCI_VENDOR_ID_MICROGATE, SYNCLINK_GT2_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, {PCI_VENDOR_ID_MICROGATE, SYNCLINK_GT4_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, {PCI_VENDOR_ID_MICROGATE, SYNCLINK_AC_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, {0,}, /* terminate list */ @@ -3277,6 +3278,9 @@ static void add_device(struct slgt_info *info) case SYNCLINK_GT_DEVICE_ID: devstr = "GT"; break; + case SYNCLINK_GT2_DEVICE_ID: + devstr = "GT2"; + break; case SYNCLINK_GT4_DEVICE_ID: devstr = "GT4"; break; @@ -3354,7 +3358,9 @@ static void device_init(int adapter_num, struct pci_dev *pdev) int i; int port_count = 1; - if (pdev->device == SYNCLINK_GT4_DEVICE_ID) + if (pdev->device == SYNCLINK_GT2_DEVICE_ID) + port_count = 2; + else if (pdev->device == SYNCLINK_GT4_DEVICE_ID) port_count = 4; /* allocate device instances for all ports */ diff --git a/include/linux/synclink.h b/include/linux/synclink.h index b0e3535c38b..0577f5284cb 100644 --- a/include/linux/synclink.h +++ b/include/linux/synclink.h @@ -172,6 +172,7 @@ typedef struct _MGSL_PARAMS #define SYNCLINK_GT_DEVICE_ID 0x0070 #define SYNCLINK_GT4_DEVICE_ID 0x0080 #define SYNCLINK_AC_DEVICE_ID 0x0090 +#define SYNCLINK_GT2_DEVICE_ID 0x00A0 #define MGSL_MAX_SERIAL_NUMBER 30 /* -- cgit v1.2.3-70-g09d2 From b9ab58dd8e771d30df110c56e785db1ae5e073df Mon Sep 17 00:00:00 2001 From: Jerome Pinot Date: Mon, 26 Jun 2006 01:51:23 -0400 Subject: Input: fix misspelling of Hangeul key Fix a mispelling of the korean alphabet name in the input subsystem. See http://en.wikipedia.org/wiki/Hangeul#Names for more details. KEY_HANGUEL left to not break people Signed-off-by: Jerome Pinot Signed-off-by: Dmitry Torokhov --- drivers/char/keyboard.c | 2 +- drivers/input/keyboard/atkbd.c | 8 ++++---- drivers/macintosh/adbhid.c | 2 +- drivers/usb/input/hid-debug.h | 2 +- include/linux/input.h | 3 ++- 5 files changed, 9 insertions(+), 8 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c index 1b63acfc6c7..d82368bc46d 100644 --- a/drivers/char/keyboard.c +++ b/drivers/char/keyboard.c @@ -1074,7 +1074,7 @@ static int emulate_raw(struct vc_data *vc, unsigned int keycode, 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: diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c index 0eb955ddc65..1bf61f00cbd 100644 --- a/drivers/input/keyboard/atkbd.c +++ b/drivers/input/keyboard/atkbd.c @@ -150,7 +150,7 @@ static unsigned char atkbd_unxlate_table[128] = { #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(struct serio *serio, unsigned char data, 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(struct serio *serio, unsigned char data, 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); diff --git a/drivers/macintosh/adbhid.c b/drivers/macintosh/adbhid.c index c26e1236b27..cbfbbe2b150 100644 --- 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 */ diff --git a/drivers/usb/input/hid-debug.h b/drivers/usb/input/hid-debug.h index 702c48c2f81..f04d6d75c09 100644 --- 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_HANGUEL] = "Hangeul", [KEY_HANJA] = "Hanja", [KEY_YEN] = "Yen", [KEY_LEFTMETA] = "LeftMeta", [KEY_RIGHTMETA] = "RightMeta", [KEY_COMPOSE] = "Compose", [KEY_STOP] = "Stop", [KEY_AGAIN] = "Again", diff --git a/include/linux/input.h b/include/linux/input.h index 8d2b874d9e7..56f1e0e1e59 100644 --- a/include/linux/input.h +++ b/include/linux/input.h @@ -232,7 +232,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 -- cgit v1.2.3-70-g09d2 From 0ae051a19092d36112b5ba60ff8b5df7a5d5d23b Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Mon, 26 Jun 2006 01:52:34 -0400 Subject: Input: atkbd - fix HANGEUL/HANJA keys Make atkbd report HANGEUL/HANJA keys by default and use correct scan codes for these keys (they were swapped). Also make sure their scancodes reported as EV_MSC/MSC_SCAN events. Signed-off-by: Dmitry Torokhov --- drivers/char/keyboard.c | 6 +- drivers/input/keyboard/atkbd.c | 208 ++++++++++++++++++++++++++--------------- 2 files changed, 135 insertions(+), 79 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c index d82368bc46d..6cb85dcbbc8 100644 --- a/drivers/char/keyboard.c +++ b/drivers/char/keyboard.c @@ -1075,10 +1075,12 @@ static int emulate_raw(struct vc_data *vc, unsigned int keycode, put_queue(vc, 0x45 | up_flag); return 0; case KEY_HANGEUL: - if (!up_flag) put_queue(vc, 0xf1); + if (!up_flag) + put_queue(vc, 0xf2); return 0; case KEY_HANJA: - if (!up_flag) put_queue(vc, 0xf2); + if (!up_flag) + put_queue(vc, 0xf1); return 0; } diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c index 1bf61f00cbd..ffde8f86e0f 100644 --- a/drivers/input/keyboard/atkbd.c +++ b/drivers/input/keyboard/atkbd.c @@ -55,7 +55,7 @@ static int atkbd_softraw = 1; module_param_named(softraw, atkbd_softraw, bool, 0); MODULE_PARM_DESC(softraw, "Use software generated rawmode"); -static int atkbd_scroll = 0; +static int atkbd_scroll; module_param_named(scroll, atkbd_scroll, bool, 0); MODULE_PARM_DESC(scroll, "Enable scroll-wheel on MS Office and similar keyboards"); @@ -150,8 +150,8 @@ static unsigned char atkbd_unxlate_table[128] = { #define ATKBD_RET_EMUL0 0xe0 #define ATKBD_RET_EMUL1 0xe1 #define ATKBD_RET_RELEASE 0xf0 -#define ATKBD_RET_HANGEUL 0xf1 -#define ATKBD_RET_HANJA 0xf2 +#define ATKBD_RET_HANJA 0xf1 +#define ATKBD_RET_HANGEUL 0xf2 #define ATKBD_RET_ERR 0xff #define ATKBD_KEY_UNKNOWN 0 @@ -170,6 +170,13 @@ static unsigned char atkbd_unxlate_table[128] = { #define ATKBD_LED_EVENT_BIT 0 #define ATKBD_REP_EVENT_BIT 1 +#define ATKBD_XL_ERR 0x01 +#define ATKBD_XL_BAT 0x02 +#define ATKBD_XL_ACK 0x04 +#define ATKBD_XL_NAK 0x08 +#define ATKBD_XL_HANGEUL 0x10 +#define ATKBD_XL_HANJA 0x20 + static struct { unsigned char keycode; unsigned char set2; @@ -211,8 +218,7 @@ struct atkbd { unsigned char emul; unsigned char resend; unsigned char release; - unsigned char bat_xl; - unsigned char err_xl; + unsigned long xl_bit; unsigned int last; unsigned long time; @@ -245,17 +251,65 @@ ATKBD_DEFINE_ATTR(set); ATKBD_DEFINE_ATTR(softrepeat); ATKBD_DEFINE_ATTR(softraw); +static const unsigned int xl_table[] = { + ATKBD_RET_BAT, ATKBD_RET_ERR, ATKBD_RET_ACK, + ATKBD_RET_NAK, ATKBD_RET_HANJA, ATKBD_RET_HANGEUL, +}; -static void atkbd_report_key(struct input_dev *dev, struct pt_regs *regs, int code, int value) +/* + * Checks if we should mangle the scancode to extract 'release' bit + * in translated mode. + */ +static int atkbd_need_xlate(unsigned long xl_bit, unsigned char code) { - input_regs(dev, regs); - if (value == 3) { - input_report_key(dev, code, 1); - input_sync(dev); - input_report_key(dev, code, 0); - } else - input_event(dev, EV_KEY, code, value); - input_sync(dev); + int i; + + if (code == ATKBD_RET_EMUL0 || code == ATKBD_RET_EMUL1) + return 0; + + for (i = 0; i < ARRAY_SIZE(xl_table); i++) + if (code == xl_table[i]) + return test_bit(i, &xl_bit); + + return 1; +} + +/* + * Calculates new value of xl_bit so the driver can distinguish + * between make/break pair of scancodes for select keys and PS/2 + * protocol responses. + */ +static void atkbd_calculate_xl_bit(struct atkbd *atkbd, unsigned char code) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(xl_table); i++) { + if (!((code ^ xl_table[i]) & 0x7f)) { + if (code & 0x80) + __clear_bit(i, &atkbd->xl_bit); + else + __set_bit(i, &atkbd->xl_bit); + break; + } + } +} + +/* + * Encode the scancode, 0xe0 prefix, and high bit into a single integer, + * keeping kernel 2.4 compatibility for set 2 + */ +static unsigned int atkbd_compat_scancode(struct atkbd *atkbd, unsigned int code) +{ + if (atkbd->set == 3) { + if (atkbd->emul == 1) + code |= 0x100; + } else { + code = (code & 0x7f) | ((code & 0x80) << 1); + if (atkbd->emul == 1) + code |= 0x80; + } + + return code; } /* @@ -267,9 +321,11 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, unsigned int flags, struct pt_regs *regs) { struct atkbd *atkbd = serio_get_drvdata(serio); + struct input_dev *dev = atkbd->dev; unsigned int code = data; - int scroll = 0, hscroll = 0, click = -1; + int scroll = 0, hscroll = 0, click = -1, add_release_event = 0; int value; + unsigned char keycode; #ifdef ATKBD_DEBUG printk(KERN_DEBUG "atkbd.c: Received %02x flags %02x\n", data, flags); @@ -298,25 +354,17 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, if (!atkbd->enabled) goto out; - input_event(atkbd->dev, EV_MSC, MSC_RAW, code); + input_event(dev, EV_MSC, MSC_RAW, code); if (atkbd->translated) { - if (atkbd->emul || - (code != ATKBD_RET_EMUL0 && code != ATKBD_RET_EMUL1 && - code != ATKBD_RET_HANGEUL && code != ATKBD_RET_HANJA && - (code != ATKBD_RET_ERR || atkbd->err_xl) && - (code != ATKBD_RET_BAT || atkbd->bat_xl))) { + if (atkbd->emul || atkbd_need_xlate(atkbd->xl_bit, code)) { atkbd->release = code >> 7; code &= 0x7f; } - if (!atkbd->emul) { - if ((code & 0x7f) == (ATKBD_RET_BAT & 0x7f)) - atkbd->bat_xl = !(data >> 7); - if ((code & 0x7f) == (ATKBD_RET_ERR & 0x7f)) - atkbd->err_xl = !(data >> 7); - } + if (!atkbd->emul) + atkbd_calculate_xl_bit(atkbd, data); } switch (code) { @@ -333,47 +381,48 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, case ATKBD_RET_RELEASE: atkbd->release = 1; goto out; - case ATKBD_RET_HANGEUL: - atkbd_report_key(atkbd->dev, regs, KEY_HANGEUL, 3); + case ATKBD_RET_ACK: + case ATKBD_RET_NAK: + printk(KERN_WARNING "atkbd.c: Spurious %s on %s. " + "Some program might be trying access hardware directly.\n", + data == ATKBD_RET_ACK ? "ACK" : "NAK", serio->phys); goto out; + case ATKBD_RET_HANGEUL: case ATKBD_RET_HANJA: - atkbd_report_key(atkbd->dev, regs, KEY_HANJA, 3); - goto out; + /* + * These keys do not report release and thus need to be + * flagged properly + */ + add_release_event = 1; + break; case ATKBD_RET_ERR: printk(KERN_DEBUG "atkbd.c: Keyboard on %s reports too many keys pressed.\n", serio->phys); goto out; } - if (atkbd->set != 3) - code = (code & 0x7f) | ((code & 0x80) << 1); - if (atkbd->emul) { - if (--atkbd->emul) - goto out; - code |= (atkbd->set != 3) ? 0x80 : 0x100; - } + code = atkbd_compat_scancode(atkbd, code); + + if (atkbd->emul && --atkbd->emul) + goto out; + + keycode = atkbd->keycode[code]; - if (atkbd->keycode[code] != ATKBD_KEY_NULL) - input_event(atkbd->dev, EV_MSC, MSC_SCAN, code); + if (keycode != ATKBD_KEY_NULL) + input_event(dev, EV_MSC, MSC_SCAN, code); - switch (atkbd->keycode[code]) { + switch (keycode) { case ATKBD_KEY_NULL: break; case ATKBD_KEY_UNKNOWN: - if (data == ATKBD_RET_ACK || data == ATKBD_RET_NAK) { - printk(KERN_WARNING "atkbd.c: Spurious %s on %s. Some program, " - "like XFree86, might be trying access hardware directly.\n", - data == ATKBD_RET_ACK ? "ACK" : "NAK", serio->phys); - } else { - printk(KERN_WARNING "atkbd.c: Unknown key %s " - "(%s set %d, code %#x on %s).\n", - atkbd->release ? "released" : "pressed", - atkbd->translated ? "translated" : "raw", - atkbd->set, code, serio->phys); - printk(KERN_WARNING "atkbd.c: Use 'setkeycodes %s%02x ' " - "to make it known.\n", - code & 0x80 ? "e0" : "", code & 0x7f); - } - input_sync(atkbd->dev); + printk(KERN_WARNING + "atkbd.c: Unknown key %s (%s set %d, code %#x on %s).\n", + atkbd->release ? "released" : "pressed", + atkbd->translated ? "translated" : "raw", + atkbd->set, code, serio->phys); + printk(KERN_WARNING + "atkbd.c: Use 'setkeycodes %s%02x ' to make it known.\n", + code & 0x80 ? "e0" : "", code & 0x7f); + input_sync(dev); break; case ATKBD_SCR_1: scroll = 1 - atkbd->release * 2; @@ -397,33 +446,35 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, hscroll = 1; break; default: - value = atkbd->release ? 0 : - (1 + (!atkbd->softrepeat && test_bit(atkbd->keycode[code], atkbd->dev->key))); - - switch (value) { /* Workaround Toshiba laptop multiple keypress */ - case 0: - atkbd->last = 0; - break; - case 1: - atkbd->last = code; - atkbd->time = jiffies + msecs_to_jiffies(atkbd->dev->rep[REP_DELAY]) / 2; - break; - case 2: - if (!time_after(jiffies, atkbd->time) && atkbd->last == code) - value = 1; - break; + if (atkbd->release) { + value = 0; + atkbd->last = 0; + } else if (!atkbd->softrepeat && test_bit(keycode, dev->key)) { + /* Workaround Toshiba laptop multiple keypress */ + value = time_before(jiffies, atkbd->time) && atkbd->last == code ? 1 : 2; + } else { + value = 1; + atkbd->last = code; + atkbd->time = jiffies + msecs_to_jiffies(dev->rep[REP_DELAY]) / 2; } - atkbd_report_key(atkbd->dev, regs, atkbd->keycode[code], value); + input_regs(dev, regs); + input_report_key(dev, keycode, value); + input_sync(dev); + + if (value && add_release_event) { + input_report_key(dev, keycode, 0); + input_sync(dev); + } } if (atkbd->scroll) { - input_regs(atkbd->dev, regs); + input_regs(dev, regs); if (click != -1) - input_report_key(atkbd->dev, BTN_MIDDLE, click); - input_report_rel(atkbd->dev, REL_WHEEL, scroll); - input_report_rel(atkbd->dev, REL_HWHEEL, hscroll); - input_sync(atkbd->dev); + input_report_key(dev, BTN_MIDDLE, click); + input_report_rel(dev, REL_WHEEL, scroll); + input_report_rel(dev, REL_HWHEEL, hscroll); + input_sync(dev); } atkbd->release = 0; @@ -764,6 +815,9 @@ static void atkbd_set_keycode_table(struct atkbd *atkbd) for (i = 0; i < ARRAY_SIZE(atkbd_scroll_keys); i++) atkbd->keycode[atkbd_scroll_keys[i].set2] = atkbd_scroll_keys[i].keycode; } + + atkbd->keycode[atkbd_compat_scancode(atkbd, ATKBD_RET_HANGEUL)] = KEY_HANGUEL; + atkbd->keycode[atkbd_compat_scancode(atkbd, ATKBD_RET_HANJA)] = KEY_HANJA; } /* -- cgit v1.2.3-70-g09d2 From f18190bd3407554ba6df30a1927e07e6cba93e56 Mon Sep 17 00:00:00 2001 From: Lee Revell Date: Mon, 26 Jun 2006 18:30:00 +0200 Subject: fix paniced->panicked typos In a testament to the utter simplicity and logic of the English language ;-), I found a single correct use - in kernel/panic.c - and 10-15 incorrect ones. Signed-Off-By: Lee Revell Signed-off-by: Adrian Bunk --- Documentation/kdump/gdbmacros.txt | 2 +- arch/i386/kernel/crash.c | 2 +- arch/mips/sgi-ip22/ip22-reset.c | 2 +- arch/mips/sgi-ip32/ip32-reset.c | 12 ++++++------ arch/powerpc/kernel/crash.c | 2 +- arch/x86_64/kernel/crash.c | 2 +- arch/x86_64/kernel/smp.c | 2 +- drivers/char/ipmi/ipmi_msghandler.c | 6 +++--- 8 files changed, 15 insertions(+), 15 deletions(-) (limited to 'drivers/char') diff --git a/Documentation/kdump/gdbmacros.txt b/Documentation/kdump/gdbmacros.txt index dcf5580380a..9b9b454b048 100644 --- a/Documentation/kdump/gdbmacros.txt +++ b/Documentation/kdump/gdbmacros.txt @@ -175,7 +175,7 @@ end document trapinfo Run info threads and lookup pid of thread #1 'trapinfo ' will tell you by which trap & possibly - addresthe kernel paniced. + address the kernel panicked. end diff --git a/arch/i386/kernel/crash.c b/arch/i386/kernel/crash.c index 21dc1bbb806..13288d9793a 100644 --- a/arch/i386/kernel/crash.c +++ b/arch/i386/kernel/crash.c @@ -163,7 +163,7 @@ static void nmi_shootdown_cpus(void) void machine_crash_shutdown(struct pt_regs *regs) { /* This function is only called after the system - * has paniced or is otherwise in a critical state. + * has panicked or is otherwise in a critical state. * The minimum amount of code to allow a kexec'd kernel * to run successfully needs to happen here. * diff --git a/arch/mips/sgi-ip22/ip22-reset.c b/arch/mips/sgi-ip22/ip22-reset.c index a9c58e067b5..8134220ed60 100644 --- a/arch/mips/sgi-ip22/ip22-reset.c +++ b/arch/mips/sgi-ip22/ip22-reset.c @@ -34,7 +34,7 @@ #define POWERDOWN_TIMEOUT 120 /* - * Blink frequency during reboot grace period and when paniced. + * Blink frequency during reboot grace period and when panicked. */ #define POWERDOWN_FREQ (HZ / 4) #define PANIC_FREQ (HZ / 8) diff --git a/arch/mips/sgi-ip32/ip32-reset.c b/arch/mips/sgi-ip32/ip32-reset.c index ab9d9cef089..79ddb460565 100644 --- a/arch/mips/sgi-ip32/ip32-reset.c +++ b/arch/mips/sgi-ip32/ip32-reset.c @@ -28,13 +28,13 @@ #define POWERDOWN_TIMEOUT 120 /* - * Blink frequency during reboot grace period and when paniced. + * Blink frequency during reboot grace period and when panicked. */ #define POWERDOWN_FREQ (HZ / 4) #define PANIC_FREQ (HZ / 8) static struct timer_list power_timer, blink_timer, debounce_timer; -static int has_paniced, shuting_down; +static int has_panicked, shuting_down; static void ip32_machine_restart(char *command) __attribute__((noreturn)); static void ip32_machine_halt(void) __attribute__((noreturn)); @@ -109,7 +109,7 @@ static void debounce(unsigned long data) } CMOS_WRITE(reg_a & ~DS_REGA_DV0, RTC_REG_A); - if (has_paniced) + if (has_panicked) ip32_machine_restart(NULL); enable_irq(MACEISA_RTC_IRQ); @@ -117,7 +117,7 @@ static void debounce(unsigned long data) static inline void ip32_power_button(void) { - if (has_paniced) + if (has_panicked) return; if (shuting_down || kill_proc(1, SIGINT, 1)) { @@ -161,9 +161,9 @@ static int panic_event(struct notifier_block *this, unsigned long event, { unsigned long led; - if (has_paniced) + if (has_panicked) return NOTIFY_DONE; - has_paniced = 1; + has_panicked = 1; /* turn off the green LED */ led = mace->perif.ctrl.misc | MACEISA_LED_GREEN; diff --git a/arch/powerpc/kernel/crash.c b/arch/powerpc/kernel/crash.c index dbcb85994f4..e253a45dcf1 100644 --- a/arch/powerpc/kernel/crash.c +++ b/arch/powerpc/kernel/crash.c @@ -179,7 +179,7 @@ void default_machine_crash_shutdown(struct pt_regs *regs) /* * This function is only called after the system - * has paniced or is otherwise in a critical state. + * has panicked or is otherwise in a critical state. * The minimum amount of code to allow a kexec'd kernel * to run successfully needs to happen here. * diff --git a/arch/x86_64/kernel/crash.c b/arch/x86_64/kernel/crash.c index 4e6c3b729e3..15beddc7fdf 100644 --- a/arch/x86_64/kernel/crash.c +++ b/arch/x86_64/kernel/crash.c @@ -161,7 +161,7 @@ void machine_crash_shutdown(struct pt_regs *regs) { /* * This function is only called after the system - * has paniced or is otherwise in a critical state. + * has panicked or is otherwise in a critical state. * The minimum amount of code to allow a kexec'd kernel * to run successfully needs to happen here. * diff --git a/arch/x86_64/kernel/smp.c b/arch/x86_64/kernel/smp.c index 4a6628b14d9..e369a3426df 100644 --- a/arch/x86_64/kernel/smp.c +++ b/arch/x86_64/kernel/smp.c @@ -470,7 +470,7 @@ void smp_send_stop(void) return; /* Don't deadlock on the call lock in panic */ if (!spin_trylock(&call_lock)) { - /* ignore locking because we have paniced anyways */ + /* ignore locking because we have panicked anyways */ nolock = 1; } __smp_call_function(smp_really_stop_cpu, NULL, 0, 0); diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c index 9f2f8fdec69..586f1f81937 100644 --- a/drivers/char/ipmi/ipmi_msghandler.c +++ b/drivers/char/ipmi/ipmi_msghandler.c @@ -3677,7 +3677,7 @@ static void send_panic_events(char *str) } #endif /* CONFIG_IPMI_PANIC_EVENT */ -static int has_paniced = 0; +static int has_panicked = 0; static int panic_event(struct notifier_block *this, unsigned long event, @@ -3686,9 +3686,9 @@ static int panic_event(struct notifier_block *this, int i; ipmi_smi_t intf; - if (has_paniced) + if (has_panicked) return NOTIFY_DONE; - has_paniced = 1; + has_panicked = 1; /* For every registered interface, set it to run to completion. */ for (i = 0; i < MAX_IPMI_INTERFACES; i++) { -- cgit v1.2.3-70-g09d2 From d6e05edc59ecd79e8badf440c0d295a979bdfa3e Mon Sep 17 00:00:00 2001 From: Andreas Mohr Date: Mon, 26 Jun 2006 18:35:02 +0200 Subject: spelling fixes acquired (aquired) contiguous (contigious) successful (succesful, succesfull) surprise (suprise) whether (weather) some other misspellings Signed-off-by: Andreas Mohr Signed-off-by: Adrian Bunk --- arch/i386/kernel/cpu/cyrix.c | 2 +- arch/i386/kernel/i8259.c | 2 +- arch/mips/momentum/ocelot_g/gt-irq.c | 4 ++-- arch/powerpc/platforms/cell/spufs/switch.c | 2 +- arch/powerpc/platforms/pseries/eeh_cache.c | 2 +- arch/s390/kernel/vtime.c | 2 +- arch/um/drivers/ubd_kern.c | 2 +- arch/x86_64/kernel/i8259.c | 2 +- block/as-iosched.c | 2 +- block/ll_rw_blk.c | 4 ++-- drivers/atm/firestream.c | 2 +- drivers/char/agp/amd-k7-agp.c | 2 +- drivers/char/agp/ati-agp.c | 2 +- drivers/char/agp/efficeon-agp.c | 2 +- drivers/char/rio/riointr.c | 2 +- drivers/hwmon/asb100.c | 2 +- drivers/hwmon/lm78.c | 2 +- drivers/hwmon/lm80.c | 2 +- drivers/hwmon/lm87.c | 2 +- drivers/hwmon/sis5595.c | 2 +- drivers/hwmon/smsc47m1.c | 2 +- drivers/hwmon/w83627hf.c | 2 +- drivers/hwmon/w83781d.c | 2 +- drivers/hwmon/w83792d.c | 2 +- drivers/ide/ide-disk.c | 2 +- drivers/ide/ide-io.c | 2 +- drivers/ieee1394/hosts.c | 2 +- drivers/ieee1394/ieee1394_core.h | 2 +- drivers/isdn/divert/isdn_divert.c | 2 +- drivers/media/video/bt8xx/bttv-cards.c | 2 +- drivers/net/3c501.c | 4 ++-- drivers/net/irda/irport.c | 2 +- drivers/net/pcmcia/smc91c92_cs.c | 2 +- drivers/net/wireless/ipw2100.c | 2 +- drivers/pci/pci.c | 2 +- drivers/s390/scsi/zfcp_erp.c | 14 +++++++------- drivers/scsi/NCR5380.c | 2 +- drivers/scsi/advansys.c | 2 +- drivers/scsi/dc395x.c | 2 +- drivers/scsi/ibmmca.c | 8 ++++---- drivers/scsi/ips.c | 4 ++-- drivers/scsi/st.c | 2 +- fs/9p/mux.c | 2 +- fs/aio.c | 2 +- fs/jffs2/summary.c | 2 +- fs/jfs/jfs_extent.c | 8 ++++---- include/asm-i386/system.h | 2 +- include/asm-m32r/system.h | 2 +- include/linux/sunrpc/gss_api.h | 2 +- lib/kernel_lock.c | 4 ++-- mm/page_alloc.c | 2 +- mm/readahead.c | 4 ++-- net/sunrpc/auth_gss/gss_krb5_mech.c | 2 +- net/sunrpc/auth_gss/gss_spkm3_mech.c | 2 +- sound/core/seq/seq_memory.h | 2 +- sound/oss/sb_ess.c | 28 ++++++++++++++-------------- sound/pci/cs5535audio/cs5535audio_pcm.c | 2 +- 57 files changed, 88 insertions(+), 88 deletions(-) (limited to 'drivers/char') diff --git a/arch/i386/kernel/cpu/cyrix.c b/arch/i386/kernel/cpu/cyrix.c index fc32c8028e2..f03b7f94c30 100644 --- a/arch/i386/kernel/cpu/cyrix.c +++ b/arch/i386/kernel/cpu/cyrix.c @@ -354,7 +354,7 @@ static void __init init_nsc(struct cpuinfo_x86 *c) * This function only handles the GX processor, and kicks every * thing else to the Cyrix init function above - that should * cover any processors that might have been branded differently - * after NSC aquired Cyrix. + * after NSC acquired Cyrix. * * If this breaks your GX1 horribly, please e-mail * info-linux@ldcmail.amd.com to tell us. diff --git a/arch/i386/kernel/i8259.c b/arch/i386/kernel/i8259.c index b7636b96e10..c1a42feba28 100644 --- a/arch/i386/kernel/i8259.c +++ b/arch/i386/kernel/i8259.c @@ -175,7 +175,7 @@ static void mask_and_ack_8259A(unsigned int irq) * Lightweight spurious IRQ detection. We do not want * to overdo spurious IRQ handling - it's usually a sign * of hardware problems, so we only do the checks we can - * do without slowing down good hardware unnecesserily. + * do without slowing down good hardware unnecessarily. * * Note that IRQ7 and IRQ15 (the two spurious IRQs * usually resulting from the 8259A-1|2 PICs) occur diff --git a/arch/mips/momentum/ocelot_g/gt-irq.c b/arch/mips/momentum/ocelot_g/gt-irq.c index e5eceed1bef..8bd9b844fa9 100644 --- a/arch/mips/momentum/ocelot_g/gt-irq.c +++ b/arch/mips/momentum/ocelot_g/gt-irq.c @@ -59,7 +59,7 @@ void hook_irq_handler(int int_cause, int bit_num, void *isr_ptr) * bit_num - Indicates which bit number in the cause register * * Outputs : - * 1 if succesful, 0 if failure + * 1 if successful, 0 if failure */ int enable_galileo_irq(int int_cause, int bit_num) { @@ -83,7 +83,7 @@ int enable_galileo_irq(int int_cause, int bit_num) * bit_num - Indicates which bit number in the cause register * * Outputs : - * 1 if succesful, 0 if failure + * 1 if successful, 0 if failure */ int disable_galileo_irq(int int_cause, int bit_num) { diff --git a/arch/powerpc/platforms/cell/spufs/switch.c b/arch/powerpc/platforms/cell/spufs/switch.c index b30e55dab83..3068b429b03 100644 --- a/arch/powerpc/platforms/cell/spufs/switch.c +++ b/arch/powerpc/platforms/cell/spufs/switch.c @@ -2100,7 +2100,7 @@ EXPORT_SYMBOL_GPL(spu_save); * @spu: pointer to SPU iomem structure. * * Perform harvest + restore, as we may not be coming - * from a previous succesful save operation, and the + * from a previous successful save operation, and the * hardware state is unknown. */ int spu_restore(struct spu_state *new, struct spu *spu) diff --git a/arch/powerpc/platforms/pseries/eeh_cache.c b/arch/powerpc/platforms/pseries/eeh_cache.c index 98c23aec85b..c37a8497c60 100644 --- a/arch/powerpc/platforms/pseries/eeh_cache.c +++ b/arch/powerpc/platforms/pseries/eeh_cache.c @@ -287,7 +287,7 @@ void pci_addr_cache_remove_device(struct pci_dev *dev) * find the pci device that corresponds to a given address. * This routine scans all pci busses to build the cache. * Must be run late in boot process, after the pci controllers - * have been scaned for devices (after all device resources are known). + * have been scanned for devices (after all device resources are known). */ void __init pci_addr_cache_build(void) { diff --git a/arch/s390/kernel/vtime.c b/arch/s390/kernel/vtime.c index dfe6f085661..1f0439dc245 100644 --- a/arch/s390/kernel/vtime.c +++ b/arch/s390/kernel/vtime.c @@ -356,7 +356,7 @@ static void internal_add_vtimer(struct vtimer_list *timer) set_vtimer(event->expires); spin_unlock_irqrestore(&vt_list->lock, flags); - /* release CPU aquired in prepare_vtimer or mod_virt_timer() */ + /* release CPU acquired in prepare_vtimer or mod_virt_timer() */ put_cpu(); } diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c index 0897852b09a..290cec6d69e 100644 --- a/arch/um/drivers/ubd_kern.c +++ b/arch/um/drivers/ubd_kern.c @@ -1222,7 +1222,7 @@ int open_ubd_file(char *file, struct openflags *openflags, int shared, } } - /* Succesful return case! */ + /* Successful return case! */ if(backing_file_out == NULL) return(fd); diff --git a/arch/x86_64/kernel/i8259.c b/arch/x86_64/kernel/i8259.c index 5ecd34ab8c2..573990a6d66 100644 --- a/arch/x86_64/kernel/i8259.c +++ b/arch/x86_64/kernel/i8259.c @@ -278,7 +278,7 @@ static void mask_and_ack_8259A(unsigned int irq) * Lightweight spurious IRQ detection. We do not want * to overdo spurious IRQ handling - it's usually a sign * of hardware problems, so we only do the checks we can - * do without slowing down good hardware unnecesserily. + * do without slowing down good hardware unnecessarily. * * Note that IRQ7 and IRQ15 (the two spurious IRQs * usually resulting from the 8259A-1|2 PICs) occur diff --git a/block/as-iosched.c b/block/as-iosched.c index 1ec5df46670..3af31ed49a9 100644 --- a/block/as-iosched.c +++ b/block/as-iosched.c @@ -892,7 +892,7 @@ static int as_can_break_anticipation(struct as_data *ad, struct as_rq *arq) } /* - * as_can_anticipate indicates weather we should either run arq + * as_can_anticipate indicates whether we should either run arq * or keep anticipating a better request. */ static int as_can_anticipate(struct as_data *ad, struct as_rq *arq) diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c index 0603ab2f369..c04422a502d 100644 --- a/block/ll_rw_blk.c +++ b/block/ll_rw_blk.c @@ -2745,7 +2745,7 @@ static int attempt_merge(request_queue_t *q, struct request *req, return 0; /* - * not contigious + * not contiguous */ if (req->sector + req->nr_sectors != next->sector) return 0; @@ -3415,7 +3415,7 @@ static struct notifier_block blk_cpu_notifier = { * * Description: * Ends all I/O on a request. It does not handle partial completions, - * unless the driver actually implements this in its completionc callback + * unless the driver actually implements this in its completion callback * through requeueing. Theh actual completion happens out-of-order, * through a softirq handler. The user must have registered a completion * callback through blk_queue_softirq_done(). diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c index 7f7ec288824..f2eeaf9dc56 100644 --- a/drivers/atm/firestream.c +++ b/drivers/atm/firestream.c @@ -951,7 +951,7 @@ static int fs_open(struct atm_vcc *atm_vcc) it most likely that the chip will notice it. It also prevents us from having to wait for completion. On the other hand, we may need to wait for completion anyway, to see if it completed - succesfully. */ + successfully. */ switch (atm_vcc->qos.aal) { case ATM_AAL2: diff --git a/drivers/char/agp/amd-k7-agp.c b/drivers/char/agp/amd-k7-agp.c index 1f776651ac6..51d0d562d01 100644 --- a/drivers/char/agp/amd-k7-agp.c +++ b/drivers/char/agp/amd-k7-agp.c @@ -118,7 +118,7 @@ static int amd_create_gatt_pages(int nr_tables) return retval; } -/* Since we don't need contigious memory we just try +/* Since we don't need contiguous memory we just try * to get the gatt table once */ diff --git a/drivers/char/agp/ati-agp.c b/drivers/char/agp/ati-agp.c index 06fd10ba0c5..16056434599 100644 --- a/drivers/char/agp/ati-agp.c +++ b/drivers/char/agp/ati-agp.c @@ -261,7 +261,7 @@ static int agp_ati_suspend(struct pci_dev *dev, pm_message_t state) #endif /* - *Since we don't need contigious memory we just try + *Since we don't need contiguous memory we just try * to get the gatt table once */ diff --git a/drivers/char/agp/efficeon-agp.c b/drivers/char/agp/efficeon-agp.c index 86a966b6523..b788b0a3bbf 100644 --- a/drivers/char/agp/efficeon-agp.c +++ b/drivers/char/agp/efficeon-agp.c @@ -177,7 +177,7 @@ static int efficeon_free_gatt_table(struct agp_bridge_data *bridge) /* - * Since we don't need contigious memory we just try + * Since we don't need contiguous memory we just try * to get the gatt table once */ diff --git a/drivers/char/rio/riointr.c b/drivers/char/rio/riointr.c index eec1fea0cb9..0bd09040a5c 100644 --- a/drivers/char/rio/riointr.c +++ b/drivers/char/rio/riointr.c @@ -546,7 +546,7 @@ static void RIOReceive(struct rio_info *p, struct Port *PortP) ** run out of space it will be set to the offset of the ** next byte to copy from the packet data area. The packet ** length field is decremented by the number of bytes that - ** we succesfully removed from the packet. When this reaches + ** we successfully removed from the packet. When this reaches ** zero, we reset the offset pointer to be zero, and free ** the packet from the front of the queue. */ diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c index 65b2709f750..facc1ccb833 100644 --- a/drivers/hwmon/asb100.c +++ b/drivers/hwmon/asb100.c @@ -341,7 +341,7 @@ static ssize_t set_fan_min(struct device *dev, const char *buf, /* Note: we save and restore the fan minimum here, because its value is determined in part by the fan divisor. This follows the principle of - least suprise; the user doesn't expect the fan minimum to change just + least surprise; the user doesn't expect the fan minimum to change just because the divisor changed. */ static ssize_t set_fan_div(struct device *dev, const char *buf, size_t count, int nr) diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c index 94be3d797e6..a6ce7abf860 100644 --- a/drivers/hwmon/lm78.c +++ b/drivers/hwmon/lm78.c @@ -358,7 +358,7 @@ static ssize_t show_fan_div(struct device *dev, char *buf, int nr) /* Note: we save and restore the fan minimum here, because its value is determined in part by the fan divisor. This follows the principle of - least suprise; the user doesn't expect the fan minimum to change just + least surprise; the user doesn't expect the fan minimum to change just because the divisor changed. */ static ssize_t set_fan_div(struct device *dev, const char *buf, size_t count, int nr) diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c index f72120d08c4..b4ccdfc0120 100644 --- a/drivers/hwmon/lm80.c +++ b/drivers/hwmon/lm80.c @@ -253,7 +253,7 @@ set_fan(min2, fan_min[1], LM80_REG_FAN_MIN(2), fan_div[1]); /* Note: we save and restore the fan minimum here, because its value is determined in part by the fan divisor. This follows the principle of - least suprise; the user doesn't expect the fan minimum to change just + least surprise; the user doesn't expect the fan minimum to change just because the divisor changed. */ static ssize_t set_fan_div(struct device *dev, const char *buf, size_t count, int nr) diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c index e229daf666d..e6c1b638c97 100644 --- a/drivers/hwmon/lm87.c +++ b/drivers/hwmon/lm87.c @@ -421,7 +421,7 @@ static void set_fan_min(struct device *dev, const char *buf, int nr) /* Note: we save and restore the fan minimum here, because its value is determined in part by the fan clock divider. This follows the principle - of least suprise; the user doesn't expect the fan minimum to change just + of least surprise; the user doesn't expect the fan minimum to change just because the divider changed. */ static ssize_t set_fan_div(struct device *dev, const char *buf, size_t count, int nr) diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c index 6f3fda73f70..063f71c5f07 100644 --- a/drivers/hwmon/sis5595.c +++ b/drivers/hwmon/sis5595.c @@ -380,7 +380,7 @@ static ssize_t show_fan_div(struct device *dev, char *buf, int nr) /* Note: we save and restore the fan minimum here, because its value is determined in part by the fan divisor. This follows the principle of - least suprise; the user doesn't expect the fan minimum to change just + least surprise; the user doesn't expect the fan minimum to change just because the divisor changed. */ static ssize_t set_fan_div(struct device *dev, const char *buf, size_t count, int nr) diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c index 7732aec5459..825e8f72698 100644 --- a/drivers/hwmon/smsc47m1.c +++ b/drivers/hwmon/smsc47m1.c @@ -207,7 +207,7 @@ static ssize_t set_fan_min(struct device *dev, const char *buf, /* Note: we save and restore the fan minimum here, because its value is determined in part by the fan clock divider. This follows the principle - of least suprise; the user doesn't expect the fan minimum to change just + of least surprise; the user doesn't expect the fan minimum to change just because the divider changed. */ static ssize_t set_fan_div(struct device *dev, const char *buf, size_t count, int nr) diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c index 71fb7f1af8f..79368d53c36 100644 --- a/drivers/hwmon/w83627hf.c +++ b/drivers/hwmon/w83627hf.c @@ -781,7 +781,7 @@ show_fan_div_reg(struct device *dev, char *buf, int nr) /* Note: we save and restore the fan minimum here, because its value is determined in part by the fan divisor. This follows the principle of - least suprise; the user doesn't expect the fan minimum to change just + least surprise; the user doesn't expect the fan minimum to change just because the divisor changed. */ static ssize_t store_fan_div_reg(struct device *dev, const char *buf, size_t count, int nr) diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c index e4c700356c4..7be469ed0f8 100644 --- a/drivers/hwmon/w83781d.c +++ b/drivers/hwmon/w83781d.c @@ -630,7 +630,7 @@ show_fan_div_reg(struct device *dev, char *buf, int nr) /* Note: we save and restore the fan minimum here, because its value is determined in part by the fan divisor. This follows the principle of - least suprise; the user doesn't expect the fan minimum to change just + least surprise; the user doesn't expect the fan minimum to change just because the divisor changed. */ static ssize_t store_fan_div_reg(struct device *dev, const char *buf, size_t count, int nr) diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c index 4ef884c216e..e407c74bda3 100644 --- a/drivers/hwmon/w83792d.c +++ b/drivers/hwmon/w83792d.c @@ -463,7 +463,7 @@ show_fan_div(struct device *dev, struct device_attribute *attr, /* Note: we save and restore the fan minimum here, because its value is determined in part by the fan divisor. This follows the principle of - least suprise; the user doesn't expect the fan minimum to change just + least surprise; the user doesn't expect the fan minimum to change just because the divisor changed. */ static ssize_t store_fan_div(struct device *dev, struct device_attribute *attr, diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index a5017de72da..f033d732f38 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c @@ -37,7 +37,7 @@ * Version 1.15 convert all calls to ide_raw_taskfile * since args will return register content. * Version 1.16 added suspend-resume-checkpower - * Version 1.17 do flush on standy, do flush on ATA < ATA6 + * Version 1.17 do flush on standby, do flush on ATA < ATA6 * fix wcache setup. */ diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index 622a55c72f0..05ba8e01e63 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c @@ -1665,7 +1665,7 @@ irqreturn_t ide_intr (int irq, void *dev_id, struct pt_regs *regs) * Initialize a request before we fill it in and send it down to * ide_do_drive_cmd. Commands must be set up by this function. Right * now it doesn't do a lot, but if that changes abusers will have a - * nasty suprise. + * nasty surprise. */ void ide_init_drive_cmd (struct request *rq) diff --git a/drivers/ieee1394/hosts.c b/drivers/ieee1394/hosts.c index 2d47b11777a..ad49c040b67 100644 --- a/drivers/ieee1394/hosts.c +++ b/drivers/ieee1394/hosts.c @@ -103,7 +103,7 @@ static int alloc_hostnum_cb(struct hpsb_host *host, void *__data) * driver specific parts, enable the controller and make it available * to the general subsystem using hpsb_add_host(). * - * Return Value: a pointer to the &hpsb_host if succesful, %NULL if + * Return Value: a pointer to the &hpsb_host if successful, %NULL if * no memory was available. */ static DEFINE_MUTEX(host_num_alloc); diff --git a/drivers/ieee1394/ieee1394_core.h b/drivers/ieee1394/ieee1394_core.h index e7b55e895f5..0ecbf335c64 100644 --- a/drivers/ieee1394/ieee1394_core.h +++ b/drivers/ieee1394/ieee1394_core.h @@ -139,7 +139,7 @@ int hpsb_bus_reset(struct hpsb_host *host); /* * Hand over received selfid packet to the core. Complement check (second - * quadlet is complement of first) is expected to be done and succesful. + * quadlet is complement of first) is expected to be done and successful. */ void hpsb_selfid_received(struct hpsb_host *host, quadlet_t sid); diff --git a/drivers/isdn/divert/isdn_divert.c b/drivers/isdn/divert/isdn_divert.c index f1a1f9a9b88..1f5ebe9ee72 100644 --- a/drivers/isdn/divert/isdn_divert.c +++ b/drivers/isdn/divert/isdn_divert.c @@ -592,7 +592,7 @@ static int put_address(char *st, u_char *p, int len) } /* put_address */ /*************************************/ -/* report a succesfull interrogation */ +/* report a successful interrogation */ /*************************************/ static int interrogate_success(isdn_ctrl *ic, struct call_struc *cs) { char *src = ic->parm.dss1_io.data; diff --git a/drivers/media/video/bt8xx/bttv-cards.c b/drivers/media/video/bt8xx/bttv-cards.c index 3116345c93b..e68a6d2fff2 100644 --- a/drivers/media/video/bt8xx/bttv-cards.c +++ b/drivers/media/video/bt8xx/bttv-cards.c @@ -4848,7 +4848,7 @@ static void picolo_tetra_muxsel (struct bttv* btv, unsigned int input) * * The IVC120G security card has 4 i2c controlled TDA8540 matrix * swichers to provide 16 channels to MUX0. The TDA8540's have - * 4 indepedant outputs and as such the IVC120G also has the + * 4 independent outputs and as such the IVC120G also has the * optional "Monitor Out" bus. This allows the card to be looking * at one input while the monitor is looking at another. * diff --git a/drivers/net/3c501.c b/drivers/net/3c501.c index bb44509fd40..07136ec423b 100644 --- a/drivers/net/3c501.c +++ b/drivers/net/3c501.c @@ -508,11 +508,11 @@ static int el_start_xmit(struct sk_buff *skb, struct net_device *dev) * speak of. We simply pull the packet out of its PIO buffer (which is slow) * and queue it for the kernel. Then we reset the card for the next packet. * - * We sometimes get suprise interrupts late both because the SMP IRQ delivery + * We sometimes get surprise interrupts late both because the SMP IRQ delivery * is message passing and because the card sometimes seems to deliver late. I * think if it is part way through a receive and the mode is changed it carries * on receiving and sends us an interrupt. We have to band aid all these cases - * to get a sensible 150kbytes/second performance. Even then you want a small + * to get a sensible 150kBytes/second performance. Even then you want a small * TCP window. */ diff --git a/drivers/net/irda/irport.c b/drivers/net/irda/irport.c index 98fa5319e5c..44efd49bf4a 100644 --- a/drivers/net/irda/irport.c +++ b/drivers/net/irda/irport.c @@ -386,7 +386,7 @@ static int __irport_change_speed(struct irda_task *task) /* Locking notes : this function may be called from irq context with * spinlock, via irport_write_wakeup(), or from non-interrupt without * spinlock (from the task timer). Yuck ! - * This is ugly, and unsafe is the spinlock is not already aquired. + * This is ugly, and unsafe is the spinlock is not already acquired. * This will be fixed when irda-task get rewritten. * Jean II */ if (!spin_is_locked(&self->lock)) { diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c index e74bf5014ef..a73d5455303 100644 --- a/drivers/net/pcmcia/smc91c92_cs.c +++ b/drivers/net/pcmcia/smc91c92_cs.c @@ -1883,7 +1883,7 @@ static void smc_reset(struct net_device *dev) /* Set the Window 1 control, configuration and station addr registers. No point in writing the I/O base register ;-> */ SMC_SELECT_BANK(1); - /* Automatically release succesfully transmitted packets, + /* Automatically release successfully transmitted packets, Accept link errors, counter and Tx error interrupts. */ outw(CTL_AUTO_RELEASE | CTL_TE_ENABLE | CTL_CR_ENABLE, ioaddr + CONTROL); diff --git a/drivers/net/wireless/ipw2100.c b/drivers/net/wireless/ipw2100.c index 72335c8eb97..94aeb23a772 100644 --- a/drivers/net/wireless/ipw2100.c +++ b/drivers/net/wireless/ipw2100.c @@ -1485,7 +1485,7 @@ static int ipw2100_hw_stop_adapter(struct ipw2100_priv *priv) * * Sending the PREPARE_FOR_POWER_DOWN will restrict the * hardware from going into standby mode and will transition - * out of D0-standy if it is already in that state. + * out of D0-standby if it is already in that state. * * STATUS_PREPARE_POWER_DOWN_COMPLETE will be sent by the * driver upon completion. Once received, the driver can diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index d408a3c3042..23d3b17c8ca 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -369,7 +369,7 @@ pci_set_power_state(struct pci_dev *dev, pci_power_t state) /* * Give firmware a chance to be called, such as ACPI _PRx, _PSx - * Firmware method after natice method ? + * Firmware method after native method ? */ if (platform_pci_set_power_state) platform_pci_set_power_state(dev, state); diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c index 4682c8b8bd2..909731b99d2 100644 --- a/drivers/s390/scsi/zfcp_erp.c +++ b/drivers/s390/scsi/zfcp_erp.c @@ -167,7 +167,7 @@ zfcp_fsf_scsi_er_timeout_handler(unsigned long data) * initiates adapter recovery which is done * asynchronously * - * returns: 0 - initiated action succesfully + * returns: 0 - initiated action successfully * <0 - failed to initiate action */ int @@ -203,7 +203,7 @@ zfcp_erp_adapter_reopen_internal(struct zfcp_adapter *adapter, int clear_mask) * purpose: Wrappper for zfcp_erp_adapter_reopen_internal * used to ensure the correct locking * - * returns: 0 - initiated action succesfully + * returns: 0 - initiated action successfully * <0 - failed to initiate action */ int @@ -469,7 +469,7 @@ zfcp_test_link(struct zfcp_port *port) * initiates Forced Reopen recovery which is done * asynchronously * - * returns: 0 - initiated action succesfully + * returns: 0 - initiated action successfully * <0 - failed to initiate action */ static int @@ -509,7 +509,7 @@ zfcp_erp_port_forced_reopen_internal(struct zfcp_port *port, int clear_mask) * purpose: Wrappper for zfcp_erp_port_forced_reopen_internal * used to ensure the correct locking * - * returns: 0 - initiated action succesfully + * returns: 0 - initiated action successfully * <0 - failed to initiate action */ int @@ -536,7 +536,7 @@ zfcp_erp_port_forced_reopen(struct zfcp_port *port, int clear_mask) * initiates Reopen recovery which is done * asynchronously * - * returns: 0 - initiated action succesfully + * returns: 0 - initiated action successfully * <0 - failed to initiate action */ static int @@ -605,7 +605,7 @@ zfcp_erp_port_reopen(struct zfcp_port *port, int clear_mask) * initiates Reopen recovery which is done * asynchronously * - * returns: 0 - initiated action succesfully + * returns: 0 - initiated action successfully * <0 - failed to initiate action */ static int @@ -1805,7 +1805,7 @@ zfcp_erp_modify_unit_status(struct zfcp_unit *unit, u32 mask, int set_or_clear) * purpose: Wrappper for zfcp_erp_port_reopen_all_internal * used to ensure the correct locking * - * returns: 0 - initiated action succesfully + * returns: 0 - initiated action successfully * <0 - failed to initiate action */ int diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c index fa57e0b4a5f..75f2f7ae2a8 100644 --- a/drivers/scsi/NCR5380.c +++ b/drivers/scsi/NCR5380.c @@ -500,7 +500,7 @@ static void NCR5380_print_phase(struct Scsi_Host *instance) /* * Function : int should_disconnect (unsigned char cmd) * - * Purpose : decide weather a command would normally disconnect or + * Purpose : decide whether a command would normally disconnect or * not, since if it won't disconnect we should go to sleep. * * Input : cmd - opcode of SCSI command diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c index 5ee47555a8a..dd9fb3d9100 100644 --- a/drivers/scsi/advansys.c +++ b/drivers/scsi/advansys.c @@ -12374,7 +12374,7 @@ AscInitFromEEP(ASC_DVC_VAR *asc_dvc) ASC_PRINT1( "AscInitFromEEP: Failed to re-write EEPROM with %d errors.\n", i); } else { - ASC_PRINT("AscInitFromEEP: Succesfully re-wrote EEPROM."); + ASC_PRINT("AscInitFromEEP: Successfully re-wrote EEPROM.\n"); } } return (warn_code); diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c index 18324525493..58b0748045e 100644 --- a/drivers/scsi/dc395x.c +++ b/drivers/scsi/dc395x.c @@ -3771,7 +3771,7 @@ static void request_sense(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb, * @target: The target for the new device. * @lun: The lun for the new device. * - * Return the new device if succesfull or NULL on failure. + * Return the new device if successful or NULL on failure. **/ static struct DeviceCtlBlk *device_alloc(struct AdapterCtlBlk *acb, u8 target, u8 lun) diff --git a/drivers/scsi/ibmmca.c b/drivers/scsi/ibmmca.c index 115f55471ed..497f6642b2d 100644 --- a/drivers/scsi/ibmmca.c +++ b/drivers/scsi/ibmmca.c @@ -760,7 +760,7 @@ static int device_inquiry(int host_index, int ldn) while (!got_interrupt(host_index)) barrier(); - /*if command succesful, break */ + /*if command successful, break */ if ((stat_result(host_index) == IM_SCB_CMD_COMPLETED) || (stat_result(host_index) == IM_SCB_CMD_COMPLETED_WITH_RETRIES)) return 1; } @@ -885,7 +885,7 @@ static int immediate_assign(int host_index, unsigned int pun, unsigned int lun, while (!got_interrupt(host_index)) barrier(); - /*if command succesful, break */ + /*if command successful, break */ if (stat_result(host_index) == IM_IMMEDIATE_CMD_COMPLETED) return 1; } @@ -921,7 +921,7 @@ static int immediate_feature(int host_index, unsigned int speed, unsigned int ti return 2; } else global_command_error_excuse = 0; - /*if command succesful, break */ + /*if command successful, break */ if (stat_result(host_index) == IM_IMMEDIATE_CMD_COMPLETED) return 1; } @@ -959,7 +959,7 @@ static int immediate_reset(int host_index, unsigned int ldn) /* did not work, finish */ return 1; } - /*if command succesful, break */ + /*if command successful, break */ if (stat_result(host_index) == IM_IMMEDIATE_CMD_COMPLETED) return 1; } diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c index 5353b28b293..78f2ff736c3 100644 --- a/drivers/scsi/ips.c +++ b/drivers/scsi/ips.c @@ -6438,7 +6438,7 @@ ips_erase_bios(ips_ha_t * ha) /* VPP failure */ return (1); - /* check for succesful flash */ + /* check for successful flash */ if (status & 0x30) /* sequence error */ return (1); @@ -6550,7 +6550,7 @@ ips_erase_bios_memio(ips_ha_t * ha) /* VPP failure */ return (1); - /* check for succesful flash */ + /* check for successful flash */ if (status & 0x30) /* sequence error */ return (1); diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 1272dd249af..b5218fc0ac8 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c @@ -2818,7 +2818,7 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon (cmdstatp->sense_hdr.sense_key == NO_SENSE || cmdstatp->sense_hdr.sense_key == RECOVERED_ERROR) && undone == 0) { - ioctl_result = 0; /* EOF written succesfully at EOM */ + ioctl_result = 0; /* EOF written successfully at EOM */ if (fileno >= 0) fileno++; STps->drv_file = fileno; diff --git a/fs/9p/mux.c b/fs/9p/mux.c index f4407eb276c..12e1baa4508 100644 --- a/fs/9p/mux.c +++ b/fs/9p/mux.c @@ -712,7 +712,7 @@ static void v9fs_read_work(void *a) * v9fs_send_request - send 9P request * The function can sleep until the request is scheduled for sending. * The function can be interrupted. Return from the function is not - * a guarantee that the request is sent succesfully. Can return errors + * a guarantee that the request is sent successfully. Can return errors * that can be retrieved by PTR_ERR macros. * * @m: mux data diff --git a/fs/aio.c b/fs/aio.c index 8c34a62df7d..950630187ac 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -641,7 +641,7 @@ static inline int __queue_kicked_iocb(struct kiocb *iocb) * invoked both for initial i/o submission and * subsequent retries via the aio_kick_handler. * Expects to be invoked with iocb->ki_ctx->lock - * already held. The lock is released and reaquired + * already held. The lock is released and reacquired * as needed during processing. * * Calls the iocb retry method (already setup for the diff --git a/fs/jffs2/summary.c b/fs/jffs2/summary.c index 0b02fc79e4d..be1acc3dad9 100644 --- a/fs/jffs2/summary.c +++ b/fs/jffs2/summary.c @@ -43,7 +43,7 @@ int jffs2_sum_init(struct jffs2_sb_info *c) return -ENOMEM; } - dbg_summary("returned succesfully\n"); + dbg_summary("returned successfully\n"); return 0; } diff --git a/fs/jfs/jfs_extent.c b/fs/jfs/jfs_extent.c index 5549378358b..4d52593a5fc 100644 --- a/fs/jfs/jfs_extent.c +++ b/fs/jfs/jfs_extent.c @@ -126,7 +126,7 @@ extAlloc(struct inode *ip, s64 xlen, s64 pno, xad_t * xp, boolean_t abnr) /* allocate the disk blocks for the extent. initially, extBalloc() * will try to allocate disk blocks for the requested size (xlen). - * if this fails (xlen contigious free blocks not avaliable), it'll + * if this fails (xlen contiguous free blocks not avaliable), it'll * try to allocate a smaller number of blocks (producing a smaller * extent), with this smaller number of blocks consisting of the * requested number of blocks rounded down to the next smaller @@ -493,7 +493,7 @@ int extFill(struct inode *ip, xad_t * xp) * * initially, we will try to allocate disk blocks for the * requested size (nblocks). if this fails (nblocks - * contigious free blocks not avaliable), we'll try to allocate + * contiguous free blocks not avaliable), we'll try to allocate * a smaller number of blocks (producing a smaller extent), with * this smaller number of blocks consisting of the requested * number of blocks rounded down to the next smaller power of 2 @@ -529,7 +529,7 @@ extBalloc(struct inode *ip, s64 hint, s64 * nblocks, s64 * blkno) /* get the number of blocks to initially attempt to allocate. * we'll first try the number of blocks requested unless this - * number is greater than the maximum number of contigious free + * number is greater than the maximum number of contiguous free * blocks in the map. in that case, we'll start off with the * maximum free. */ @@ -586,7 +586,7 @@ extBalloc(struct inode *ip, s64 hint, s64 * nblocks, s64 * blkno) * in place. if this fails, we'll try to move the extent * to a new set of blocks. if moving the extent, we initially * will try to allocate disk blocks for the requested size - * (nnew). if this fails (nnew contigious free blocks not + * (nnew). if this fails (new contiguous free blocks not * avaliable), we'll try to allocate a smaller number of * blocks (producing a smaller extent), with this smaller * number of blocks consisting of the requested number of diff --git a/include/asm-i386/system.h b/include/asm-i386/system.h index 0249f912a29..cab0180567f 100644 --- a/include/asm-i386/system.h +++ b/include/asm-i386/system.h @@ -427,7 +427,7 @@ static inline unsigned long long __cmpxchg64(volatile void *ptr, unsigned long l * does not enforce ordering, since there is no data dependency between * the read of "a" and the read of "b". Therefore, on some CPUs, such * as Alpha, "y" could be set to 3 and "x" to 0. Use rmb() - * in cases like thiswhere there are no data dependencies. + * in cases like this where there are no data dependencies. **/ #define read_barrier_depends() do { } while(0) diff --git a/include/asm-m32r/system.h b/include/asm-m32r/system.h index 33567e8bfe6..66c4742f09e 100644 --- a/include/asm-m32r/system.h +++ b/include/asm-m32r/system.h @@ -318,7 +318,7 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size) * does not enforce ordering, since there is no data dependency between * the read of "a" and the read of "b". Therefore, on some CPUs, such * as Alpha, "y" could be set to 3 and "x" to 0. Use rmb() - * in cases like thiswhere there are no data dependencies. + * in cases like this where there are no data dependencies. **/ #define read_barrier_depends() do { } while (0) diff --git a/include/linux/sunrpc/gss_api.h b/include/linux/sunrpc/gss_api.h index 9b8bcf125c1..6e112cc5cdd 100644 --- a/include/linux/sunrpc/gss_api.h +++ b/include/linux/sunrpc/gss_api.h @@ -126,7 +126,7 @@ struct gss_api_mech *gss_mech_get_by_pseudoflavor(u32); /* Just increments the mechanism's reference count and returns its input: */ struct gss_api_mech * gss_mech_get(struct gss_api_mech *); -/* For every succesful gss_mech_get or gss_mech_get_by_* call there must be a +/* For every successful gss_mech_get or gss_mech_get_by_* call there must be a * corresponding call to gss_mech_put. */ void gss_mech_put(struct gss_api_mech *); diff --git a/lib/kernel_lock.c b/lib/kernel_lock.c index cb5490ec00f..e713e86811a 100644 --- a/lib/kernel_lock.c +++ b/lib/kernel_lock.c @@ -14,7 +14,7 @@ * The 'big kernel semaphore' * * This mutex is taken and released recursively by lock_kernel() - * and unlock_kernel(). It is transparently dropped and reaquired + * and unlock_kernel(). It is transparently dropped and reacquired * over schedule(). It is used to protect legacy code that hasn't * been migrated to a proper locking design yet. * @@ -92,7 +92,7 @@ void __lockfunc unlock_kernel(void) * The 'big kernel lock' * * This spinlock is taken and released recursively by lock_kernel() - * and unlock_kernel(). It is transparently dropped and reaquired + * and unlock_kernel(). It is transparently dropped and reacquired * over schedule(). It is used to protect legacy code that hasn't * been migrated to a proper locking design yet. * diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 6c1174fcf52..9f86191bb63 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -266,7 +266,7 @@ static inline void rmv_page_order(struct page *page) * satisfies the following equation: * P = B & ~(1 << O) * - * Assumption: *_mem_map is contigious at least up to MAX_ORDER + * Assumption: *_mem_map is contiguous at least up to MAX_ORDER */ static inline struct page * __page_find_buddy(struct page *page, unsigned long page_idx, unsigned int order) diff --git a/mm/readahead.c b/mm/readahead.c index e39e416860d..aa7ec424656 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -390,8 +390,8 @@ int do_page_cache_readahead(struct address_space *mapping, struct file *filp, * Read 'nr_to_read' pages starting at page 'offset'. If the flag 'block' * is set wait till the read completes. Otherwise attempt to read without * blocking. - * Returns 1 meaning 'success' if read is succesfull without switching off - * readhaead mode. Otherwise return failure. + * Returns 1 meaning 'success' if read is successful without switching off + * readahead mode. Otherwise return failure. */ static int blockable_page_cache_readahead(struct address_space *mapping, struct file *filp, diff --git a/net/sunrpc/auth_gss/gss_krb5_mech.c b/net/sunrpc/auth_gss/gss_krb5_mech.c index 129e2bd36af..b8714a87b34 100644 --- a/net/sunrpc/auth_gss/gss_krb5_mech.c +++ b/net/sunrpc/auth_gss/gss_krb5_mech.c @@ -169,7 +169,7 @@ gss_import_sec_context_kerberos(const void *p, } ctx_id->internal_ctx_id = ctx; - dprintk("RPC: Succesfully imported new context.\n"); + dprintk("RPC: Successfully imported new context.\n"); return 0; out_err_free_key2: diff --git a/net/sunrpc/auth_gss/gss_spkm3_mech.c b/net/sunrpc/auth_gss/gss_spkm3_mech.c index 5bf11ccba7c..3d0432aa45c 100644 --- a/net/sunrpc/auth_gss/gss_spkm3_mech.c +++ b/net/sunrpc/auth_gss/gss_spkm3_mech.c @@ -201,7 +201,7 @@ gss_import_sec_context_spkm3(const void *p, size_t len, ctx_id->internal_ctx_id = ctx; - dprintk("Succesfully imported new spkm context.\n"); + dprintk("Successfully imported new spkm context.\n"); return 0; out_err_free_key2: diff --git a/sound/core/seq/seq_memory.h b/sound/core/seq/seq_memory.h index 39c60d9e1ef..63e91431a29 100644 --- a/sound/core/seq/seq_memory.h +++ b/sound/core/seq/seq_memory.h @@ -31,7 +31,7 @@ struct snd_seq_event_cell { struct snd_seq_event_cell *next; /* next cell */ }; -/* design note: the pool is a contigious block of memory, if we dynamicly +/* design note: the pool is a contiguous block of memory, if we dynamicly want to add additional cells to the pool be better store this in another pool as we need to know the base address of the pool when releasing memory. */ diff --git a/sound/oss/sb_ess.c b/sound/oss/sb_ess.c index fae05fe3de4..180e95c87e3 100644 --- a/sound/oss/sb_ess.c +++ b/sound/oss/sb_ess.c @@ -97,19 +97,19 @@ * * The documentation is an adventure: it's close but not fully accurate. I * found out that after a reset some registers are *NOT* reset, though the - * docs say the would be. Interresting ones are 0x7f, 0x7d and 0x7a. They are - * related to the Audio 2 channel. I also was suprised about the consequenses + * docs say the would be. Interesting ones are 0x7f, 0x7d and 0x7a. They are + * related to the Audio 2 channel. I also was surprised about the consequences * of writing 0x00 to 0x7f (which should be done by reset): The ES1887 moves * into ES1888 mode. This means that it claims IRQ 11, which happens to be my * ISDN adapter. Needless to say it no longer worked. I now understand why * after rebooting 0x7f already was 0x05, the value of my choice: the BIOS * did it. * - * Oh, and this is another trap: in ES1887 docs mixer register 0x70 is decribed - * as if it's exactly the same as register 0xa1. This is *NOT* true. The - * description of 0x70 in ES1869 docs is accurate however. + * Oh, and this is another trap: in ES1887 docs mixer register 0x70 is + * described as if it's exactly the same as register 0xa1. This is *NOT* true. + * The description of 0x70 in ES1869 docs is accurate however. * Well, the assumption about ES1869 was wrong: register 0x70 is very much - * like register 0xa1, except that bit 7 is allways 1, whatever you want + * like register 0xa1, except that bit 7 is always 1, whatever you want * it to be. * * When using audio 2 mixer register 0x72 seems te be meaningless. Only 0xa2 @@ -117,10 +117,10 @@ * * Software reset not being able to reset all registers is great! Especially * the fact that register 0x78 isn't reset is great when you wanna change back - * to single dma operation (simplex): audio 2 is still operation, and uses the - * same dma as audio 1: your ess changes into a funny echo machine. + * to single dma operation (simplex): audio 2 is still operational, and uses + * the same dma as audio 1: your ess changes into a funny echo machine. * - * Received the new that ES1688 is detected as a ES1788. Did some thinking: + * Received the news that ES1688 is detected as a ES1788. Did some thinking: * the ES1887 detection scheme suggests in step 2 to try if bit 3 of register * 0x64 can be changed. This is inaccurate, first I inverted the * check: "If * can be modified, it's a 1688", which lead to a correct detection @@ -135,7 +135,7 @@ * About recognition of ESS chips * * The distinction of ES688, ES1688, ES1788, ES1887 and ES1888 is described in - * a (preliminary ??) datasheet on ES1887. It's aim is to identify ES1887, but + * a (preliminary ??) datasheet on ES1887. Its aim is to identify ES1887, but * during detection the text claims that "this chip may be ..." when a step * fails. This scheme is used to distinct between the above chips. * It appears however that some PnP chips like ES1868 are recognized as ES1788 @@ -156,9 +156,9 @@ * * The existing ES1688 support didn't take care of the ES1688+ recording * levels very well. Whenever a device was selected (recmask) for recording - * it's recording level was loud, and it couldn't be changed. The fact that + * its recording level was loud, and it couldn't be changed. The fact that * internal register 0xb4 could take care of RECLEV, didn't work meaning until - * it's value was restored every time the chip was reset; this reset the + * its value was restored every time the chip was reset; this reset the * value of 0xb4 too. I guess that's what 4front also had (have?) trouble with. * * About ES1887 support: @@ -169,9 +169,9 @@ * the latter case the recording volumes are 0. * Now recording levels of inputs can be controlled, by changing the playback * levels. Futhermore several devices can be recorded together (which is not - * possible with the ES1688. + * possible with the ES1688). * Besides the separate recording level control for each input, the common - * recordig level can also be controlled by RECLEV as described above. + * recording level can also be controlled by RECLEV as described above. * * Not only ES1887 have this recording mixer. I know the following from the * documentation: diff --git a/sound/pci/cs5535audio/cs5535audio_pcm.c b/sound/pci/cs5535audio/cs5535audio_pcm.c index f0a48693d68..5450a9e8f13 100644 --- a/sound/pci/cs5535audio/cs5535audio_pcm.c +++ b/sound/pci/cs5535audio/cs5535audio_pcm.c @@ -143,7 +143,7 @@ static int cs5535audio_build_dma_packets(struct cs5535audio *cs5535au, if (dma->periods == periods && dma->period_bytes == period_bytes) return 0; - /* the u32 cast is okay because in snd*create we succesfully told + /* the u32 cast is okay because in snd*create we successfully told pci alloc that we're only 32 bit capable so the uppper will be 0 */ addr = (u32) substream->runtime->dma_addr; desc_addr = (u32) dma->desc_buf.addr; -- cgit v1.2.3-70-g09d2 From d2be8ee53856c3c510d4d38f534979747db65d96 Mon Sep 17 00:00:00 2001 From: Fredrik Roubert Date: Mon, 26 Jun 2006 00:24:35 -0700 Subject: [PATCH] fix magic sysrq on strange keyboards Magic sysrq fails to work on many keyboards, particulary most of notebook keyboards. This patch fixes it. The idea is quite simple: Discard the SysRq break code if Alt is still being held down. This way the broken keyboard can send the break code (or the user with a normal keyboard can release the SysRq key) and the kernel waits until the next key is pressed or the Alt key is released. Signed-off-by: Pavel Machek Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/keyboard.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c index edd996f6fb8..13e3126c1de 100644 --- a/drivers/char/keyboard.c +++ b/drivers/char/keyboard.c @@ -151,6 +151,7 @@ unsigned char kbd_sysrq_xlate[KEY_MAX + 1] = "230\177\000\000\213\214\000\000\000\000\000\000\000\000\000\000" /* 0x50 - 0x5f */ "\r\000/"; /* 0x60 - 0x6f */ static int sysrq_down; +static int sysrq_alt_use; #endif static int sysrq_alt; @@ -1143,7 +1144,7 @@ static void kbd_keycode(unsigned int keycode, int down, kbd = kbd_table + fg_console; if (keycode == KEY_LEFTALT || keycode == KEY_RIGHTALT) - sysrq_alt = down; + sysrq_alt = down ? keycode : 0; #ifdef CONFIG_SPARC if (keycode == KEY_STOP) sparc_l1_a_state = down; @@ -1163,9 +1164,14 @@ static void kbd_keycode(unsigned int keycode, int down, #ifdef CONFIG_MAGIC_SYSRQ /* Handle the SysRq Hack */ if (keycode == KEY_SYSRQ && (sysrq_down || (down == 1 && sysrq_alt))) { - sysrq_down = down; + if (!sysrq_down) { + sysrq_down = down; + sysrq_alt_use = sysrq_alt; + } return; } + if (sysrq_down && !down && keycode == sysrq_alt_use) + sysrq_down = 0; if (sysrq_down && down && !rep) { handle_sysrq(kbd_sysrq_xlate[keycode], regs, tty); return; -- cgit v1.2.3-70-g09d2 From 179e09172ab663b8587ecc46bb18a56a770304a9 Mon Sep 17 00:00:00 2001 From: Akinobu Mita Date: Mon, 26 Jun 2006 00:24:41 -0700 Subject: [PATCH] drivers: use list_move() This patch converts the combination of list_del(A) and list_add(A, B) to list_move(A, B) under drivers/. Acked-by: Corey Minyard Cc: Ben Collins Acked-by: Roland Dreier Cc: Alasdair Kergon Cc: Gerd Knorr Cc: Paul Mackerras Cc: Frank Pavlic Acked-by: Matthew Wilcox Cc: Andrew Vasquez Cc: Mikael Starvik Cc: Greg Kroah-Hartman Signed-off-by: Akinobu Mita Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/ipmi/ipmi_msghandler.c | 7 ++----- drivers/ieee1394/eth1394.c | 3 +-- drivers/ieee1394/raw1394.c | 3 +-- drivers/infiniband/core/mad.c | 9 +++------ drivers/infiniband/core/mad_rmpp.c | 3 +-- drivers/infiniband/ulp/ipoib/ipoib_multicast.c | 6 ++---- drivers/md/dm-raid1.c | 6 ++---- drivers/media/video/cx88/cx88-video.c | 6 ++---- drivers/net/ppp_generic.c | 3 +-- drivers/s390/net/lcs.c | 7 +++---- drivers/scsi/ncr53c8xx.c | 3 +-- drivers/scsi/qla2xxx/qla_init.c | 3 +-- drivers/usb/host/hc_crisv10.c | 3 +-- drivers/usb/serial/whiteheat.c | 19 +++++++------------ 14 files changed, 28 insertions(+), 53 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c index 9f2f8fdec69..23028559dbc 100644 --- a/drivers/char/ipmi/ipmi_msghandler.c +++ b/drivers/char/ipmi/ipmi_msghandler.c @@ -936,11 +936,8 @@ int ipmi_set_gets_events(ipmi_user_t user, int val) if (val) { /* Deliver any queued events. */ - list_for_each_entry_safe(msg, msg2, &intf->waiting_events, - link) { - list_del(&msg->link); - list_add_tail(&msg->link, &msgs); - } + list_for_each_entry_safe(msg, msg2, &intf->waiting_events, link) + list_move_tail(&msg->link, &msgs); intf->waiting_events_count = 0; } diff --git a/drivers/ieee1394/eth1394.c b/drivers/ieee1394/eth1394.c index 5bda15904a0..2d5b57be98c 100644 --- a/drivers/ieee1394/eth1394.c +++ b/drivers/ieee1394/eth1394.c @@ -1074,8 +1074,7 @@ static inline int update_partial_datagram(struct list_head *pdgl, struct list_he /* Move list entry to beginnig of list so that oldest partial * datagrams percolate to the end of the list */ - list_del(lh); - list_add(lh, pdgl); + list_move(lh, pdgl); return 0; } diff --git a/drivers/ieee1394/raw1394.c b/drivers/ieee1394/raw1394.c index 20ce539580f..571ea68c0cf 100644 --- a/drivers/ieee1394/raw1394.c +++ b/drivers/ieee1394/raw1394.c @@ -132,8 +132,7 @@ static void free_pending_request(struct pending_request *req) static void __queue_complete_req(struct pending_request *req) { struct file_info *fi = req->file_info; - list_del(&req->list); - list_add_tail(&req->list, &fi->req_complete); + list_move_tail(&req->list, &fi->req_complete); up(&fi->complete_sem); wake_up_interruptible(&fi->poll_wait_complete); diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c index b38e02a5db3..5ed4dab52a6 100644 --- a/drivers/infiniband/core/mad.c +++ b/drivers/infiniband/core/mad.c @@ -1775,11 +1775,9 @@ ib_find_send_mad(struct ib_mad_agent_private *mad_agent_priv, void ib_mark_mad_done(struct ib_mad_send_wr_private *mad_send_wr) { mad_send_wr->timeout = 0; - if (mad_send_wr->refcount == 1) { - list_del(&mad_send_wr->agent_list); - list_add_tail(&mad_send_wr->agent_list, + if (mad_send_wr->refcount == 1) + list_move_tail(&mad_send_wr->agent_list, &mad_send_wr->mad_agent_priv->done_list); - } } static void ib_mad_complete_recv(struct ib_mad_agent_private *mad_agent_priv, @@ -2098,8 +2096,7 @@ retry: queued_send_wr = container_of(mad_list, struct ib_mad_send_wr_private, mad_list); - list_del(&mad_list->list); - list_add_tail(&mad_list->list, &send_queue->list); + list_move_tail(&mad_list->list, &send_queue->list); } spin_unlock_irqrestore(&send_queue->lock, flags); diff --git a/drivers/infiniband/core/mad_rmpp.c b/drivers/infiniband/core/mad_rmpp.c index d4704e054e3..ebcd5b18177 100644 --- a/drivers/infiniband/core/mad_rmpp.c +++ b/drivers/infiniband/core/mad_rmpp.c @@ -665,8 +665,7 @@ static void process_rmpp_ack(struct ib_mad_agent_private *agent, goto out; mad_send_wr->refcount++; - list_del(&mad_send_wr->agent_list); - list_add_tail(&mad_send_wr->agent_list, + list_move_tail(&mad_send_wr->agent_list, &mad_send_wr->mad_agent_priv->send_list); } out: diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c index 216471fa01c..ab40488182b 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c @@ -864,8 +864,7 @@ void ipoib_mcast_restart_task(void *dev_ptr) if (mcast) { /* Destroy the send only entry */ - list_del(&mcast->list); - list_add_tail(&mcast->list, &remove_list); + list_move_tail(&mcast->list, &remove_list); rb_replace_node(&mcast->rb_node, &nmcast->rb_node, @@ -890,8 +889,7 @@ void ipoib_mcast_restart_task(void *dev_ptr) rb_erase(&mcast->rb_node, &priv->multicast_tree); /* Move to the remove list */ - list_del(&mcast->list); - list_add_tail(&mcast->list, &remove_list); + list_move_tail(&mcast->list, &remove_list); } } diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c index d12cf3e5e07..4ad269e6652 100644 --- a/drivers/md/dm-raid1.c +++ b/drivers/md/dm-raid1.c @@ -458,11 +458,9 @@ static int __rh_recovery_prepare(struct region_hash *rh) /* Already quiesced ? */ if (atomic_read(®->pending)) list_del_init(®->list); + else + list_move(®->list, &rh->quiesced_regions); - else { - list_del_init(®->list); - list_add(®->list, &rh->quiesced_regions); - } spin_unlock_irq(&rh->region_lock); return 1; diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c index 694d1d80ff3..dcda5291b99 100644 --- a/drivers/media/video/cx88/cx88-video.c +++ b/drivers/media/video/cx88/cx88-video.c @@ -494,8 +494,7 @@ static int restart_video_queue(struct cx8800_dev *dev, return 0; buf = list_entry(q->queued.next, struct cx88_buffer, vb.queue); if (NULL == prev) { - list_del(&buf->vb.queue); - list_add_tail(&buf->vb.queue,&q->active); + list_move_tail(&buf->vb.queue, &q->active); start_video_dma(dev, q, buf); buf->vb.state = STATE_ACTIVE; buf->count = q->count++; @@ -506,8 +505,7 @@ static int restart_video_queue(struct cx8800_dev *dev, } else if (prev->vb.width == buf->vb.width && prev->vb.height == buf->vb.height && prev->fmt == buf->fmt) { - list_del(&buf->vb.queue); - list_add_tail(&buf->vb.queue,&q->active); + list_move_tail(&buf->vb.queue, &q->active); buf->vb.state = STATE_ACTIVE; buf->count = q->count++; prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c index 01cd8ec751e..d643a097faa 100644 --- a/drivers/net/ppp_generic.c +++ b/drivers/net/ppp_generic.c @@ -2578,8 +2578,7 @@ ppp_find_channel(int unit) list_for_each_entry(pch, &new_channels, list) { if (pch->file.index == unit) { - list_del(&pch->list); - list_add(&pch->list, &all_channels); + list_move(&pch->list, &all_channels); return pch; } } diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c index f94419b334f..2eded55ae88 100644 --- a/drivers/s390/net/lcs.c +++ b/drivers/s390/net/lcs.c @@ -1140,10 +1140,9 @@ list_modified: } } /* re-insert all entries from the failed_list into ipm_list */ - list_for_each_entry_safe(ipm, tmp, &failed_list, list) { - list_del_init(&ipm->list); - list_add_tail(&ipm->list, &card->ipm_list); - } + list_for_each_entry_safe(ipm, tmp, &failed_list, list) + list_move_tail(&ipm->list, &card->ipm_list); + spin_unlock_irqrestore(&card->ipm_lock, flags); } diff --git a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c index 6ab035590ee..b28712df0b7 100644 --- a/drivers/scsi/ncr53c8xx.c +++ b/drivers/scsi/ncr53c8xx.c @@ -5118,8 +5118,7 @@ static void ncr_ccb_skipped(struct ncb *np, struct ccb *cp) cp->host_status &= ~HS_SKIPMASK; cp->start.schedule.l_paddr = cpu_to_scr(NCB_SCRIPT_PHYS (np, select)); - list_del(&cp->link_ccbq); - list_add_tail(&cp->link_ccbq, &lp->skip_ccbq); + list_move_tail(&cp->link_ccbq, &lp->skip_ccbq); if (cp->queued) { --lp->queuedccbs; } diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index aef093db597..3d4487eac9b 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -2258,8 +2258,7 @@ qla2x00_configure_fabric(scsi_qla_host_t *ha) } /* Remove device from the new list and add it to DB */ - list_del(&fcport->list); - list_add_tail(&fcport->list, &ha->fcports); + list_move_tail(&fcport->list, &ha->fcports); /* Login and update database */ qla2x00_fabric_dev_login(ha, fcport, &next_loopid); diff --git a/drivers/usb/host/hc_crisv10.c b/drivers/usb/host/hc_crisv10.c index 2fe7fd19437..4a22909518f 100644 --- a/drivers/usb/host/hc_crisv10.c +++ b/drivers/usb/host/hc_crisv10.c @@ -411,8 +411,7 @@ static inline void urb_list_move_last(struct urb *urb, int epid) urb_entry_t *urb_entry = __urb_list_entry(urb, epid); assert(urb_entry); - list_del(&urb_entry->list); - list_add_tail(&urb_entry->list, &urb_list[epid]); + list_move_tail(&urb_entry->list, &urb_list[epid]); } /* Get the next urb in the list. */ diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c index 5b06fa36609..56ffc81302f 100644 --- a/drivers/usb/serial/whiteheat.c +++ b/drivers/usb/serial/whiteheat.c @@ -686,19 +686,16 @@ static void whiteheat_close(struct usb_serial_port *port, struct file * filp) wrap = list_entry(tmp, struct whiteheat_urb_wrap, list); urb = wrap->urb; usb_kill_urb(urb); - list_del(tmp); - list_add(tmp, &info->rx_urbs_free); - } - list_for_each_safe(tmp, tmp2, &info->rx_urb_q) { - list_del(tmp); - list_add(tmp, &info->rx_urbs_free); + list_move(tmp, &info->rx_urbs_free); } + list_for_each_safe(tmp, tmp2, &info->rx_urb_q) + list_move(tmp, &info->rx_urbs_free); + list_for_each_safe(tmp, tmp2, &info->tx_urbs_submitted) { wrap = list_entry(tmp, struct whiteheat_urb_wrap, list); urb = wrap->urb; usb_kill_urb(urb); - list_del(tmp); - list_add(tmp, &info->tx_urbs_free); + list_move(tmp, &info->tx_urbs_free); } spin_unlock_irqrestore(&info->lock, flags); @@ -1080,8 +1077,7 @@ static void whiteheat_write_callback(struct urb *urb, struct pt_regs *regs) err("%s - Not my urb!", __FUNCTION__); return; } - list_del(&wrap->list); - list_add(&wrap->list, &info->tx_urbs_free); + list_move(&wrap->list, &info->tx_urbs_free); spin_unlock(&info->lock); if (urb->status) { @@ -1371,8 +1367,7 @@ static int start_port_read(struct usb_serial_port *port) wrap = list_entry(tmp, struct whiteheat_urb_wrap, list); urb = wrap->urb; usb_kill_urb(urb); - list_del(tmp); - list_add(tmp, &info->rx_urbs_free); + list_move(tmp, &info->rx_urbs_free); } break; } -- cgit v1.2.3-70-g09d2 From 59f5d35f83738bf07e66f8cdcff32a433df804a3 Mon Sep 17 00:00:00 2001 From: Michael Buesch Date: Mon, 26 Jun 2006 00:24:58 -0700 Subject: [PATCH] Remove old HW RNG support This patch series replaces the old non-generic Hardware Random Number Generator support by a fully generic RNG API. This makes it possible to register additional RNGs from modules. With this patch series applied, Laptops with a bcm43xx chip (PowerBook) have a HW RNG available now. Additionally two new RNG drivers are added for the "ixp4xx" and "omap" devices. (Written by Deepak Saxena). This patch series includes the old patches by Deepak Saxena. The old x86-rng driver has beed split. The userspace RNG daemon can later be updated to select the RNG through /sys/class/misc/hw_random/ for convenience. For now it is sufficient to use cat and echo -n on the sysfs attributes. Signed-off-by: Michael Buesch Acked-by: Jeff Garzik Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/Kconfig | 15 - drivers/char/Makefile | 1 - drivers/char/hw_random.c | 698 ----------------------------------------------- 3 files changed, 714 deletions(-) delete mode 100644 drivers/char/hw_random.c (limited to 'drivers/char') diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index 63f28d169b3..e4b44c68ad0 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -670,21 +670,6 @@ config NWFLASH If you're not sure, say N. -config HW_RANDOM - tristate "Intel/AMD/VIA HW Random Number Generator support" - depends on (X86 || IA64) && PCI - ---help--- - This driver provides kernel-side support for the Random Number - Generator hardware found on Intel i8xx-based motherboards, - AMD 76x-based motherboards, and Via Nehemiah CPUs. - - Provides a character driver, used to read() entropy data. - - To compile this driver as a module, choose M here: the - module will be called hw_random. - - If unsure, say N. - config NVRAM tristate "/dev/nvram support" depends on ATARI || X86 || ARM || GENERIC_NVRAM diff --git a/drivers/char/Makefile b/drivers/char/Makefile index fb919bfb282..79aecef93b6 100644 --- a/drivers/char/Makefile +++ b/drivers/char/Makefile @@ -75,7 +75,6 @@ endif obj-$(CONFIG_TOSHIBA) += toshiba.o obj-$(CONFIG_I8K) += i8k.o obj-$(CONFIG_DS1620) += ds1620.o -obj-$(CONFIG_HW_RANDOM) += hw_random.o obj-$(CONFIG_FTAPE) += ftape/ obj-$(CONFIG_COBALT_LCD) += lcd.o obj-$(CONFIG_PPDEV) += ppdev.o diff --git a/drivers/char/hw_random.c b/drivers/char/hw_random.c deleted file mode 100644 index 29dc87e5902..00000000000 --- a/drivers/char/hw_random.c +++ /dev/null @@ -1,698 +0,0 @@ -/* - Added support for the AMD Geode LX RNG - (c) Copyright 2004-2005 Advanced Micro Devices, Inc. - - derived from - - Hardware driver for the Intel/AMD/VIA Random Number Generators (RNG) - (c) Copyright 2003 Red Hat Inc - - derived from - - Hardware driver for the AMD 768 Random Number Generator (RNG) - (c) Copyright 2001 Red Hat Inc - - derived from - - Hardware driver for Intel i810 Random Number Generator (RNG) - Copyright 2000,2001 Jeff Garzik - Copyright 2000,2001 Philipp Rumpf - - Please read Documentation/hw_random.txt for details on use. - - ---------------------------------------------------------- - This software may be used and distributed according to the terms - of the GNU General Public License, incorporated herein by reference. - - */ - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __i386__ -#include -#include -#endif - -#include -#include - - -/* - * core module and version information - */ -#define RNG_VERSION "1.0.0" -#define RNG_MODULE_NAME "hw_random" -#define RNG_DRIVER_NAME RNG_MODULE_NAME " hardware driver " RNG_VERSION -#define PFX RNG_MODULE_NAME ": " - - -/* - * debugging macros - */ - -/* pr_debug() collapses to a no-op if DEBUG is not defined */ -#define DPRINTK(fmt, args...) pr_debug(PFX "%s: " fmt, __FUNCTION__ , ## args) - - -#undef RNG_NDEBUG /* define to enable lightweight runtime checks */ -#ifdef RNG_NDEBUG -#define assert(expr) \ - if(!(expr)) { \ - printk(KERN_DEBUG PFX "Assertion failed! %s,%s,%s," \ - "line=%d\n", #expr, __FILE__, __FUNCTION__, __LINE__); \ - } -#else -#define assert(expr) -#endif - -#define RNG_MISCDEV_MINOR 183 /* official */ - -static int rng_dev_open (struct inode *inode, struct file *filp); -static ssize_t rng_dev_read (struct file *filp, char __user *buf, size_t size, - loff_t * offp); - -static int __init intel_init (struct pci_dev *dev); -static void intel_cleanup(void); -static unsigned int intel_data_present (void); -static u32 intel_data_read (void); - -static int __init amd_init (struct pci_dev *dev); -static void amd_cleanup(void); -static unsigned int amd_data_present (void); -static u32 amd_data_read (void); - -#ifdef __i386__ -static int __init via_init(struct pci_dev *dev); -static void via_cleanup(void); -static unsigned int via_data_present (void); -static u32 via_data_read (void); -#endif - -static int __init geode_init(struct pci_dev *dev); -static void geode_cleanup(void); -static unsigned int geode_data_present (void); -static u32 geode_data_read (void); - -struct rng_operations { - int (*init) (struct pci_dev *dev); - void (*cleanup) (void); - unsigned int (*data_present) (void); - u32 (*data_read) (void); - unsigned int n_bytes; /* number of bytes per ->data_read */ -}; -static struct rng_operations *rng_ops; - -static struct file_operations rng_chrdev_ops = { - .owner = THIS_MODULE, - .open = rng_dev_open, - .read = rng_dev_read, -}; - - -static struct miscdevice rng_miscdev = { - RNG_MISCDEV_MINOR, - RNG_MODULE_NAME, - &rng_chrdev_ops, -}; - -enum { - rng_hw_none, - rng_hw_intel, - rng_hw_amd, -#ifdef __i386__ - rng_hw_via, -#endif - rng_hw_geode, -}; - -static struct rng_operations rng_vendor_ops[] = { - /* rng_hw_none */ - { }, - - /* rng_hw_intel */ - { intel_init, intel_cleanup, intel_data_present, - intel_data_read, 1 }, - - /* rng_hw_amd */ - { amd_init, amd_cleanup, amd_data_present, amd_data_read, 4 }, - -#ifdef __i386__ - /* rng_hw_via */ - { via_init, via_cleanup, via_data_present, via_data_read, 1 }, -#endif - - /* rng_hw_geode */ - { geode_init, geode_cleanup, geode_data_present, geode_data_read, 4 } -}; - -/* - * Data for PCI driver interface - * - * This data only exists for exporting the supported - * PCI ids via MODULE_DEVICE_TABLE. We do not actually - * register a pci_driver, because someone else might one day - * want to register another driver on the same PCI id. - */ -static struct pci_device_id rng_pci_tbl[] = { - { 0x1022, 0x7443, PCI_ANY_ID, PCI_ANY_ID, 0, 0, rng_hw_amd }, - { 0x1022, 0x746b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, rng_hw_amd }, - - { 0x8086, 0x2418, PCI_ANY_ID, PCI_ANY_ID, 0, 0, rng_hw_intel }, - { 0x8086, 0x2428, PCI_ANY_ID, PCI_ANY_ID, 0, 0, rng_hw_intel }, - { 0x8086, 0x2430, PCI_ANY_ID, PCI_ANY_ID, 0, 0, rng_hw_intel }, - { 0x8086, 0x2448, PCI_ANY_ID, PCI_ANY_ID, 0, 0, rng_hw_intel }, - { 0x8086, 0x244e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, rng_hw_intel }, - { 0x8086, 0x245e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, rng_hw_intel }, - - { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_LX_AES, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, rng_hw_geode }, - - { 0, }, /* terminate list */ -}; -MODULE_DEVICE_TABLE (pci, rng_pci_tbl); - - -/*********************************************************************** - * - * Intel RNG operations - * - */ - -/* - * RNG registers (offsets from rng_mem) - */ -#define INTEL_RNG_HW_STATUS 0 -#define INTEL_RNG_PRESENT 0x40 -#define INTEL_RNG_ENABLED 0x01 -#define INTEL_RNG_STATUS 1 -#define INTEL_RNG_DATA_PRESENT 0x01 -#define INTEL_RNG_DATA 2 - -/* - * Magic address at which Intel PCI bridges locate the RNG - */ -#define INTEL_RNG_ADDR 0xFFBC015F -#define INTEL_RNG_ADDR_LEN 3 - -/* token to our ioremap'd RNG register area */ -static void __iomem *rng_mem; - -static inline u8 intel_hwstatus (void) -{ - assert (rng_mem != NULL); - return readb (rng_mem + INTEL_RNG_HW_STATUS); -} - -static inline u8 intel_hwstatus_set (u8 hw_status) -{ - assert (rng_mem != NULL); - writeb (hw_status, rng_mem + INTEL_RNG_HW_STATUS); - return intel_hwstatus (); -} - -static unsigned int intel_data_present(void) -{ - assert (rng_mem != NULL); - - return (readb (rng_mem + INTEL_RNG_STATUS) & INTEL_RNG_DATA_PRESENT) ? - 1 : 0; -} - -static u32 intel_data_read(void) -{ - assert (rng_mem != NULL); - - return readb (rng_mem + INTEL_RNG_DATA); -} - -static int __init intel_init (struct pci_dev *dev) -{ - int rc; - u8 hw_status; - - DPRINTK ("ENTER\n"); - - rng_mem = ioremap (INTEL_RNG_ADDR, INTEL_RNG_ADDR_LEN); - if (rng_mem == NULL) { - printk (KERN_ERR PFX "cannot ioremap RNG Memory\n"); - rc = -EBUSY; - goto err_out; - } - - /* Check for Intel 82802 */ - hw_status = intel_hwstatus (); - if ((hw_status & INTEL_RNG_PRESENT) == 0) { - printk (KERN_ERR PFX "RNG not detected\n"); - rc = -ENODEV; - goto err_out_free_map; - } - - /* turn RNG h/w on, if it's off */ - if ((hw_status & INTEL_RNG_ENABLED) == 0) - hw_status = intel_hwstatus_set (hw_status | INTEL_RNG_ENABLED); - if ((hw_status & INTEL_RNG_ENABLED) == 0) { - printk (KERN_ERR PFX "cannot enable RNG, aborting\n"); - rc = -EIO; - goto err_out_free_map; - } - - DPRINTK ("EXIT, returning 0\n"); - return 0; - -err_out_free_map: - iounmap (rng_mem); - rng_mem = NULL; -err_out: - DPRINTK ("EXIT, returning %d\n", rc); - return rc; -} - -static void intel_cleanup(void) -{ - u8 hw_status; - - hw_status = intel_hwstatus (); - if (hw_status & INTEL_RNG_ENABLED) - intel_hwstatus_set (hw_status & ~INTEL_RNG_ENABLED); - else - printk(KERN_WARNING PFX "unusual: RNG already disabled\n"); - iounmap(rng_mem); - rng_mem = NULL; -} - -/*********************************************************************** - * - * AMD RNG operations - * - */ - -static u32 pmbase; /* PMxx I/O base */ -static struct pci_dev *amd_dev; - -static unsigned int amd_data_present (void) -{ - return inl(pmbase + 0xF4) & 1; -} - - -static u32 amd_data_read (void) -{ - return inl(pmbase + 0xF0); -} - -static int __init amd_init (struct pci_dev *dev) -{ - int rc; - u8 rnen; - - DPRINTK ("ENTER\n"); - - pci_read_config_dword(dev, 0x58, &pmbase); - - pmbase &= 0x0000FF00; - - if (pmbase == 0) - { - printk (KERN_ERR PFX "power management base not set\n"); - rc = -EIO; - goto err_out; - } - - pci_read_config_byte(dev, 0x40, &rnen); - rnen |= (1 << 7); /* RNG on */ - pci_write_config_byte(dev, 0x40, rnen); - - pci_read_config_byte(dev, 0x41, &rnen); - rnen |= (1 << 7); /* PMIO enable */ - pci_write_config_byte(dev, 0x41, rnen); - - pr_info( PFX "AMD768 system management I/O registers at 0x%X.\n", - pmbase); - - amd_dev = dev; - - DPRINTK ("EXIT, returning 0\n"); - return 0; - -err_out: - DPRINTK ("EXIT, returning %d\n", rc); - return rc; -} - -static void amd_cleanup(void) -{ - u8 rnen; - - pci_read_config_byte(amd_dev, 0x40, &rnen); - rnen &= ~(1 << 7); /* RNG off */ - pci_write_config_byte(amd_dev, 0x40, rnen); - - /* FIXME: twiddle pmio, also? */ -} - -#ifdef __i386__ -/*********************************************************************** - * - * VIA RNG operations - * - */ - -enum { - VIA_STRFILT_CNT_SHIFT = 16, - VIA_STRFILT_FAIL = (1 << 15), - VIA_STRFILT_ENABLE = (1 << 14), - VIA_RAWBITS_ENABLE = (1 << 13), - VIA_RNG_ENABLE = (1 << 6), - VIA_XSTORE_CNT_MASK = 0x0F, - - VIA_RNG_CHUNK_8 = 0x00, /* 64 rand bits, 64 stored bits */ - VIA_RNG_CHUNK_4 = 0x01, /* 32 rand bits, 32 stored bits */ - VIA_RNG_CHUNK_4_MASK = 0xFFFFFFFF, - VIA_RNG_CHUNK_2 = 0x02, /* 16 rand bits, 32 stored bits */ - VIA_RNG_CHUNK_2_MASK = 0xFFFF, - VIA_RNG_CHUNK_1 = 0x03, /* 8 rand bits, 32 stored bits */ - VIA_RNG_CHUNK_1_MASK = 0xFF, -}; - -static u32 via_rng_datum; - -/* - * Investigate using the 'rep' prefix to obtain 32 bits of random data - * in one insn. The upside is potentially better performance. The - * downside is that the instruction becomes no longer atomic. Due to - * this, just like familiar issues with /dev/random itself, the worst - * case of a 'rep xstore' could potentially pause a cpu for an - * unreasonably long time. In practice, this condition would likely - * only occur when the hardware is failing. (or so we hope :)) - * - * Another possible performance boost may come from simply buffering - * until we have 4 bytes, thus returning a u32 at a time, - * instead of the current u8-at-a-time. - */ - -static inline u32 xstore(u32 *addr, u32 edx_in) -{ - u32 eax_out; - - asm(".byte 0x0F,0xA7,0xC0 /* xstore %%edi (addr=%0) */" - :"=m"(*addr), "=a"(eax_out) - :"D"(addr), "d"(edx_in)); - - return eax_out; -} - -static unsigned int via_data_present(void) -{ - u32 bytes_out; - - /* We choose the recommended 1-byte-per-instruction RNG rate, - * for greater randomness at the expense of speed. Larger - * values 2, 4, or 8 bytes-per-instruction yield greater - * speed at lesser randomness. - * - * If you change this to another VIA_CHUNK_n, you must also - * change the ->n_bytes values in rng_vendor_ops[] tables. - * VIA_CHUNK_8 requires further code changes. - * - * A copy of MSR_VIA_RNG is placed in eax_out when xstore - * completes. - */ - via_rng_datum = 0; /* paranoia, not really necessary */ - bytes_out = xstore(&via_rng_datum, VIA_RNG_CHUNK_1) & VIA_XSTORE_CNT_MASK; - if (bytes_out == 0) - return 0; - - return 1; -} - -static u32 via_data_read(void) -{ - return via_rng_datum; -} - -static int __init via_init(struct pci_dev *dev) -{ - u32 lo, hi, old_lo; - - /* Control the RNG via MSR. Tread lightly and pay very close - * close attention to values written, as the reserved fields - * are documented to be "undefined and unpredictable"; but it - * does not say to write them as zero, so I make a guess that - * we restore the values we find in the register. - */ - rdmsr(MSR_VIA_RNG, lo, hi); - - old_lo = lo; - lo &= ~(0x7f << VIA_STRFILT_CNT_SHIFT); - lo &= ~VIA_XSTORE_CNT_MASK; - lo &= ~(VIA_STRFILT_ENABLE | VIA_STRFILT_FAIL | VIA_RAWBITS_ENABLE); - lo |= VIA_RNG_ENABLE; - - if (lo != old_lo) - wrmsr(MSR_VIA_RNG, lo, hi); - - /* perhaps-unnecessary sanity check; remove after testing if - unneeded */ - rdmsr(MSR_VIA_RNG, lo, hi); - if ((lo & VIA_RNG_ENABLE) == 0) { - printk(KERN_ERR PFX "cannot enable VIA C3 RNG, aborting\n"); - return -ENODEV; - } - - return 0; -} - -static void via_cleanup(void) -{ - /* do nothing */ -} -#endif - -/*********************************************************************** - * - * AMD Geode RNG operations - * - */ - -static void __iomem *geode_rng_base = NULL; - -#define GEODE_RNG_DATA_REG 0x50 -#define GEODE_RNG_STATUS_REG 0x54 - -static u32 geode_data_read(void) -{ - u32 val; - - assert(geode_rng_base != NULL); - val = readl(geode_rng_base + GEODE_RNG_DATA_REG); - return val; -} - -static unsigned int geode_data_present(void) -{ - u32 val; - - assert(geode_rng_base != NULL); - val = readl(geode_rng_base + GEODE_RNG_STATUS_REG); - return val; -} - -static void geode_cleanup(void) -{ - iounmap(geode_rng_base); - geode_rng_base = NULL; -} - -static int geode_init(struct pci_dev *dev) -{ - unsigned long rng_base = pci_resource_start(dev, 0); - - if (rng_base == 0) - return 1; - - geode_rng_base = ioremap(rng_base, 0x58); - - if (geode_rng_base == NULL) { - printk(KERN_ERR PFX "Cannot ioremap RNG memory\n"); - return -EBUSY; - } - - return 0; -} - -/*********************************************************************** - * - * /dev/hwrandom character device handling (major 10, minor 183) - * - */ - -static int rng_dev_open (struct inode *inode, struct file *filp) -{ - /* enforce read-only access to this chrdev */ - if ((filp->f_mode & FMODE_READ) == 0) - return -EINVAL; - if (filp->f_mode & FMODE_WRITE) - return -EINVAL; - - return 0; -} - - -static ssize_t rng_dev_read (struct file *filp, char __user *buf, size_t size, - loff_t * offp) -{ - static DEFINE_SPINLOCK(rng_lock); - unsigned int have_data; - u32 data = 0; - ssize_t ret = 0; - - while (size) { - spin_lock(&rng_lock); - - have_data = 0; - if (rng_ops->data_present()) { - data = rng_ops->data_read(); - have_data = rng_ops->n_bytes; - } - - spin_unlock (&rng_lock); - - while (have_data && size) { - if (put_user((u8)data, buf++)) { - ret = ret ? : -EFAULT; - break; - } - size--; - ret++; - have_data--; - data>>=8; - } - - if (filp->f_flags & O_NONBLOCK) - return ret ? : -EAGAIN; - - if(need_resched()) - schedule_timeout_interruptible(1); - else - udelay(200); /* FIXME: We could poll for 250uS ?? */ - - if (signal_pending (current)) - return ret ? : -ERESTARTSYS; - } - return ret; -} - - - -/* - * rng_init_one - look for and attempt to init a single RNG - */ -static int __init rng_init_one (struct pci_dev *dev) -{ - int rc; - - DPRINTK ("ENTER\n"); - - assert(rng_ops != NULL); - - rc = rng_ops->init(dev); - if (rc) - goto err_out; - - rc = misc_register (&rng_miscdev); - if (rc) { - printk (KERN_ERR PFX "misc device register failed\n"); - goto err_out_cleanup_hw; - } - - DPRINTK ("EXIT, returning 0\n"); - return 0; - -err_out_cleanup_hw: - rng_ops->cleanup(); -err_out: - DPRINTK ("EXIT, returning %d\n", rc); - return rc; -} - - - -MODULE_AUTHOR("The Linux Kernel team"); -MODULE_DESCRIPTION("H/W Random Number Generator (RNG) driver"); -MODULE_LICENSE("GPL"); - - -/* - * rng_init - initialize RNG module - */ -static int __init rng_init (void) -{ - int rc; - struct pci_dev *pdev = NULL; - const struct pci_device_id *ent; - - DPRINTK ("ENTER\n"); - - /* Probe for Intel, AMD, Geode RNGs */ - for_each_pci_dev(pdev) { - ent = pci_match_id(rng_pci_tbl, pdev); - if (ent) { - rng_ops = &rng_vendor_ops[ent->driver_data]; - goto match; - } - } - -#ifdef __i386__ - /* Probe for VIA RNG */ - if (cpu_has_xstore) { - rng_ops = &rng_vendor_ops[rng_hw_via]; - pdev = NULL; - goto match; - } -#endif - - DPRINTK ("EXIT, returning -ENODEV\n"); - return -ENODEV; - -match: - rc = rng_init_one (pdev); - if (rc) - return rc; - - pr_info( RNG_DRIVER_NAME " loaded\n"); - - DPRINTK ("EXIT, returning 0\n"); - return 0; -} - - -/* - * rng_init - shutdown RNG module - */ -static void __exit rng_cleanup (void) -{ - DPRINTK ("ENTER\n"); - - misc_deregister (&rng_miscdev); - - if (rng_ops->cleanup) - rng_ops->cleanup(); - - DPRINTK ("EXIT\n"); -} - - -module_init (rng_init); -module_exit (rng_cleanup); -- cgit v1.2.3-70-g09d2 From 844dd05fec172d98b0dacecd9b9e9f6595204c13 Mon Sep 17 00:00:00 2001 From: Michael Buesch Date: Mon, 26 Jun 2006 00:24:59 -0700 Subject: [PATCH] Add new generic HW RNG core Signed-off-by: Michael Buesch Cc: Jeff Garzik Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- MAINTAINERS | 15 ++ drivers/char/Kconfig | 2 + drivers/char/Makefile | 1 + drivers/char/hw_random/Kconfig | 11 ++ drivers/char/hw_random/Makefile | 5 + drivers/char/hw_random/core.c | 354 ++++++++++++++++++++++++++++++++++++++++ include/linux/hw_random.h | 50 ++++++ 7 files changed, 438 insertions(+) create mode 100644 drivers/char/hw_random/Kconfig create mode 100644 drivers/char/hw_random/Makefile create mode 100644 drivers/char/hw_random/core.c create mode 100644 include/linux/hw_random.h (limited to 'drivers/char') diff --git a/MAINTAINERS b/MAINTAINERS index 4dcd2f1f14d..28c0a967692 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1118,6 +1118,11 @@ L: lm-sensors@lm-sensors.org W: http://www.lm-sensors.nu/ S: Maintained +HARDWARE RANDOM NUMBER GENERATOR CORE +P: Michael Buesch +M: mb@bu3sch.de +S: Maintained + HARD DRIVE ACTIVE PROTECTION SYSTEM (HDAPS) DRIVER P: Robert Love M: rlove@rlove.org @@ -1436,6 +1441,11 @@ P: Tigran Aivazian M: tigran@veritas.com S: Maintained +INTEL IXP4XX RANDOM NUMBER GENERATOR SUPPORT +P: Deepak Saxena +M: dsaxena@plexity.net +S: Maintained + INTEL PRO/100 ETHERNET SUPPORT P: John Ronciak M: john.ronciak@intel.com @@ -2725,6 +2735,11 @@ P: Christoph Hellwig M: hch@infradead.org S: Maintained +TI OMAP RANDOM NUMBER GENERATOR SUPPORT +P: Deepak Saxena +M: dsaxena@plexity.net +S: Maintained + TI PARALLEL LINK CABLE DRIVER P: Romain Lievin M: roms@lpg.ticalc.org diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index e4b44c68ad0..ed31638bd75 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -670,6 +670,8 @@ config NWFLASH If you're not sure, say N. +source "drivers/char/hw_random/Kconfig" + config NVRAM tristate "/dev/nvram support" depends on ATARI || X86 || ARM || GENERIC_NVRAM diff --git a/drivers/char/Makefile b/drivers/char/Makefile index 79aecef93b6..524105597ea 100644 --- a/drivers/char/Makefile +++ b/drivers/char/Makefile @@ -75,6 +75,7 @@ endif obj-$(CONFIG_TOSHIBA) += toshiba.o obj-$(CONFIG_I8K) += i8k.o obj-$(CONFIG_DS1620) += ds1620.o +obj-$(CONFIG_HW_RANDOM) += hw_random/ obj-$(CONFIG_FTAPE) += ftape/ obj-$(CONFIG_COBALT_LCD) += lcd.o obj-$(CONFIG_PPDEV) += ppdev.o diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig new file mode 100644 index 00000000000..fa4a245127a --- /dev/null +++ b/drivers/char/hw_random/Kconfig @@ -0,0 +1,11 @@ +# +# Hardware Random Number Generator (RNG) configuration +# + +config HW_RANDOM + bool "Hardware Random Number Generator Core support" + default y + ---help--- + Hardware Random Number Generator Core infrastructure. + + If unsure, say Y. diff --git a/drivers/char/hw_random/Makefile b/drivers/char/hw_random/Makefile new file mode 100644 index 00000000000..aa752af468c --- /dev/null +++ b/drivers/char/hw_random/Makefile @@ -0,0 +1,5 @@ +# +# Makefile for HW Random Number Generator (RNG) device drivers. +# + +obj-$(CONFIG_HW_RANDOM) += core.o diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c new file mode 100644 index 00000000000..88b026639f1 --- /dev/null +++ b/drivers/char/hw_random/core.c @@ -0,0 +1,354 @@ +/* + Added support for the AMD Geode LX RNG + (c) Copyright 2004-2005 Advanced Micro Devices, Inc. + + derived from + + Hardware driver for the Intel/AMD/VIA Random Number Generators (RNG) + (c) Copyright 2003 Red Hat Inc + + derived from + + Hardware driver for the AMD 768 Random Number Generator (RNG) + (c) Copyright 2001 Red Hat Inc + + derived from + + Hardware driver for Intel i810 Random Number Generator (RNG) + Copyright 2000,2001 Jeff Garzik + Copyright 2000,2001 Philipp Rumpf + + Added generic RNG API + Copyright 2006 Michael Buesch + Copyright 2005 (c) MontaVista Software, Inc. + + Please read Documentation/hw_random.txt for details on use. + + ---------------------------------------------------------- + This software may be used and distributed according to the terms + of the GNU General Public License, incorporated herein by reference. + + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#define RNG_MODULE_NAME "hw_random" +#define PFX RNG_MODULE_NAME ": " +#define RNG_MISCDEV_MINOR 183 /* official */ + + +static struct hwrng *current_rng; +static LIST_HEAD(rng_list); +static DEFINE_MUTEX(rng_mutex); + + +static inline int hwrng_init(struct hwrng *rng) +{ + if (!rng->init) + return 0; + return rng->init(rng); +} + +static inline void hwrng_cleanup(struct hwrng *rng) +{ + if (rng && rng->cleanup) + rng->cleanup(rng); +} + +static inline int hwrng_data_present(struct hwrng *rng) +{ + if (!rng->data_present) + return 1; + return rng->data_present(rng); +} + +static inline int hwrng_data_read(struct hwrng *rng, u32 *data) +{ + return rng->data_read(rng, data); +} + + +static int rng_dev_open(struct inode *inode, struct file *filp) +{ + /* enforce read-only access to this chrdev */ + if ((filp->f_mode & FMODE_READ) == 0) + return -EINVAL; + if (filp->f_mode & FMODE_WRITE) + return -EINVAL; + return 0; +} + +static ssize_t rng_dev_read(struct file *filp, char __user *buf, + size_t size, loff_t *offp) +{ + u32 data; + ssize_t ret = 0; + int i, err = 0; + int data_present; + int bytes_read; + + while (size) { + err = -ERESTARTSYS; + if (mutex_lock_interruptible(&rng_mutex)) + goto out; + if (!current_rng) { + mutex_unlock(&rng_mutex); + err = -ENODEV; + goto out; + } + if (filp->f_flags & O_NONBLOCK) { + data_present = hwrng_data_present(current_rng); + } else { + /* Some RNG require some time between data_reads to gather + * new entropy. Poll it. + */ + for (i = 0; i < 20; i++) { + data_present = hwrng_data_present(current_rng); + if (data_present) + break; + udelay(10); + } + } + bytes_read = 0; + if (data_present) + bytes_read = hwrng_data_read(current_rng, &data); + mutex_unlock(&rng_mutex); + + err = -EAGAIN; + if (!bytes_read && (filp->f_flags & O_NONBLOCK)) + goto out; + + err = -EFAULT; + while (bytes_read && size) { + if (put_user((u8)data, buf++)) + goto out; + size--; + ret++; + bytes_read--; + data >>= 8; + } + + if (need_resched()) + schedule_timeout_interruptible(1); + err = -ERESTARTSYS; + if (signal_pending(current)) + goto out; + } +out: + return ret ? : err; +} + + +static struct file_operations rng_chrdev_ops = { + .owner = THIS_MODULE, + .open = rng_dev_open, + .read = rng_dev_read, +}; + +static struct miscdevice rng_miscdev = { + .minor = RNG_MISCDEV_MINOR, + .name = RNG_MODULE_NAME, + .fops = &rng_chrdev_ops, +}; + + +static ssize_t hwrng_attr_current_store(struct class_device *class, + const char *buf, size_t len) +{ + int err; + struct hwrng *rng; + + err = mutex_lock_interruptible(&rng_mutex); + if (err) + return -ERESTARTSYS; + err = -ENODEV; + list_for_each_entry(rng, &rng_list, list) { + if (strcmp(rng->name, buf) == 0) { + if (rng == current_rng) { + err = 0; + break; + } + err = hwrng_init(rng); + if (err) + break; + hwrng_cleanup(current_rng); + current_rng = rng; + err = 0; + break; + } + } + mutex_unlock(&rng_mutex); + + return err ? : len; +} + +static ssize_t hwrng_attr_current_show(struct class_device *class, + char *buf) +{ + int err; + ssize_t ret; + const char *name = "none"; + + err = mutex_lock_interruptible(&rng_mutex); + if (err) + return -ERESTARTSYS; + if (current_rng) + name = current_rng->name; + ret = snprintf(buf, PAGE_SIZE, "%s\n", name); + mutex_unlock(&rng_mutex); + + return ret; +} + +static ssize_t hwrng_attr_available_show(struct class_device *class, + char *buf) +{ + int err; + ssize_t ret = 0; + struct hwrng *rng; + + err = mutex_lock_interruptible(&rng_mutex); + if (err) + return -ERESTARTSYS; + buf[0] = '\0'; + list_for_each_entry(rng, &rng_list, list) { + strncat(buf, rng->name, PAGE_SIZE - ret - 1); + ret += strlen(rng->name); + strncat(buf, " ", PAGE_SIZE - ret - 1); + ret++; + } + strncat(buf, "\n", PAGE_SIZE - ret - 1); + ret++; + mutex_unlock(&rng_mutex); + + return ret; +} + +static CLASS_DEVICE_ATTR(rng_current, S_IRUGO | S_IWUSR, + hwrng_attr_current_show, + hwrng_attr_current_store); +static CLASS_DEVICE_ATTR(rng_available, S_IRUGO, + hwrng_attr_available_show, + NULL); + + +static void unregister_miscdev(void) +{ + class_device_remove_file(rng_miscdev.class, + &class_device_attr_rng_available); + class_device_remove_file(rng_miscdev.class, + &class_device_attr_rng_current); + misc_deregister(&rng_miscdev); +} + +static int register_miscdev(void) +{ + int err; + + err = misc_register(&rng_miscdev); + if (err) + goto out; + err = class_device_create_file(rng_miscdev.class, + &class_device_attr_rng_current); + if (err) + goto err_misc_dereg; + err = class_device_create_file(rng_miscdev.class, + &class_device_attr_rng_available); + if (err) + goto err_remove_current; +out: + return err; + +err_remove_current: + class_device_remove_file(rng_miscdev.class, + &class_device_attr_rng_current); +err_misc_dereg: + misc_deregister(&rng_miscdev); + goto out; +} + +int hwrng_register(struct hwrng *rng) +{ + int must_register_misc; + int err = -EINVAL; + struct hwrng *old_rng, *tmp; + + if (rng->name == NULL || + rng->data_read == NULL) + goto out; + + mutex_lock(&rng_mutex); + + /* Must not register two RNGs with the same name. */ + err = -EEXIST; + list_for_each_entry(tmp, &rng_list, list) { + if (strcmp(tmp->name, rng->name) == 0) + goto out_unlock; + } + + must_register_misc = (current_rng == NULL); + old_rng = current_rng; + if (!old_rng) { + err = hwrng_init(rng); + if (err) + goto out_unlock; + current_rng = rng; + } + err = 0; + if (must_register_misc) { + err = register_miscdev(); + if (err) { + if (!old_rng) { + hwrng_cleanup(rng); + current_rng = NULL; + } + goto out_unlock; + } + } + INIT_LIST_HEAD(&rng->list); + list_add_tail(&rng->list, &rng_list); +out_unlock: + mutex_unlock(&rng_mutex); +out: + return err; +} +EXPORT_SYMBOL_GPL(hwrng_register); + +void hwrng_unregister(struct hwrng *rng) +{ + int err; + + mutex_lock(&rng_mutex); + + list_del(&rng->list); + if (current_rng == rng) { + hwrng_cleanup(rng); + if (list_empty(&rng_list)) { + current_rng = NULL; + } else { + current_rng = list_entry(rng_list.prev, struct hwrng, list); + err = hwrng_init(current_rng); + if (err) + current_rng = NULL; + } + } + if (list_empty(&rng_list)) + unregister_miscdev(); + + mutex_unlock(&rng_mutex); +} +EXPORT_SYMBOL_GPL(hwrng_unregister); + + +MODULE_DESCRIPTION("H/W Random Number Generator (RNG) driver"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/hw_random.h b/include/linux/hw_random.h new file mode 100644 index 00000000000..21ea7610e17 --- /dev/null +++ b/include/linux/hw_random.h @@ -0,0 +1,50 @@ +/* + Hardware Random Number Generator + + Please read Documentation/hw_random.txt for details on use. + + ---------------------------------------------------------- + This software may be used and distributed according to the terms + of the GNU General Public License, incorporated herein by reference. + + */ + +#ifndef LINUX_HWRANDOM_H_ +#define LINUX_HWRANDOM_H_ +#ifdef __KERNEL__ + +#include +#include + +/** + * struct hwrng - Hardware Random Number Generator driver + * @name: Unique RNG name. + * @init: Initialization callback (can be NULL). + * @cleanup: Cleanup callback (can be NULL). + * @data_present: Callback to determine if data is available + * on the RNG. If NULL, it is assumed that + * there is always data available. + * @data_read: Read data from the RNG device. + * Returns the number of lower random bytes in "data". + * Must not be NULL. + * @priv: Private data, for use by the RNG driver. + */ +struct hwrng { + const char *name; + int (*init)(struct hwrng *rng); + void (*cleanup)(struct hwrng *rng); + int (*data_present)(struct hwrng *rng); + int (*data_read)(struct hwrng *rng, u32 *data); + unsigned long priv; + + /* internal. */ + struct list_head list; +}; + +/** Register a new Hardware Random Number Generator driver. */ +extern int hwrng_register(struct hwrng *rng); +/** Unregister a Hardware Random Number Generator driver. */ +extern void hwrng_unregister(struct hwrng *rng); + +#endif /* __KERNEL__ */ +#endif /* LINUX_HWRANDOM_H_ */ -- cgit v1.2.3-70-g09d2 From ca644bd5039566725b7c71a559e65ea91b7abfb5 Mon Sep 17 00:00:00 2001 From: Michael Buesch Date: Mon, 26 Jun 2006 00:24:59 -0700 Subject: [PATCH] Add Intel HW RNG driver Signed-off-by: Michael Buesch Cc: Jeff Garzik Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/hw_random/Kconfig | 13 +++ drivers/char/hw_random/Makefile | 1 + drivers/char/hw_random/intel-rng.c | 189 +++++++++++++++++++++++++++++++++++++ 3 files changed, 203 insertions(+) create mode 100644 drivers/char/hw_random/intel-rng.c (limited to 'drivers/char') diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig index fa4a245127a..e9ae4b1313a 100644 --- a/drivers/char/hw_random/Kconfig +++ b/drivers/char/hw_random/Kconfig @@ -9,3 +9,16 @@ config HW_RANDOM Hardware Random Number Generator Core infrastructure. If unsure, say Y. + +config HW_RANDOM_INTEL + tristate "Intel HW Random Number Generator support" + depends on HW_RANDOM && (X86 || IA64) && PCI + default y + ---help--- + This driver provides kernel-side support for the Random Number + Generator hardware found on Intel i8xx-based motherboards. + + To compile this driver as a module, choose M here: the + module will be called intel-rng. + + If unsure, say Y. diff --git a/drivers/char/hw_random/Makefile b/drivers/char/hw_random/Makefile index aa752af468c..d3118e3750a 100644 --- a/drivers/char/hw_random/Makefile +++ b/drivers/char/hw_random/Makefile @@ -3,3 +3,4 @@ # obj-$(CONFIG_HW_RANDOM) += core.o +obj-$(CONFIG_HW_RANDOM_INTEL) += intel-rng.o diff --git a/drivers/char/hw_random/intel-rng.c b/drivers/char/hw_random/intel-rng.c new file mode 100644 index 00000000000..6594bd5645f --- /dev/null +++ b/drivers/char/hw_random/intel-rng.c @@ -0,0 +1,189 @@ +/* + * RNG driver for Intel RNGs + * + * Copyright 2005 (c) MontaVista Software, Inc. + * + * with the majority of the code coming from: + * + * Hardware driver for the Intel/AMD/VIA Random Number Generators (RNG) + * (c) Copyright 2003 Red Hat Inc + * + * derived from + * + * Hardware driver for the AMD 768 Random Number Generator (RNG) + * (c) Copyright 2001 Red Hat Inc + * + * derived from + * + * Hardware driver for Intel i810 Random Number Generator (RNG) + * Copyright 2000,2001 Jeff Garzik + * Copyright 2000,2001 Philipp Rumpf + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include +#include + + +#define PFX KBUILD_MODNAME ": " + +/* + * RNG registers + */ +#define INTEL_RNG_HW_STATUS 0 +#define INTEL_RNG_PRESENT 0x40 +#define INTEL_RNG_ENABLED 0x01 +#define INTEL_RNG_STATUS 1 +#define INTEL_RNG_DATA_PRESENT 0x01 +#define INTEL_RNG_DATA 2 + +/* + * Magic address at which Intel PCI bridges locate the RNG + */ +#define INTEL_RNG_ADDR 0xFFBC015F +#define INTEL_RNG_ADDR_LEN 3 + +/* + * Data for PCI driver interface + * + * This data only exists for exporting the supported + * PCI ids via MODULE_DEVICE_TABLE. We do not actually + * register a pci_driver, because someone else might one day + * want to register another driver on the same PCI id. + */ +static const struct pci_device_id pci_tbl[] = { + { 0x8086, 0x2418, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, + { 0x8086, 0x2428, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, + { 0x8086, 0x2430, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, + { 0x8086, 0x2448, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, + { 0x8086, 0x244e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, + { 0x8086, 0x245e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, + { 0, }, /* terminate list */ +}; +MODULE_DEVICE_TABLE(pci, pci_tbl); + + +static inline u8 hwstatus_get(void __iomem *mem) +{ + return readb(mem + INTEL_RNG_HW_STATUS); +} + +static inline u8 hwstatus_set(void __iomem *mem, + u8 hw_status) +{ + writeb(hw_status, mem + INTEL_RNG_HW_STATUS); + return hwstatus_get(mem); +} + +static int intel_rng_data_present(struct hwrng *rng) +{ + void __iomem *mem = (void __iomem *)rng->priv; + + return !!(readb(mem + INTEL_RNG_STATUS) & INTEL_RNG_DATA_PRESENT); +} + +static int intel_rng_data_read(struct hwrng *rng, u32 *data) +{ + void __iomem *mem = (void __iomem *)rng->priv; + + *data = readb(mem + INTEL_RNG_DATA); + + return 1; +} + +static int intel_rng_init(struct hwrng *rng) +{ + void __iomem *mem = (void __iomem *)rng->priv; + u8 hw_status; + int err = -EIO; + + hw_status = hwstatus_get(mem); + /* turn RNG h/w on, if it's off */ + if ((hw_status & INTEL_RNG_ENABLED) == 0) + hw_status = hwstatus_set(mem, hw_status | INTEL_RNG_ENABLED); + if ((hw_status & INTEL_RNG_ENABLED) == 0) { + printk(KERN_ERR PFX "cannot enable RNG, aborting\n"); + goto out; + } + err = 0; +out: + return err; +} + +static void intel_rng_cleanup(struct hwrng *rng) +{ + void __iomem *mem = (void __iomem *)rng->priv; + u8 hw_status; + + hw_status = hwstatus_get(mem); + if (hw_status & INTEL_RNG_ENABLED) + hwstatus_set(mem, hw_status & ~INTEL_RNG_ENABLED); + else + printk(KERN_WARNING PFX "unusual: RNG already disabled\n"); +} + + +static struct hwrng intel_rng = { + .name = "intel", + .init = intel_rng_init, + .cleanup = intel_rng_cleanup, + .data_present = intel_rng_data_present, + .data_read = intel_rng_data_read, +}; + + +static int __init mod_init(void) +{ + int err = -ENODEV; + void __iomem *mem; + u8 hw_status; + + if (!pci_dev_present(pci_tbl)) + goto out; /* Device not found. */ + + err = -ENOMEM; + mem = ioremap(INTEL_RNG_ADDR, INTEL_RNG_ADDR_LEN); + if (!mem) + goto out; + intel_rng.priv = (unsigned long)mem; + + /* Check for Intel 82802 */ + err = -ENODEV; + hw_status = hwstatus_get(mem); + if ((hw_status & INTEL_RNG_PRESENT) == 0) + goto err_unmap; + + printk(KERN_INFO "Intel 82802 RNG detected\n"); + err = hwrng_register(&intel_rng); + if (err) { + printk(KERN_ERR PFX "RNG registering failed (%d)\n", + err); + goto out; + } +out: + return err; + +err_unmap: + iounmap(mem); + goto out; +} + +static void __exit mod_exit(void) +{ + void __iomem *mem = (void __iomem *)intel_rng.priv; + + hwrng_unregister(&intel_rng); + iounmap(mem); +} + +subsys_initcall(mod_init); +module_exit(mod_exit); + +MODULE_DESCRIPTION("H/W RNG driver for Intel chipsets"); +MODULE_LICENSE("GPL"); -- cgit v1.2.3-70-g09d2 From 96d63c0297ccfd6d9059c614b3f5555d9441a2b3 Mon Sep 17 00:00:00 2001 From: Michael Buesch Date: Mon, 26 Jun 2006 00:25:00 -0700 Subject: [PATCH] Add AMD HW RNG driver Signed-off-by: Michael Buesch Cc: Jeff Garzik Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/hw_random/Kconfig | 13 ++++ drivers/char/hw_random/Makefile | 1 + drivers/char/hw_random/amd-rng.c | 152 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 166 insertions(+) create mode 100644 drivers/char/hw_random/amd-rng.c (limited to 'drivers/char') diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig index e9ae4b1313a..950247313ca 100644 --- a/drivers/char/hw_random/Kconfig +++ b/drivers/char/hw_random/Kconfig @@ -22,3 +22,16 @@ config HW_RANDOM_INTEL module will be called intel-rng. If unsure, say Y. + +config HW_RANDOM_AMD + tristate "AMD HW Random Number Generator support" + depends on HW_RANDOM && X86 && PCI + default y + ---help--- + This driver provides kernel-side support for the Random Number + Generator hardware found on AMD 76x-based motherboards. + + To compile this driver as a module, choose M here: the + module will be called amd-rng. + + If unsure, say Y. diff --git a/drivers/char/hw_random/Makefile b/drivers/char/hw_random/Makefile index d3118e3750a..40dbc097a5d 100644 --- a/drivers/char/hw_random/Makefile +++ b/drivers/char/hw_random/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_HW_RANDOM) += core.o obj-$(CONFIG_HW_RANDOM_INTEL) += intel-rng.o +obj-$(CONFIG_HW_RANDOM_AMD) += amd-rng.o diff --git a/drivers/char/hw_random/amd-rng.c b/drivers/char/hw_random/amd-rng.c new file mode 100644 index 00000000000..71e4e0f3fd5 --- /dev/null +++ b/drivers/char/hw_random/amd-rng.c @@ -0,0 +1,152 @@ +/* + * RNG driver for AMD RNGs + * + * Copyright 2005 (c) MontaVista Software, Inc. + * + * with the majority of the code coming from: + * + * Hardware driver for the Intel/AMD/VIA Random Number Generators (RNG) + * (c) Copyright 2003 Red Hat Inc + * + * derived from + * + * Hardware driver for the AMD 768 Random Number Generator (RNG) + * (c) Copyright 2001 Red Hat Inc + * + * derived from + * + * Hardware driver for Intel i810 Random Number Generator (RNG) + * Copyright 2000,2001 Jeff Garzik + * Copyright 2000,2001 Philipp Rumpf + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include +#include + + +#define PFX KBUILD_MODNAME ": " + + +/* + * Data for PCI driver interface + * + * This data only exists for exporting the supported + * PCI ids via MODULE_DEVICE_TABLE. We do not actually + * register a pci_driver, because someone else might one day + * want to register another driver on the same PCI id. + */ +static const struct pci_device_id pci_tbl[] = { + { 0x1022, 0x7443, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, + { 0x1022, 0x746b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, + { 0, }, /* terminate list */ +}; +MODULE_DEVICE_TABLE(pci, pci_tbl); + +static struct pci_dev *amd_pdev; + + +static int amd_rng_data_present(struct hwrng *rng) +{ + u32 pmbase = (u32)rng->priv; + + return !!(inl(pmbase + 0xF4) & 1); +} + +static int amd_rng_data_read(struct hwrng *rng, u32 *data) +{ + u32 pmbase = (u32)rng->priv; + + *data = inl(pmbase + 0xF0); + + return 4; +} + +static int amd_rng_init(struct hwrng *rng) +{ + u8 rnen; + + pci_read_config_byte(amd_pdev, 0x40, &rnen); + rnen |= (1 << 7); /* RNG on */ + pci_write_config_byte(amd_pdev, 0x40, rnen); + + pci_read_config_byte(amd_pdev, 0x41, &rnen); + rnen |= (1 << 7); /* PMIO enable */ + pci_write_config_byte(amd_pdev, 0x41, rnen); + + return 0; +} + +static void amd_rng_cleanup(struct hwrng *rng) +{ + u8 rnen; + + pci_read_config_byte(amd_pdev, 0x40, &rnen); + rnen &= ~(1 << 7); /* RNG off */ + pci_write_config_byte(amd_pdev, 0x40, rnen); +} + + +static struct hwrng amd_rng = { + .name = "amd", + .init = amd_rng_init, + .cleanup = amd_rng_cleanup, + .data_present = amd_rng_data_present, + .data_read = amd_rng_data_read, +}; + + +static int __init mod_init(void) +{ + int err = -ENODEV; + struct pci_dev *pdev = NULL; + const struct pci_device_id *ent; + u32 pmbase; + + for_each_pci_dev(pdev) { + ent = pci_match_id(pci_tbl, pdev); + if (ent) + goto found; + } + /* Device not found. */ + goto out; + +found: + err = pci_read_config_dword(pdev, 0x58, &pmbase); + if (err) + goto out; + err = -EIO; + pmbase &= 0x0000FF00; + if (pmbase == 0) + goto out; + amd_rng.priv = (unsigned long)pmbase; + amd_pdev = pdev; + + printk(KERN_INFO "AMD768 RNG detected\n"); + err = hwrng_register(&amd_rng); + if (err) { + printk(KERN_ERR PFX "RNG registering failed (%d)\n", + err); + goto out; + } +out: + return err; +} + +static void __exit mod_exit(void) +{ + hwrng_unregister(&amd_rng); +} + +subsys_initcall(mod_init); +module_exit(mod_exit); + +MODULE_AUTHOR("The Linux Kernel team"); +MODULE_DESCRIPTION("H/W RNG driver for AMD chipsets"); +MODULE_LICENSE("GPL"); -- cgit v1.2.3-70-g09d2 From ef5d862734b84239e0140319a95fb0bbff5ef394 Mon Sep 17 00:00:00 2001 From: Michael Buesch Date: Mon, 26 Jun 2006 00:25:01 -0700 Subject: [PATCH] Add Geode HW RNG driver Signed-off-by: Michael Buesch Cc: Jeff Garzik Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/hw_random/Kconfig | 13 ++++ drivers/char/hw_random/Makefile | 1 + drivers/char/hw_random/geode-rng.c | 128 +++++++++++++++++++++++++++++++++++++ 3 files changed, 142 insertions(+) create mode 100644 drivers/char/hw_random/geode-rng.c (limited to 'drivers/char') diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig index 950247313ca..defe6873695 100644 --- a/drivers/char/hw_random/Kconfig +++ b/drivers/char/hw_random/Kconfig @@ -35,3 +35,16 @@ config HW_RANDOM_AMD module will be called amd-rng. If unsure, say Y. + +config HW_RANDOM_GEODE + tristate "AMD Geode HW Random Number Generator support" + depends on HW_RANDOM && X86 && PCI + default y + ---help--- + This driver provides kernel-side support for the Random Number + Generator hardware found on the AMD Geode LX. + + To compile this driver as a module, choose M here: the + module will be called geode-rng. + + If unsure, say Y. diff --git a/drivers/char/hw_random/Makefile b/drivers/char/hw_random/Makefile index 40dbc097a5d..19ff20e5fb1 100644 --- a/drivers/char/hw_random/Makefile +++ b/drivers/char/hw_random/Makefile @@ -5,3 +5,4 @@ obj-$(CONFIG_HW_RANDOM) += core.o obj-$(CONFIG_HW_RANDOM_INTEL) += intel-rng.o obj-$(CONFIG_HW_RANDOM_AMD) += amd-rng.o +obj-$(CONFIG_HW_RANDOM_GEODE) += geode-rng.o diff --git a/drivers/char/hw_random/geode-rng.c b/drivers/char/hw_random/geode-rng.c new file mode 100644 index 00000000000..be61f22ee7b --- /dev/null +++ b/drivers/char/hw_random/geode-rng.c @@ -0,0 +1,128 @@ +/* + * RNG driver for AMD Geode RNGs + * + * Copyright 2005 (c) MontaVista Software, Inc. + * + * with the majority of the code coming from: + * + * Hardware driver for the Intel/AMD/VIA Random Number Generators (RNG) + * (c) Copyright 2003 Red Hat Inc + * + * derived from + * + * Hardware driver for the AMD 768 Random Number Generator (RNG) + * (c) Copyright 2001 Red Hat Inc + * + * derived from + * + * Hardware driver for Intel i810 Random Number Generator (RNG) + * Copyright 2000,2001 Jeff Garzik + * Copyright 2000,2001 Philipp Rumpf + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include +#include + + +#define PFX KBUILD_MODNAME ": " + +#define GEODE_RNG_DATA_REG 0x50 +#define GEODE_RNG_STATUS_REG 0x54 + +/* + * Data for PCI driver interface + * + * This data only exists for exporting the supported + * PCI ids via MODULE_DEVICE_TABLE. We do not actually + * register a pci_driver, because someone else might one day + * want to register another driver on the same PCI id. + */ +static const struct pci_device_id pci_tbl[] = { + { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_LX_AES, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, + { 0, }, /* terminate list */ +}; +MODULE_DEVICE_TABLE(pci, pci_tbl); + + +static int geode_rng_data_read(struct hwrng *rng, u32 *data) +{ + void __iomem *mem = (void __iomem *)rng->priv; + + *data = readl(mem + GEODE_RNG_DATA_REG); + + return 4; +} + +static int geode_rng_data_present(struct hwrng *rng) +{ + void __iomem *mem = (void __iomem *)rng->priv; + + return !!(readl(mem + GEODE_RNG_STATUS_REG)); +} + + +static struct hwrng geode_rng = { + .name = "geode", + .data_present = geode_rng_data_present, + .data_read = geode_rng_data_read, +}; + + +static int __init mod_init(void) +{ + int err = -ENODEV; + struct pci_dev *pdev = NULL; + const struct pci_device_id *ent; + void __iomem *mem; + unsigned long rng_base; + + for_each_pci_dev(pdev) { + ent = pci_match_id(pci_tbl, pdev); + if (ent) + goto found; + } + /* Device not found. */ + goto out; + +found: + rng_base = pci_resource_start(pdev, 0); + if (rng_base == 0) + goto out; + err = -ENOMEM; + mem = ioremap(rng_base, 0x58); + if (!mem) + goto out; + geode_rng.priv = (unsigned long)mem; + + printk(KERN_INFO "AMD Geode RNG detected\n"); + err = hwrng_register(&geode_rng); + if (err) { + printk(KERN_ERR PFX "RNG registering failed (%d)\n", + err); + goto out; + } +out: + return err; +} + +static void __exit mod_exit(void) +{ + void __iomem *mem = (void __iomem *)geode_rng.priv; + + hwrng_unregister(&geode_rng); + iounmap(mem); +} + +subsys_initcall(mod_init); +module_exit(mod_exit); + +MODULE_DESCRIPTION("H/W RNG driver for AMD Geode LX CPUs"); +MODULE_LICENSE("GPL"); -- cgit v1.2.3-70-g09d2 From 13523363577d49b9af3cad06fcb757126bedc61b Mon Sep 17 00:00:00 2001 From: Michael Buesch Date: Mon, 26 Jun 2006 00:25:02 -0700 Subject: [PATCH] Add VIA HW RNG driver Signed-off-by: Michael Buesch Cc: Jeff Garzik Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/hw_random/Kconfig | 13 +++ drivers/char/hw_random/Makefile | 1 + drivers/char/hw_random/via-rng.c | 183 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 197 insertions(+) create mode 100644 drivers/char/hw_random/via-rng.c (limited to 'drivers/char') diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig index defe6873695..01e2691d568 100644 --- a/drivers/char/hw_random/Kconfig +++ b/drivers/char/hw_random/Kconfig @@ -48,3 +48,16 @@ config HW_RANDOM_GEODE module will be called geode-rng. If unsure, say Y. + +config HW_RANDOM_VIA + tristate "VIA HW Random Number Generator support" + depends on HW_RANDOM && X86_32 + default y + ---help--- + This driver provides kernel-side support for the Random Number + Generator hardware found on VIA based motherboards. + + To compile this driver as a module, choose M here: the + module will be called via-rng. + + If unsure, say Y. diff --git a/drivers/char/hw_random/Makefile b/drivers/char/hw_random/Makefile index 19ff20e5fb1..f03bdf23f7b 100644 --- a/drivers/char/hw_random/Makefile +++ b/drivers/char/hw_random/Makefile @@ -6,3 +6,4 @@ obj-$(CONFIG_HW_RANDOM) += core.o obj-$(CONFIG_HW_RANDOM_INTEL) += intel-rng.o obj-$(CONFIG_HW_RANDOM_AMD) += amd-rng.o obj-$(CONFIG_HW_RANDOM_GEODE) += geode-rng.o +obj-$(CONFIG_HW_RANDOM_VIA) += via-rng.o diff --git a/drivers/char/hw_random/via-rng.c b/drivers/char/hw_random/via-rng.c new file mode 100644 index 00000000000..0e786b617bb --- /dev/null +++ b/drivers/char/hw_random/via-rng.c @@ -0,0 +1,183 @@ +/* + * RNG driver for VIA RNGs + * + * Copyright 2005 (c) MontaVista Software, Inc. + * + * with the majority of the code coming from: + * + * Hardware driver for the Intel/AMD/VIA Random Number Generators (RNG) + * (c) Copyright 2003 Red Hat Inc + * + * derived from + * + * Hardware driver for the AMD 768 Random Number Generator (RNG) + * (c) Copyright 2001 Red Hat Inc + * + * derived from + * + * Hardware driver for Intel i810 Random Number Generator (RNG) + * Copyright 2000,2001 Jeff Garzik + * Copyright 2000,2001 Philipp Rumpf + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include +#include +#include +#include + + +#define PFX KBUILD_MODNAME ": " + + +enum { + VIA_STRFILT_CNT_SHIFT = 16, + VIA_STRFILT_FAIL = (1 << 15), + VIA_STRFILT_ENABLE = (1 << 14), + VIA_RAWBITS_ENABLE = (1 << 13), + VIA_RNG_ENABLE = (1 << 6), + VIA_XSTORE_CNT_MASK = 0x0F, + + VIA_RNG_CHUNK_8 = 0x00, /* 64 rand bits, 64 stored bits */ + VIA_RNG_CHUNK_4 = 0x01, /* 32 rand bits, 32 stored bits */ + VIA_RNG_CHUNK_4_MASK = 0xFFFFFFFF, + VIA_RNG_CHUNK_2 = 0x02, /* 16 rand bits, 32 stored bits */ + VIA_RNG_CHUNK_2_MASK = 0xFFFF, + VIA_RNG_CHUNK_1 = 0x03, /* 8 rand bits, 32 stored bits */ + VIA_RNG_CHUNK_1_MASK = 0xFF, +}; + +/* + * Investigate using the 'rep' prefix to obtain 32 bits of random data + * in one insn. The upside is potentially better performance. The + * downside is that the instruction becomes no longer atomic. Due to + * this, just like familiar issues with /dev/random itself, the worst + * case of a 'rep xstore' could potentially pause a cpu for an + * unreasonably long time. In practice, this condition would likely + * only occur when the hardware is failing. (or so we hope :)) + * + * Another possible performance boost may come from simply buffering + * until we have 4 bytes, thus returning a u32 at a time, + * instead of the current u8-at-a-time. + */ + +static inline u32 xstore(u32 *addr, u32 edx_in) +{ + u32 eax_out; + + asm(".byte 0x0F,0xA7,0xC0 /* xstore %%edi (addr=%0) */" + :"=m"(*addr), "=a"(eax_out) + :"D"(addr), "d"(edx_in)); + + return eax_out; +} + +static int via_rng_data_present(struct hwrng *rng) +{ + u32 bytes_out; + u32 *via_rng_datum = (u32 *)(&rng->priv); + + /* We choose the recommended 1-byte-per-instruction RNG rate, + * for greater randomness at the expense of speed. Larger + * values 2, 4, or 8 bytes-per-instruction yield greater + * speed at lesser randomness. + * + * If you change this to another VIA_CHUNK_n, you must also + * change the ->n_bytes values in rng_vendor_ops[] tables. + * VIA_CHUNK_8 requires further code changes. + * + * A copy of MSR_VIA_RNG is placed in eax_out when xstore + * completes. + */ + + *via_rng_datum = 0; /* paranoia, not really necessary */ + bytes_out = xstore(via_rng_datum, VIA_RNG_CHUNK_1); + bytes_out &= VIA_XSTORE_CNT_MASK; + if (bytes_out == 0) + return 0; + return 1; +} + +static int via_rng_data_read(struct hwrng *rng, u32 *data) +{ + u32 via_rng_datum = (u32)rng->priv; + + *data = via_rng_datum; + + return 1; +} + +static int via_rng_init(struct hwrng *rng) +{ + u32 lo, hi, old_lo; + + /* Control the RNG via MSR. Tread lightly and pay very close + * close attention to values written, as the reserved fields + * are documented to be "undefined and unpredictable"; but it + * does not say to write them as zero, so I make a guess that + * we restore the values we find in the register. + */ + rdmsr(MSR_VIA_RNG, lo, hi); + + old_lo = lo; + lo &= ~(0x7f << VIA_STRFILT_CNT_SHIFT); + lo &= ~VIA_XSTORE_CNT_MASK; + lo &= ~(VIA_STRFILT_ENABLE | VIA_STRFILT_FAIL | VIA_RAWBITS_ENABLE); + lo |= VIA_RNG_ENABLE; + + if (lo != old_lo) + wrmsr(MSR_VIA_RNG, lo, hi); + + /* perhaps-unnecessary sanity check; remove after testing if + unneeded */ + rdmsr(MSR_VIA_RNG, lo, hi); + if ((lo & VIA_RNG_ENABLE) == 0) { + printk(KERN_ERR PFX "cannot enable VIA C3 RNG, aborting\n"); + return -ENODEV; + } + + return 0; +} + + +static struct hwrng via_rng = { + .name = "via", + .init = via_rng_init, + .data_present = via_rng_data_present, + .data_read = via_rng_data_read, +}; + + +static int __init mod_init(void) +{ + int err; + + if (!cpu_has_xstore) + return -ENODEV; + printk(KERN_INFO "VIA RNG detected\n"); + err = hwrng_register(&via_rng); + if (err) { + printk(KERN_ERR PFX "RNG registering failed (%d)\n", + err); + goto out; + } +out: + return err; +} + +static void __exit mod_exit(void) +{ + hwrng_unregister(&via_rng); +} + +subsys_initcall(mod_init); +module_exit(mod_exit); + +MODULE_DESCRIPTION("H/W RNG driver for VIA chipsets"); +MODULE_LICENSE("GPL"); -- cgit v1.2.3-70-g09d2 From d7174bcb919c15b295271e37c3f65c716710715c Mon Sep 17 00:00:00 2001 From: Michael Buesch Date: Mon, 26 Jun 2006 00:25:02 -0700 Subject: [PATCH] Add ixp4xx HW RNG driver Signed-off-by: Michael Buesch Cc: Jeff Garzik Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/hw_random/Kconfig | 13 +++++++ drivers/char/hw_random/Makefile | 1 + drivers/char/hw_random/ixp4xx-rng.c | 73 +++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 drivers/char/hw_random/ixp4xx-rng.c (limited to 'drivers/char') diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig index 01e2691d568..1100fd7428e 100644 --- a/drivers/char/hw_random/Kconfig +++ b/drivers/char/hw_random/Kconfig @@ -61,3 +61,16 @@ config HW_RANDOM_VIA module will be called via-rng. If unsure, say Y. + +config HW_RANDOM_IXP4XX + tristate "Intel IXP4xx NPU HW Random Number Generator support" + depends on HW_RANDOM && ARCH_IXP4XX + default y + ---help--- + This driver provides kernel-side support for the Random + Number Generator hardware found on the Intel IXP4xx NPU. + + To compile this driver as a module, choose M here: the + module will be called ixp4xx-rng. + + If unsure, say Y. diff --git a/drivers/char/hw_random/Makefile b/drivers/char/hw_random/Makefile index f03bdf23f7b..46076dfbd3f 100644 --- a/drivers/char/hw_random/Makefile +++ b/drivers/char/hw_random/Makefile @@ -7,3 +7,4 @@ obj-$(CONFIG_HW_RANDOM_INTEL) += intel-rng.o obj-$(CONFIG_HW_RANDOM_AMD) += amd-rng.o obj-$(CONFIG_HW_RANDOM_GEODE) += geode-rng.o obj-$(CONFIG_HW_RANDOM_VIA) += via-rng.o +obj-$(CONFIG_HW_RANDOM_IXP4XX) += ixp4xx-rng.o diff --git a/drivers/char/hw_random/ixp4xx-rng.c b/drivers/char/hw_random/ixp4xx-rng.c new file mode 100644 index 00000000000..ef71022423c --- /dev/null +++ b/drivers/char/hw_random/ixp4xx-rng.c @@ -0,0 +1,73 @@ +/* + * drivers/char/rng/ixp4xx-rng.c + * + * RNG driver for Intel IXP4xx family of NPUs + * + * Author: Deepak Saxena + * + * Copyright 2005 (c) MontaVista Software, Inc. + * + * Fixes by Michael Buesch + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +static int ixp4xx_rng_data_read(struct hwrng *rng, u32 *buffer) +{ + void __iomem * rng_base = (void __iomem *)rng->priv; + + *buffer = __raw_readl(rng_base); + + return 4; +} + +static struct hwrng ixp4xx_rng_ops = { + .name = "ixp4xx", + .data_read = ixp4xx_rng_data_read, +}; + +static int __init ixp4xx_rng_init(void) +{ + void __iomem * rng_base; + int err; + + rng_base = ioremap(0x70002100, 4); + if (!rng_base) + return -ENOMEM; + ixp4xx_rng_ops.priv = (unsigned long)rng_base; + err = hwrng_register(&ixp4xx_rng_ops); + if (err) + iounmap(rng_base); + + return err; +} + +static void __exit ixp4xx_rng_exit(void) +{ + void __iomem * rng_base = (void __iomem *)ixp4xx_rng_ops.priv; + + hwrng_unregister(&ixp4xx_rng_ops); + iounmap(rng_base); +} + +subsys_initcall(ixp4xx_rng_init); +module_exit(ixp4xx_rng_exit); + +MODULE_AUTHOR("Deepak Saxena "); +MODULE_DESCRIPTION("H/W Random Number Generator (RNG) driver for IXP4xx"); +MODULE_LICENSE("GPL"); -- cgit v1.2.3-70-g09d2 From ebc915ad26d881ddcafbe4e0975203d23289f36f Mon Sep 17 00:00:00 2001 From: Michael Buesch Date: Mon, 26 Jun 2006 00:25:03 -0700 Subject: [PATCH] Add TI OMAP CPU family HW RNG driver Signed-off-by: Michael Buesch Cc: Jeff Garzik Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/hw_random/Kconfig | 14 +++ drivers/char/hw_random/Makefile | 1 + drivers/char/hw_random/omap-rng.c | 208 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 223 insertions(+) create mode 100644 drivers/char/hw_random/omap-rng.c (limited to 'drivers/char') diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig index 1100fd7428e..9f7635f7517 100644 --- a/drivers/char/hw_random/Kconfig +++ b/drivers/char/hw_random/Kconfig @@ -74,3 +74,17 @@ config HW_RANDOM_IXP4XX module will be called ixp4xx-rng. If unsure, say Y. + +config HW_RANDOM_OMAP + tristate "OMAP Random Number Generator support" + depends on HW_RANDOM && (ARCH_OMAP16XX || ARCH_OMAP24XX) + default y + ---help--- + This driver provides kernel-side support for the Random Number + Generator hardware found on OMAP16xx and OMAP24xx multimedia + processors. + + To compile this driver as a module, choose M here: the + module will be called omap-rng. + + If unsure, say Y. diff --git a/drivers/char/hw_random/Makefile b/drivers/char/hw_random/Makefile index 46076dfbd3f..e263ae96f94 100644 --- a/drivers/char/hw_random/Makefile +++ b/drivers/char/hw_random/Makefile @@ -8,3 +8,4 @@ obj-$(CONFIG_HW_RANDOM_AMD) += amd-rng.o obj-$(CONFIG_HW_RANDOM_GEODE) += geode-rng.o obj-$(CONFIG_HW_RANDOM_VIA) += via-rng.o obj-$(CONFIG_HW_RANDOM_IXP4XX) += ixp4xx-rng.o +obj-$(CONFIG_HW_RANDOM_OMAP) += omap-rng.o diff --git a/drivers/char/hw_random/omap-rng.c b/drivers/char/hw_random/omap-rng.c new file mode 100644 index 00000000000..819516b35a7 --- /dev/null +++ b/drivers/char/hw_random/omap-rng.c @@ -0,0 +1,208 @@ +/* + * driver/char/hw_random/omap-rng.c + * + * RNG driver for TI OMAP CPU family + * + * Author: Deepak Saxena + * + * Copyright 2005 (c) MontaVista Software, Inc. + * + * Mostly based on original driver: + * + * Copyright (C) 2005 Nokia Corporation + * Author: Juha Yrj�� + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + * + * TODO: + * + * - Make status updated be interrupt driven so we don't poll + * + */ + +#include +#include +#include +#include +#include +#include + +#include +#include + +#define RNG_OUT_REG 0x00 /* Output register */ +#define RNG_STAT_REG 0x04 /* Status register + [0] = STAT_BUSY */ +#define RNG_ALARM_REG 0x24 /* Alarm register + [7:0] = ALARM_COUNTER */ +#define RNG_CONFIG_REG 0x28 /* Configuration register + [11:6] = RESET_COUNT + [5:3] = RING2_DELAY + [2:0] = RING1_DELAY */ +#define RNG_REV_REG 0x3c /* Revision register + [7:0] = REV_NB */ +#define RNG_MASK_REG 0x40 /* Mask and reset register + [2] = IT_EN + [1] = SOFTRESET + [0] = AUTOIDLE */ +#define RNG_SYSSTATUS 0x44 /* System status + [0] = RESETDONE */ + +static void __iomem *rng_base; +static struct clk *rng_ick; +static struct device *rng_dev; + +static u32 omap_rng_read_reg(int reg) +{ + return __raw_readl(rng_base + reg); +} + +static void omap_rng_write_reg(int reg, u32 val) +{ + __raw_writel(val, rng_base + reg); +} + +/* REVISIT: Does the status bit really work on 16xx? */ +static int omap_rng_data_present(struct hwrng *rng) +{ + return omap_rng_read_reg(RNG_STAT_REG) ? 0 : 1; +} + +static int omap_rng_data_read(struct hwrng *rng, u32 *data) +{ + *data = omap_rng_read_reg(RNG_OUT_REG); + + return 4; +} + +static struct hwrng omap_rng_ops = { + .name = "omap", + .data_present = omap_rng_data_present, + .data_read = omap_rng_data_read, +}; + +static int __init omap_rng_probe(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct resource *res, *mem; + int ret; + + /* + * A bit ugly, and it will never actually happen but there can + * be only one RNG and this catches any bork + */ + BUG_ON(rng_dev); + + if (cpu_is_omap24xx()) { + rng_ick = clk_get(NULL, "rng_ick"); + if (IS_ERR(rng_ick)) { + dev_err(dev, "Could not get rng_ick\n"); + ret = PTR_ERR(rng_ick); + return ret; + } + else { + clk_use(rng_ick); + } + } + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + + if (!res) + return -ENOENT; + + mem = request_mem_region(res->start, res->end - res->start + 1, + pdev->name); + if (mem == NULL) + return -EBUSY; + + dev_set_drvdata(dev, mem); + rng_base = (u32 __iomem *)io_p2v(res->start); + + ret = hwrng_register(&omap_rng_ops); + if (ret) { + release_resource(mem); + rng_base = NULL; + return ret; + } + + dev_info(dev, "OMAP Random Number Generator ver. %02x\n", + omap_rng_read_reg(RNG_REV_REG)); + omap_rng_write_reg(RNG_MASK_REG, 0x1); + + rng_dev = dev; + + return 0; +} + +static int __exit omap_rng_remove(struct device *dev) +{ + struct resource *mem = dev_get_drvdata(dev); + + hwrng_unregister(&omap_rng_ops); + + omap_rng_write_reg(RNG_MASK_REG, 0x0); + + if (cpu_is_omap24xx()) { + clk_unuse(rng_ick); + clk_put(rng_ick); + } + + release_resource(mem); + rng_base = NULL; + + return 0; +} + +#ifdef CONFIG_PM + +static int omap_rng_suspend(struct device *dev, pm_message_t message, u32 level) +{ + omap_rng_write_reg(RNG_MASK_REG, 0x0); + + return 0; +} + +static int omap_rng_resume(struct device *dev, pm_message_t message, u32 level) +{ + omap_rng_write_reg(RNG_MASK_REG, 0x1); + + return 1; +} + +#else + +#define omap_rng_suspend NULL +#define omap_rng_resume NULL + +#endif + + +static struct device_driver omap_rng_driver = { + .name = "omap_rng", + .bus = &platform_bus_type, + .probe = omap_rng_probe, + .remove = __exit_p(omap_rng_remove), + .suspend = omap_rng_suspend, + .resume = omap_rng_resume +}; + +static int __init omap_rng_init(void) +{ + if (!cpu_is_omap16xx() && !cpu_is_omap24xx()) + return -ENODEV; + + return driver_register(&omap_rng_driver); +} + +static void __exit omap_rng_exit(void) +{ + driver_unregister(&omap_rng_driver); +} + +module_init(omap_rng_init); +module_exit(omap_rng_exit); + +MODULE_AUTHOR("Deepak Saxena (and others)"); +MODULE_LICENSE("GPL"); -- cgit v1.2.3-70-g09d2 From ede65f3926a284f07765b94d6d9fd10d63791174 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Mon, 26 Jun 2006 00:25:09 -0700 Subject: [PATCH] hangcheck: remove monotomic_clock on x86 John's about to nuke x86's monotonic clock without grepping for it first. The patch lamely borrows the ppc64 code for x86. hangcheck-timer shouldn't be doing it this way a) HAVE_MONOTONIC should be CONFIG_MONOTONIC_CLOCK and it should be defined in arch/xxx/Kconfig. b) That ifdef tangle shouldn't be in hangcheck-timer.c. It should be using arch-provided helper functions, which CONFIG_MONOTONIC_CLOCK-enabling architectures implement in arch/something.c Cc: john stultz Acked-by: Joel Becker Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/hangcheck-timer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/hangcheck-timer.c b/drivers/char/hangcheck-timer.c index ac626418b32..d69f2ad9a67 100644 --- a/drivers/char/hangcheck-timer.c +++ b/drivers/char/hangcheck-timer.c @@ -117,12 +117,12 @@ __setup("hcheck_reboot", hangcheck_parse_reboot); __setup("hcheck_dump_tasks", hangcheck_parse_dump_tasks); #endif /* not MODULE */ -#if defined(CONFIG_X86) || defined(CONFIG_S390) +#if defined(CONFIG_X86_64) || defined(CONFIG_S390) # define HAVE_MONOTONIC # define TIMER_FREQ 1000000000ULL #elif defined(CONFIG_IA64) # define TIMER_FREQ ((unsigned long long)local_cpu_data->itc_freq) -#elif defined(CONFIG_PPC64) +#else # define TIMER_FREQ (HZ*loops_per_jiffy) #endif -- cgit v1.2.3-70-g09d2 From 4ee1acce49d616e0e3fbff76fa1dea0c7350535d Mon Sep 17 00:00:00 2001 From: David Hollister Date: Mon, 26 Jun 2006 00:26:41 -0700 Subject: [PATCH] vt: Delay the update of the visible console Delay the update of the visible framebuffer console until all other consoles have been initialized in order to avoid losing information. This only seems to be a problem with modules, not with built-in drivers. Signed-off-by: David Hollister Signed-off-by: Jordan Crouse Signed-off-by: Antonino Daplas Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/vt.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/vt.c b/drivers/char/vt.c index 6c94879e0b9..eb27eed48a8 100644 --- a/drivers/char/vt.c +++ b/drivers/char/vt.c @@ -2665,7 +2665,7 @@ int __init vty_init(void) int take_over_console(const struct consw *csw, int first, int last, int deflt) { - int i, j = -1; + int i, j = -1, k = -1; const char *desc; struct module *owner; @@ -2701,8 +2701,11 @@ int take_over_console(const struct consw *csw, int first, int last, int deflt) continue; j = i; - if (CON_IS_VISIBLE(vc)) + if (CON_IS_VISIBLE(vc)) { + k = i; save_screen(vc); + } + old_was_color = vc->vc_can_do_color; vc->vc_sw->con_deinit(vc); vc->vc_origin = (unsigned long)vc->vc_screenbuf; @@ -2718,18 +2721,23 @@ int take_over_console(const struct consw *csw, int first, int last, int deflt) */ if (old_was_color != vc->vc_can_do_color) clear_buffer_attributes(vc); - - if (CON_IS_VISIBLE(vc)) - update_screen(vc); } + printk("Console: switching "); if (!deflt) printk("consoles %d-%d ", first+1, last+1); - if (j >= 0) + if (j >= 0) { + struct vc_data *vc = vc_cons[j].d; + printk("to %s %s %dx%d\n", - vc_cons[j].d->vc_can_do_color ? "colour" : "mono", - desc, vc_cons[j].d->vc_cols, vc_cons[j].d->vc_rows); - else + vc->vc_can_do_color ? "colour" : "mono", + desc, vc->vc_cols, vc->vc_rows); + + if (k >= 0) { + vc = vc_cons[k].d; + update_screen(vc); + } + } else printk("to %s\n", desc); release_console_sem(); -- cgit v1.2.3-70-g09d2 From 1c8ce271fe707d26b7bca4e490067fe65694b363 Mon Sep 17 00:00:00 2001 From: "Antonino A. Daplas" Date: Mon, 26 Jun 2006 00:27:03 -0700 Subject: [PATCH] Detaching fbcon: fix give_up_console() To allow for detaching fbcon, it must be able to give up the console. However, the function give_up_console() is plain broken. It just sets the entries in the console driver map to NULL, it leaves the vt layer without a console driver, and does not decrement the module reference count. Calling give_up_console() is guaranteed to hang the machine.. To fix this problem, ensure that the virtual consoles are not left dangling without a driver. All systems have a default boot driver (either vgacon or dummycon) which is never unloaded. For those vt's that lost their driver, the default boot driver is reassigned back to them. Signed-off-by: Antonino Daplas Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/vt.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/vt.c b/drivers/char/vt.c index eb27eed48a8..d7ff7fdb6fe 100644 --- a/drivers/char/vt.c +++ b/drivers/char/vt.c @@ -100,6 +100,7 @@ const struct consw *conswitchp; +static struct consw *defcsw; /* default console */ /* A bitmap for codes <32. A bit of 1 indicates that the code * corresponding to that bit number invokes some special action @@ -2673,17 +2674,23 @@ int take_over_console(const struct consw *csw, int first, int last, int deflt) if (!try_module_get(owner)) return -ENODEV; - acquire_console_sem(); + /* save default console, for possible recovery later on */ + if (!defcsw) + defcsw = (struct consw *) conswitchp; + acquire_console_sem(); desc = csw->con_startup(); + if (!desc) { release_console_sem(); module_put(owner); return -ENODEV; } + if (deflt) { if (conswitchp) module_put(conswitchp->owner); + __module_get(owner); conswitchp = csw; } @@ -2701,6 +2708,7 @@ int take_over_console(const struct consw *csw, int first, int last, int deflt) continue; j = i; + if (CON_IS_VISIBLE(vc)) { k = i; save_screen(vc); @@ -2709,10 +2717,8 @@ int take_over_console(const struct consw *csw, int first, int last, int deflt) old_was_color = vc->vc_can_do_color; vc->vc_sw->con_deinit(vc); vc->vc_origin = (unsigned long)vc->vc_screenbuf; - vc->vc_visible_origin = vc->vc_origin; - vc->vc_scr_end = vc->vc_origin + vc->vc_screenbuf_size; - vc->vc_pos = vc->vc_origin + vc->vc_size_row * vc->vc_y + 2 * vc->vc_x; visual_init(vc, i, 0); + set_origin(vc); update_attr(vc); /* If the console changed between mono <-> color, then @@ -2741,22 +2747,29 @@ int take_over_console(const struct consw *csw, int first, int last, int deflt) printk("to %s\n", desc); release_console_sem(); - module_put(owner); return 0; } void give_up_console(const struct consw *csw) { - int i; + int i, first = -1, last = -1, deflt = 0; - for(i = 0; i < MAX_NR_CONSOLES; i++) + for (i = 0; i < MAX_NR_CONSOLES; i++) if (con_driver_map[i] == csw) { + if (first == -1) + first = i; + last = i; module_put(csw->owner); con_driver_map[i] = NULL; } -} + if (first != -1 && defcsw) { + if (first == 0 && last == MAX_NR_CONSOLES - 1) + deflt = 1; + take_over_console(defcsw, first, last, deflt); + } +} #endif /* -- cgit v1.2.3-70-g09d2 From 3e795de7631b2366d7301182c8d91f6d2911467b Mon Sep 17 00:00:00 2001 From: "Antonino A. Daplas" Date: Mon, 26 Jun 2006 00:27:08 -0700 Subject: [PATCH] VT binding: Add binding/unbinding support for the VT console The framebuffer console is now able to dynamically bind and unbind from the VT console layer. Due to the way the VT console layer works, the drivers themselves decide when to bind or unbind. However, it was decided that binding must be controlled, not by the drivers themselves, but by the VT console layer. With this, dynamic binding is possible for all VT console drivers, not just fbcon. Thus, the VT console layer will impose the following to all VT console drivers: - all registered VT console drivers will be entered in a private list - drivers can register themselves to the VT console layer, but they cannot decide when to bind or unbind. (Exception: To maintain backwards compatibility, take_over_console() will automatically bind the driver after registration.) - drivers can remove themselves from the list by unregistering from the VT console layer. A prerequisite for unregistration is that the driver must not be bound. The following functions are new in the vt.c: register_con_driver() - public function, this function adds the VT console driver to an internal list maintained by the VT console bind_con_driver() - private function, it binds the driver to the console take_over_console() is changed to call register_con_driver() followed by a bind_con_driver(). This is the only time drivers can decide when to bind to the VT layer. This is to maintain backwards compatibility. unbind_con_driver() - private function, it unbinds the driver from its console. The vacated consoles will be taken over by the default boot console driver. unregister_con_driver() - public function, removes the driver from the internal list maintained by the VT console. It will only succeed if the driver is currently unbound. con_is_bound() checks if the driver is currently bound or not give_up_console() is just a wrapper to unregister_con_driver(). There are also 3 additional functions meant to be called only by the tty layer for sysfs control: vt_bind() - calls bind_con_driver() vt_unbind() - calls unbind_con_driver() vt_show_drivers() - shows the list of registered drivers Most VT console drivers will continue to work as is, but might have problems when unbinding or binding which should be fixable with minimal changes. Signed-off-by: Antonino Daplas Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/vt.c | 467 ++++++++++++++++++++++++++++++++++++++++++++---- include/linux/console.h | 4 +- 2 files changed, 437 insertions(+), 34 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/vt.c b/drivers/char/vt.c index d7ff7fdb6fe..d788a0eaf26 100644 --- a/drivers/char/vt.c +++ b/drivers/char/vt.c @@ -98,9 +98,21 @@ #include #include +#define MAX_NR_CON_DRIVER 16 +#define CON_DRIVER_FLAG_BIND 1 +#define CON_DRIVER_FLAG_INIT 2 + +struct con_driver { + const struct consw *con; + const char *desc; + int first; + int last; + int flag; +}; + +static struct con_driver registered_con_driver[MAX_NR_CON_DRIVER]; const struct consw *conswitchp; -static struct consw *defcsw; /* default console */ /* A bitmap for codes <32. A bit of 1 indicates that the code * corresponding to that bit number invokes some special action @@ -2558,7 +2570,7 @@ static int __init con_init(void) { const char *display_desc = NULL; struct vc_data *vc; - unsigned int currcons = 0; + unsigned int currcons = 0, i; acquire_console_sem(); @@ -2570,6 +2582,22 @@ static int __init con_init(void) return 0; } + for (i = 0; i < MAX_NR_CON_DRIVER; i++) { + struct con_driver *con_driver = ®istered_con_driver[i]; + + if (con_driver->con == NULL) { + con_driver->con = conswitchp; + con_driver->desc = display_desc; + con_driver->flag = CON_DRIVER_FLAG_INIT; + con_driver->first = 0; + con_driver->last = MAX_NR_CONSOLES - 1; + break; + } + } + + for (i = 0; i < MAX_NR_CONSOLES; i++) + con_driver_map[i] = conswitchp; + init_timer(&console_timer); console_timer.function = blank_screen_t; if (blankinterval) { @@ -2658,33 +2686,36 @@ int __init vty_init(void) #ifndef VT_SINGLE_DRIVER -/* - * If we support more console drivers, this function is used - * when a driver wants to take over some existing consoles - * and become default driver for newly opened ones. - */ - -int take_over_console(const struct consw *csw, int first, int last, int deflt) +static int bind_con_driver(const struct consw *csw, int first, int last, + int deflt) { - int i, j = -1, k = -1; - const char *desc; - struct module *owner; + struct module *owner = csw->owner; + const char *desc = NULL; + struct con_driver *con_driver; + int i, j = -1, k = -1, retval = -ENODEV; - owner = csw->owner; if (!try_module_get(owner)) return -ENODEV; - /* save default console, for possible recovery later on */ - if (!defcsw) - defcsw = (struct consw *) conswitchp; - acquire_console_sem(); - desc = csw->con_startup(); - if (!desc) { - release_console_sem(); - module_put(owner); - return -ENODEV; + /* check if driver is registered */ + for (i = 0; i < MAX_NR_CON_DRIVER; i++) { + con_driver = ®istered_con_driver[i]; + + if (con_driver->con == csw) { + desc = con_driver->desc; + retval = 0; + break; + } + } + + if (retval) + goto err; + + if (!(con_driver->flag & CON_DRIVER_FLAG_INIT)) { + csw->con_startup(); + con_driver->flag |= CON_DRIVER_FLAG_INIT; } if (deflt) { @@ -2695,6 +2726,9 @@ int take_over_console(const struct consw *csw, int first, int last, int deflt) conswitchp = csw; } + first = max(first, con_driver->first); + last = min(last, con_driver->last); + for (i = first; i <= last; i++) { int old_was_color; struct vc_data *vc = vc_cons[i].d; @@ -2746,32 +2780,399 @@ int take_over_console(const struct consw *csw, int first, int last, int deflt) } else printk("to %s\n", desc); + retval = 0; +err: release_console_sem(); module_put(owner); - return 0; -} + return retval; +}; -void give_up_console(const struct consw *csw) +static int unbind_con_driver(const struct consw *csw, int first, int last, + int deflt) { - int i, first = -1, last = -1, deflt = 0; + struct module *owner = csw->owner; + const struct consw *defcsw = NULL; + struct con_driver *con_driver = NULL, *con_back = NULL; + int i, retval = -ENODEV; - for (i = 0; i < MAX_NR_CONSOLES; i++) + if (!try_module_get(owner)) + return -ENODEV; + + acquire_console_sem(); + + /* check if driver is registered and if it is unbindable */ + for (i = 0; i < MAX_NR_CON_DRIVER; i++) { + con_driver = ®istered_con_driver[i]; + + if (con_driver->con == csw && + con_driver->flag & CON_DRIVER_FLAG_BIND) { + retval = 0; + break; + } + } + + if (retval) { + release_console_sem(); + goto err; + } + + /* check if backup driver exists */ + for (i = 0; i < MAX_NR_CON_DRIVER; i++) { + con_back = ®istered_con_driver[i]; + + if (con_back->con && + !(con_back->flag & CON_DRIVER_FLAG_BIND)) { + defcsw = con_back->con; + retval = 0; + break; + } + } + + if (retval) { + release_console_sem(); + goto err; + } + + if (!con_is_bound(csw)) { + release_console_sem(); + goto err; + } + + first = max(first, con_driver->first); + last = min(last, con_driver->last); + + for (i = first; i <= last; i++) { if (con_driver_map[i] == csw) { - if (first == -1) - first = i; - last = i; module_put(csw->owner); con_driver_map[i] = NULL; } + } + + if (!con_is_bound(defcsw)) { + defcsw->con_startup(); + con_back->flag |= CON_DRIVER_FLAG_INIT; + } + + if (!con_is_bound(csw)) + con_driver->flag &= ~CON_DRIVER_FLAG_INIT; + + release_console_sem(); + retval = bind_con_driver(defcsw, first, last, deflt); +err: + module_put(owner); + return retval; + +} + +/** + * con_is_bound - checks if driver is bound to the console + * @csw: console driver + * + * RETURNS: zero if unbound, nonzero if bound + * + * Drivers can call this and if zero, they should release + * all resources allocated on con_startup() + */ +int con_is_bound(const struct consw *csw) +{ + int i, bound = 0; + + for (i = 0; i < MAX_NR_CONSOLES; i++) { + if (con_driver_map[i] == csw) { + bound = 1; + break; + } + } + + return bound; +} +EXPORT_SYMBOL(con_is_bound); + +/** + * register_con_driver - register console driver to console layer + * @csw: console driver + * @first: the first console to take over, minimum value is 0 + * @last: the last console to take over, maximum value is MAX_NR_CONSOLES -1 + * + * DESCRIPTION: This function registers a console driver which can later + * bind to a range of consoles specified by @first and @last. It will + * also initialize the console driver by calling con_startup(). + */ +int register_con_driver(const struct consw *csw, int first, int last) +{ + struct module *owner = csw->owner; + struct con_driver *con_driver; + const char *desc; + int i, retval = 0; + + if (!try_module_get(owner)) + return -ENODEV; + + acquire_console_sem(); + + for (i = 0; i < MAX_NR_CON_DRIVER; i++) { + con_driver = ®istered_con_driver[i]; + + /* already registered */ + if (con_driver->con == csw) + retval = -EINVAL; + } + + if (retval) + goto err; + + desc = csw->con_startup(); + + if (!desc) + goto err; + + retval = -EINVAL; + + for (i = 0; i < MAX_NR_CON_DRIVER; i++) { + con_driver = ®istered_con_driver[i]; + + if (con_driver->con == NULL) { + con_driver->con = csw; + con_driver->desc = desc; + con_driver->flag = CON_DRIVER_FLAG_BIND | + CON_DRIVER_FLAG_INIT; + con_driver->first = first; + con_driver->last = last; + retval = 0; + break; + } + } + +err: + release_console_sem(); + module_put(owner); + return retval; +} +EXPORT_SYMBOL(register_con_driver); + +/** + * unregister_con_driver - unregister console driver from console layer + * @csw: console driver + * + * DESCRIPTION: All drivers that registers to the console layer must + * call this function upon exit, or if the console driver is in a state + * where it won't be able to handle console services, such as the + * framebuffer console without loaded framebuffer drivers. + * + * The driver must unbind first prior to unregistration. + */ +int unregister_con_driver(const struct consw *csw) +{ + int i, retval = -ENODEV; + + acquire_console_sem(); + + /* cannot unregister a bound driver */ + if (con_is_bound(csw)) + goto err; + + for (i = 0; i < MAX_NR_CON_DRIVER; i++) { + struct con_driver *con_driver = ®istered_con_driver[i]; + + if (con_driver->con == csw && + con_driver->flag & CON_DRIVER_FLAG_BIND) { + con_driver->con = NULL; + con_driver->desc = NULL; + con_driver->flag = 0; + con_driver->first = 0; + con_driver->last = 0; + retval = 0; + break; + } + } + +err: + release_console_sem(); + return retval; +} +EXPORT_SYMBOL(unregister_con_driver); + +/* + * If we support more console drivers, this function is used + * when a driver wants to take over some existing consoles + * and become default driver for newly opened ones. + * + * take_over_console is basically a register followed by unbind + */ +int take_over_console(const struct consw *csw, int first, int last, int deflt) +{ + int err; + + err = register_con_driver(csw, first, last); + + if (!err) + err = bind_con_driver(csw, first, last, deflt); + + return err; +} + +/* + * give_up_console is a wrapper to unregister_con_driver. It will only + * work if driver is fully unbound. + */ +void give_up_console(const struct consw *csw) +{ + unregister_con_driver(csw); +} + +/* + * this function is intended to be called by the tty layer only + */ +int vt_bind(int index) +{ + const struct consw *defcsw = NULL, *csw = NULL; + struct con_driver *con; + int i, more = 1, first = -1, last = -1, deflt = 0; + + if (index >= MAX_NR_CON_DRIVER) + goto err; + + con = ®istered_con_driver[index]; + + if (!con->con || !(con->flag & CON_DRIVER_FLAG_BIND)) + goto err; + + csw = con->con; + + for (i = 0; i < MAX_NR_CON_DRIVER; i++) { + struct con_driver *con = ®istered_con_driver[i]; + + if (con->con && !(con->flag & CON_DRIVER_FLAG_BIND)) { + defcsw = con->con; + break; + } + } - if (first != -1 && defcsw) { - if (first == 0 && last == MAX_NR_CONSOLES - 1) + if (!defcsw) + goto err; + + while (more) { + more = 0; + + for (i = con->first; i <= con->last; i++) { + if (con_driver_map[i] == defcsw) { + if (first == -1) + first = i; + last = i; + more = 1; + } else if (first != -1) + break; + } + + if (first == 0 && last == MAX_NR_CONSOLES -1) deflt = 1; - take_over_console(defcsw, first, last, deflt); + + if (first != -1) + bind_con_driver(csw, first, last, deflt); + + first = -1; + last = -1; + deflt = 0; } + +err: + return 0; +} + +/* + * this function is intended to be called by the tty layer only + */ +int vt_unbind(int index) +{ + const struct consw *csw = NULL; + struct con_driver *con; + int i, more = 1, first = -1, last = -1, deflt = 0; + + if (index >= MAX_NR_CON_DRIVER) + goto err; + + con = ®istered_con_driver[index]; + + if (!con->con || !(con->flag & CON_DRIVER_FLAG_BIND)) + goto err; + + csw = con->con; + + while (more) { + more = 0; + + for (i = con->first; i <= con->last; i++) { + if (con_driver_map[i] == csw) { + if (first == -1) + first = i; + last = i; + more = 1; + } else if (first != -1) + break; + } + + if (first == 0 && last == MAX_NR_CONSOLES -1) + deflt = 1; + + if (first != -1) + unbind_con_driver(csw, first, last, deflt); + + first = -1; + last = -1; + deflt = 0; + } + +err: + return 0; +} +#else +int vt_bind(int index) +{ + return 0; +} + +int vt_unbind(int index) +{ + return 0; } #endif +/* + * this function is intended to be called by the tty layer only + */ +int vt_show_drivers(char *buf) +{ + int i, j, read, offset = 0, cnt = PAGE_SIZE; + + for (i = 0; i < MAX_NR_CON_DRIVER; i++) { + struct con_driver *con_driver = ®istered_con_driver[i]; + + if (con_driver->con != NULL) { + int sys = 0; + + if (con_driver->flag & CON_DRIVER_FLAG_BIND) { + sys = 2; + + for (j = 0; j < MAX_NR_CONSOLES; j++) { + if (con_driver_map[j] == + con_driver->con) { + sys = 1; + break; + } + } + } + + read = snprintf(buf + offset, cnt, "%i %s: %s\n", + i, (sys) ? ((sys == 1) ? "B" : "U") : + "S", con_driver->desc); + offset += read; + cnt -= read; + } + } + + return offset; +} + /* * Screen blanking */ diff --git a/include/linux/console.h b/include/linux/console.h index d0f8a800949..3bdf2155e56 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -63,9 +63,11 @@ extern const struct consw vga_con; /* VGA text console */ extern const struct consw newport_con; /* SGI Newport console */ extern const struct consw prom_con; /* SPARC PROM console */ +int con_is_bound(const struct consw *csw); +int register_con_driver(const struct consw *csw, int first, int last); +int unregister_con_driver(const struct consw *csw); int take_over_console(const struct consw *sw, int first, int last, int deflt); void give_up_console(const struct consw *sw); - /* scroll */ #define SM_UP (1) #define SM_DOWN (2) -- cgit v1.2.3-70-g09d2 From 6db4063c5b72b46e9793b0f141a7a3984ac6facf Mon Sep 17 00:00:00 2001 From: "Antonino A. Daplas" Date: Mon, 26 Jun 2006 00:27:12 -0700 Subject: [PATCH] VT binding: Add sysfs control to the VT layer Add sysfs control to the VT layer. A new sysfs class, 'vtconsole', and class devices 'vtcon[n]' are added. Each class device file has the following attributes: /sys/class/vtconsole/vtcon[n]/name - read-only attribute showing the name of the current backend /sys/class/vtconsole/vtcon[n]/bind - read/write attribute where: 0 - backend is unbound/unbind backend from the VT layer 1 - backend is bound/bind backend to the VT layer In addition, if any of the consoles are in KD_GRAPHICS mode, binding and unbinding will not succeed. KD_GRAPHICS mode usually indicates that the underlying console hardware is used for other purposes other than displaying text (ie X). This feature should prevent binding/unbinding from interfering with a graphics application using the VT. [akpm@osdl.org: warning fixes] Signed-off-by: Antonino Daplas Cc: Greg KH Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/vt.c | 379 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 232 insertions(+), 147 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/vt.c b/drivers/char/vt.c index d788a0eaf26..037d8a3f588 100644 --- a/drivers/char/vt.c +++ b/drivers/char/vt.c @@ -100,12 +100,14 @@ #define MAX_NR_CON_DRIVER 16 -#define CON_DRIVER_FLAG_BIND 1 +#define CON_DRIVER_FLAG_MODULE 1 #define CON_DRIVER_FLAG_INIT 2 struct con_driver { const struct consw *con; const char *desc; + struct class_device *class_dev; + int node; int first; int last; int flag; @@ -2685,6 +2687,25 @@ int __init vty_init(void) } #ifndef VT_SINGLE_DRIVER +#include + +static struct class *vtconsole_class; + +static int con_is_graphics(const struct consw *csw, int first, int last) +{ + int i, retval = 0; + + for (i = first; i <= last; i++) { + struct vc_data *vc = vc_cons[i].d; + + if (vc && vc->vc_mode == KD_GRAPHICS) { + retval = 1; + break; + } + } + + return retval; +} static int bind_con_driver(const struct consw *csw, int first, int last, int deflt) @@ -2805,7 +2826,7 @@ static int unbind_con_driver(const struct consw *csw, int first, int last, con_driver = ®istered_con_driver[i]; if (con_driver->con == csw && - con_driver->flag & CON_DRIVER_FLAG_BIND) { + con_driver->flag & CON_DRIVER_FLAG_MODULE) { retval = 0; break; } @@ -2816,12 +2837,14 @@ static int unbind_con_driver(const struct consw *csw, int first, int last, goto err; } + retval = -ENODEV; + /* check if backup driver exists */ for (i = 0; i < MAX_NR_CON_DRIVER; i++) { con_back = ®istered_con_driver[i]; if (con_back->con && - !(con_back->flag & CON_DRIVER_FLAG_BIND)) { + !(con_back->flag & CON_DRIVER_FLAG_MODULE)) { defcsw = con_back->con; retval = 0; break; @@ -2849,21 +2872,177 @@ static int unbind_con_driver(const struct consw *csw, int first, int last, } if (!con_is_bound(defcsw)) { + const struct consw *defconsw = conswitchp; + defcsw->con_startup(); con_back->flag |= CON_DRIVER_FLAG_INIT; + /* + * vgacon may change the default driver to point + * to dummycon, we restore it here... + */ + conswitchp = defconsw; } if (!con_is_bound(csw)) con_driver->flag &= ~CON_DRIVER_FLAG_INIT; release_console_sem(); - retval = bind_con_driver(defcsw, first, last, deflt); + /* ignore return value, binding should not fail */ + bind_con_driver(defcsw, first, last, deflt); err: module_put(owner); return retval; } +static int vt_bind(struct con_driver *con) +{ + const struct consw *defcsw = NULL, *csw = NULL; + int i, more = 1, first = -1, last = -1, deflt = 0; + + if (!con->con || !(con->flag & CON_DRIVER_FLAG_MODULE) || + con_is_graphics(con->con, con->first, con->last)) + goto err; + + csw = con->con; + + for (i = 0; i < MAX_NR_CON_DRIVER; i++) { + struct con_driver *con = ®istered_con_driver[i]; + + if (con->con && !(con->flag & CON_DRIVER_FLAG_MODULE)) { + defcsw = con->con; + break; + } + } + + if (!defcsw) + goto err; + + while (more) { + more = 0; + + for (i = con->first; i <= con->last; i++) { + if (con_driver_map[i] == defcsw) { + if (first == -1) + first = i; + last = i; + more = 1; + } else if (first != -1) + break; + } + + if (first == 0 && last == MAX_NR_CONSOLES -1) + deflt = 1; + + if (first != -1) + bind_con_driver(csw, first, last, deflt); + + first = -1; + last = -1; + deflt = 0; + } + +err: + return 0; +} + +static int vt_unbind(struct con_driver *con) +{ + const struct consw *csw = NULL; + int i, more = 1, first = -1, last = -1, deflt = 0; + + if (!con->con || !(con->flag & CON_DRIVER_FLAG_MODULE) || + con_is_graphics(con->con, con->first, con->last)) + goto err; + + csw = con->con; + + while (more) { + more = 0; + + for (i = con->first; i <= con->last; i++) { + if (con_driver_map[i] == csw) { + if (first == -1) + first = i; + last = i; + more = 1; + } else if (first != -1) + break; + } + + if (first == 0 && last == MAX_NR_CONSOLES -1) + deflt = 1; + + if (first != -1) + unbind_con_driver(csw, first, last, deflt); + + first = -1; + last = -1; + deflt = 0; + } + +err: + return 0; +} + +static ssize_t store_bind(struct class_device *class_device, + const char *buf, size_t count) +{ + struct con_driver *con = class_get_devdata(class_device); + int bind = simple_strtoul(buf, NULL, 0); + + if (bind) + vt_bind(con); + else + vt_unbind(con); + + return count; +} + +static ssize_t show_bind(struct class_device *class_device, char *buf) +{ + struct con_driver *con = class_get_devdata(class_device); + int bind = con_is_bound(con->con); + + return snprintf(buf, PAGE_SIZE, "%i\n", bind); +} + +static ssize_t show_name(struct class_device *class_device, char *buf) +{ + struct con_driver *con = class_get_devdata(class_device); + + return snprintf(buf, PAGE_SIZE, "%s %s\n", + (con->flag & CON_DRIVER_FLAG_MODULE) ? "(M)" : "(S)", + con->desc); + +} + +static struct class_device_attribute class_device_attrs[] = { + __ATTR(bind, S_IRUGO|S_IWUSR, show_bind, store_bind), + __ATTR(name, S_IRUGO, show_name, NULL), +}; + +static int vtconsole_init_class_device(struct con_driver *con) +{ + int i; + + class_set_devdata(con->class_dev, con); + for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) + class_device_create_file(con->class_dev, + &class_device_attrs[i]); + + return 0; +} + +static void vtconsole_deinit_class_device(struct con_driver *con) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) + class_device_remove_file(con->class_dev, + &class_device_attrs[i]); +} + /** * con_is_bound - checks if driver is bound to the console * @csw: console driver @@ -2934,7 +3113,8 @@ int register_con_driver(const struct consw *csw, int first, int last) if (con_driver->con == NULL) { con_driver->con = csw; con_driver->desc = desc; - con_driver->flag = CON_DRIVER_FLAG_BIND | + con_driver->node = i; + con_driver->flag = CON_DRIVER_FLAG_MODULE | CON_DRIVER_FLAG_INIT; con_driver->first = first; con_driver->last = last; @@ -2943,6 +3123,22 @@ int register_con_driver(const struct consw *csw, int first, int last) } } + if (retval) + goto err; + + con_driver->class_dev = class_device_create(vtconsole_class, NULL, + MKDEV(0, con_driver->node), + NULL, "vtcon%i", + con_driver->node); + + if (IS_ERR(con_driver->class_dev)) { + printk(KERN_WARNING "Unable to create class_device for %s; " + "errno = %ld\n", con_driver->desc, + PTR_ERR(con_driver->class_dev)); + con_driver->class_dev = NULL; + } else { + vtconsole_init_class_device(con_driver); + } err: release_console_sem(); module_put(owner); @@ -2975,9 +3171,14 @@ int unregister_con_driver(const struct consw *csw) struct con_driver *con_driver = ®istered_con_driver[i]; if (con_driver->con == csw && - con_driver->flag & CON_DRIVER_FLAG_BIND) { + con_driver->flag & CON_DRIVER_FLAG_MODULE) { + vtconsole_deinit_class_device(con_driver); + class_device_destroy(vtconsole_class, + MKDEV(0, con_driver->node)); con_driver->con = NULL; con_driver->desc = NULL; + con_driver->class_dev = NULL; + con_driver->node = 0; con_driver->flag = 0; con_driver->first = 0; con_driver->last = 0; @@ -2985,7 +3186,6 @@ int unregister_con_driver(const struct consw *csw) break; } } - err: release_console_sem(); return retval; @@ -3006,7 +3206,7 @@ int take_over_console(const struct consw *csw, int first, int last, int deflt) err = register_con_driver(csw, first, last); if (!err) - err = bind_con_driver(csw, first, last, deflt); + bind_con_driver(csw, first, last, deflt); return err; } @@ -3020,159 +3220,44 @@ void give_up_console(const struct consw *csw) unregister_con_driver(csw); } -/* - * this function is intended to be called by the tty layer only - */ -int vt_bind(int index) +static int __init vtconsole_class_init(void) { - const struct consw *defcsw = NULL, *csw = NULL; - struct con_driver *con; - int i, more = 1, first = -1, last = -1, deflt = 0; - - if (index >= MAX_NR_CON_DRIVER) - goto err; - - con = ®istered_con_driver[index]; - - if (!con->con || !(con->flag & CON_DRIVER_FLAG_BIND)) - goto err; + int i; - csw = con->con; + vtconsole_class = class_create(THIS_MODULE, "vtconsole"); + if (IS_ERR(vtconsole_class)) { + printk(KERN_WARNING "Unable to create vt console class; " + "errno = %ld\n", PTR_ERR(vtconsole_class)); + vtconsole_class = NULL; + } + /* Add system drivers to sysfs */ for (i = 0; i < MAX_NR_CON_DRIVER; i++) { struct con_driver *con = ®istered_con_driver[i]; - if (con->con && !(con->flag & CON_DRIVER_FLAG_BIND)) { - defcsw = con->con; - break; - } - } - - if (!defcsw) - goto err; - - while (more) { - more = 0; - - for (i = con->first; i <= con->last; i++) { - if (con_driver_map[i] == defcsw) { - if (first == -1) - first = i; - last = i; - more = 1; - } else if (first != -1) - break; - } - - if (first == 0 && last == MAX_NR_CONSOLES -1) - deflt = 1; - - if (first != -1) - bind_con_driver(csw, first, last, deflt); - - first = -1; - last = -1; - deflt = 0; - } - -err: - return 0; -} - -/* - * this function is intended to be called by the tty layer only - */ -int vt_unbind(int index) -{ - const struct consw *csw = NULL; - struct con_driver *con; - int i, more = 1, first = -1, last = -1, deflt = 0; - - if (index >= MAX_NR_CON_DRIVER) - goto err; - - con = ®istered_con_driver[index]; - - if (!con->con || !(con->flag & CON_DRIVER_FLAG_BIND)) - goto err; - - csw = con->con; - - while (more) { - more = 0; - - for (i = con->first; i <= con->last; i++) { - if (con_driver_map[i] == csw) { - if (first == -1) - first = i; - last = i; - more = 1; - } else if (first != -1) - break; + if (con->con && !con->class_dev) { + con->class_dev = + class_device_create(vtconsole_class, NULL, + MKDEV(0, con->node), NULL, + "vtcon%i", con->node); + + if (IS_ERR(con->class_dev)) { + printk(KERN_WARNING "Unable to create " + "class_device for %s; errno = %ld\n", + con->desc, PTR_ERR(con->class_dev)); + con->class_dev = NULL; + } else { + vtconsole_init_class_device(con); + } } - - if (first == 0 && last == MAX_NR_CONSOLES -1) - deflt = 1; - - if (first != -1) - unbind_con_driver(csw, first, last, deflt); - - first = -1; - last = -1; - deflt = 0; } -err: - return 0; -} -#else -int vt_bind(int index) -{ return 0; } +postcore_initcall(vtconsole_class_init); -int vt_unbind(int index) -{ - return 0; -} #endif -/* - * this function is intended to be called by the tty layer only - */ -int vt_show_drivers(char *buf) -{ - int i, j, read, offset = 0, cnt = PAGE_SIZE; - - for (i = 0; i < MAX_NR_CON_DRIVER; i++) { - struct con_driver *con_driver = ®istered_con_driver[i]; - - if (con_driver->con != NULL) { - int sys = 0; - - if (con_driver->flag & CON_DRIVER_FLAG_BIND) { - sys = 2; - - for (j = 0; j < MAX_NR_CONSOLES; j++) { - if (con_driver_map[j] == - con_driver->con) { - sys = 1; - break; - } - } - } - - read = snprintf(buf + offset, cnt, "%i %s: %s\n", - i, (sys) ? ((sys == 1) ? "B" : "U") : - "S", con_driver->desc); - offset += read; - cnt -= read; - } - } - - return offset; -} - /* * Screen blanking */ -- cgit v1.2.3-70-g09d2 From 13ae66458971b4967350765a8bfaf2a636442e5f Mon Sep 17 00:00:00 2001 From: "Antonino A. Daplas" Date: Mon, 26 Jun 2006 00:27:12 -0700 Subject: [PATCH] VT binding: Make VT binding a Kconfig option To enable this feature, CONFIG_VT_HW_CONSOLE_BINDING must be set to 'y'. This feature will default to 'n' to minimize users accidentally corrupting their virtual terminals. Signed-off-by: Antonino Daplas Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/Kconfig | 17 +++++++++++++++++ drivers/char/vt.c | 43 +++++++++++++++++++++++++++---------------- 2 files changed, 44 insertions(+), 16 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index ed31638bd75..3610c572955 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -62,6 +62,23 @@ config HW_CONSOLE depends on VT && !S390 && !UML default y +config VT_HW_CONSOLE_BINDING + bool "Support for binding and unbinding console drivers" + depends on HW_CONSOLE + default n + ---help--- + The virtual terminal is the device that interacts with the physical + terminal through console drivers. On these systems, at least one + console driver is loaded. In other configurations, additional console + drivers may be enabled, such as the framebuffer console. If more than + 1 console driver is enabled, setting this to 'y' will allow you to + select the console driver that will serve as the backend for the + virtual terminals. + + See for more + information. For framebuffer console users, please refer to + . + config SERIAL_NONSTANDARD bool "Non-standard serial port support" ---help--- diff --git a/drivers/char/vt.c b/drivers/char/vt.c index 037d8a3f588..714d95ff2f1 100644 --- a/drivers/char/vt.c +++ b/drivers/char/vt.c @@ -2691,22 +2691,6 @@ int __init vty_init(void) static struct class *vtconsole_class; -static int con_is_graphics(const struct consw *csw, int first, int last) -{ - int i, retval = 0; - - for (i = first; i <= last; i++) { - struct vc_data *vc = vc_cons[i].d; - - if (vc && vc->vc_mode == KD_GRAPHICS) { - retval = 1; - break; - } - } - - return retval; -} - static int bind_con_driver(const struct consw *csw, int first, int last, int deflt) { @@ -2808,6 +2792,23 @@ err: return retval; }; +#ifdef CONFIG_VT_HW_CONSOLE_BINDING +static int con_is_graphics(const struct consw *csw, int first, int last) +{ + int i, retval = 0; + + for (i = first; i <= last; i++) { + struct vc_data *vc = vc_cons[i].d; + + if (vc && vc->vc_mode == KD_GRAPHICS) { + retval = 1; + break; + } + } + + return retval; +} + static int unbind_con_driver(const struct consw *csw, int first, int last, int deflt) { @@ -2984,6 +2985,16 @@ static int vt_unbind(struct con_driver *con) err: return 0; } +#else +static inline int vt_bind(struct con_driver *con) +{ + return 0; +} +static inline int vt_unbind(struct con_driver *con) +{ + return 0; +} +#endif /* CONFIG_VT_HW_CONSOLE_BINDING */ static ssize_t store_bind(struct class_device *class_device, const char *buf, size_t count) -- cgit v1.2.3-70-g09d2 From a32073bffc656ca4bde6002b6cf7c1a8e0e22712 Mon Sep 17 00:00:00 2001 From: Andi Kleen Date: Mon, 26 Jun 2006 13:56:40 +0200 Subject: [PATCH] x86_64: Clean and enhance up K8 northbridge access code - Factor out the duplicated access/cache code into a single file * Shared between i386/x86-64. - Share flush code between AGP and IOMMU * Fix a bug: AGP didn't wait for end of flush before - Drop 8 northbridges limit and allocate dynamically - Add lock to serialize AGP and IOMMU GART flushes - Add PCI ID for next AMD northbridge - Random related cleanups The old K8 NUMA discovery code is unchanged. New systems should all use SRAT for this. Cc: "Navin Boppuri" Cc: Dave Jones Signed-off-by: Andi Kleen Signed-off-by: Linus Torvalds --- arch/i386/Kconfig | 4 ++ arch/i386/kernel/Makefile | 4 ++ arch/x86_64/Kconfig | 4 ++ arch/x86_64/kernel/Makefile | 1 + arch/x86_64/kernel/aperture.c | 24 ++++----- arch/x86_64/kernel/k8.c | 118 ++++++++++++++++++++++++++++++++++++++++++ arch/x86_64/kernel/pci-gart.c | 93 ++++++++------------------------- arch/x86_64/pci/k8-bus.c | 10 ++-- drivers/char/agp/amd64-agp.c | 77 +++++++++------------------ include/asm-i386/k8.h | 1 + include/asm-x86_64/k8.h | 14 +++++ 11 files changed, 209 insertions(+), 141 deletions(-) create mode 100644 arch/x86_64/kernel/k8.c create mode 100644 include/asm-i386/k8.h create mode 100644 include/asm-x86_64/k8.h (limited to 'drivers/char') diff --git a/arch/i386/Kconfig b/arch/i386/Kconfig index 1596101cfaf..2206bf6637d 100644 --- a/arch/i386/Kconfig +++ b/arch/i386/Kconfig @@ -1054,6 +1054,10 @@ config SCx200 This support is also available as a module. If compiled as a module, it will be called scx200. +config K8_NB + def_bool y + depends on AGP_AMD64 + source "drivers/pcmcia/Kconfig" source "drivers/pci/hotplug/Kconfig" diff --git a/arch/i386/kernel/Makefile b/arch/i386/kernel/Makefile index 96fb8a020af..28b14d6c7b1 100644 --- a/arch/i386/kernel/Makefile +++ b/arch/i386/kernel/Makefile @@ -37,6 +37,7 @@ obj-$(CONFIG_EFI) += efi.o efi_stub.o obj-$(CONFIG_DOUBLEFAULT) += doublefault.o obj-$(CONFIG_VM86) += vm86.o obj-$(CONFIG_EARLY_PRINTK) += early_printk.o +obj-$(CONFIG_K8_NB) += k8.o EXTRA_AFLAGS := -traditional @@ -76,3 +77,6 @@ SYSCFLAGS_vsyscall-syms.o = -r $(obj)/vsyscall-syms.o: $(src)/vsyscall.lds \ $(obj)/vsyscall-sysenter.o $(obj)/vsyscall-note.o FORCE $(call if_changed,syscall) + +k8-y += ../../x86_64/kernel/k8.o + diff --git a/arch/x86_64/Kconfig b/arch/x86_64/Kconfig index af44130f0d6..fc75275d8c7 100644 --- a/arch/x86_64/Kconfig +++ b/arch/x86_64/Kconfig @@ -501,6 +501,10 @@ config REORDER optimal TLB usage. If you have pretty much any version of binutils, this can increase your kernel build time by roughly one minute. +config K8_NB + def_bool y + depends on AGP_AMD64 || GART_IOMMU || (PCI && NUMA) + endmenu # diff --git a/arch/x86_64/kernel/Makefile b/arch/x86_64/kernel/Makefile index 381bc6ad743..f927d11065f 100644 --- a/arch/x86_64/kernel/Makefile +++ b/arch/x86_64/kernel/Makefile @@ -33,6 +33,7 @@ obj-$(CONFIG_SWIOTLB) += pci-swiotlb.o obj-$(CONFIG_KPROBES) += kprobes.o obj-$(CONFIG_X86_PM_TIMER) += pmtimer.o obj-$(CONFIG_X86_VSMP) += vsmp.o +obj-$(CONFIG_K8_NB) += k8.o obj-$(CONFIG_MODULES) += module.o diff --git a/arch/x86_64/kernel/aperture.c b/arch/x86_64/kernel/aperture.c index 70b9d21ed67..a7ad03ee98c 100644 --- a/arch/x86_64/kernel/aperture.c +++ b/arch/x86_64/kernel/aperture.c @@ -24,6 +24,7 @@ #include #include #include +#include int iommu_aperture; int iommu_aperture_disabled __initdata = 0; @@ -37,8 +38,6 @@ int fix_aperture __initdata = 1; /* This code runs before the PCI subsystem is initialized, so just access the northbridge directly. */ -#define NB_ID_3 (PCI_VENDOR_ID_AMD | (0x1103<<16)) - static u32 __init allocate_aperture(void) { pg_data_t *nd0 = NODE_DATA(0); @@ -68,20 +67,20 @@ static u32 __init allocate_aperture(void) return (u32)__pa(p); } -static int __init aperture_valid(char *name, u64 aper_base, u32 aper_size) +static int __init aperture_valid(u64 aper_base, u32 aper_size) { if (!aper_base) return 0; if (aper_size < 64*1024*1024) { - printk("Aperture from %s too small (%d MB)\n", name, aper_size>>20); + printk("Aperture too small (%d MB)\n", aper_size>>20); return 0; } if (aper_base + aper_size >= 0xffffffff) { - printk("Aperture from %s beyond 4GB. Ignoring.\n",name); + printk("Aperture beyond 4GB. Ignoring.\n"); return 0; } if (e820_any_mapped(aper_base, aper_base + aper_size, E820_RAM)) { - printk("Aperture from %s pointing to e820 RAM. Ignoring.\n",name); + printk("Aperture pointing to e820 RAM. Ignoring.\n"); return 0; } return 1; @@ -140,7 +139,7 @@ static __u32 __init read_agp(int num, int slot, int func, int cap, u32 *order) printk("Aperture from AGP @ %Lx size %u MB (APSIZE %x)\n", aper, 32 << *order, apsizereg); - if (!aperture_valid("AGP bridge", aper, (32*1024*1024) << *order)) + if (!aperture_valid(aper, (32*1024*1024) << *order)) return 0; return (u32)aper; } @@ -208,9 +207,8 @@ void __init iommu_hole_init(void) fix = 0; for (num = 24; num < 32; num++) { - char name[30]; - if (read_pci_config(0, num, 3, 0x00) != NB_ID_3) - continue; + if (!early_is_k8_nb(read_pci_config(0, num, 3, 0x00))) + continue; iommu_aperture = 1; @@ -222,9 +220,7 @@ void __init iommu_hole_init(void) printk("CPU %d: aperture @ %Lx size %u MB\n", num-24, aper_base, aper_size>>20); - sprintf(name, "northbridge cpu %d", num-24); - - if (!aperture_valid(name, aper_base, aper_size)) { + if (!aperture_valid(aper_base, aper_size)) { fix = 1; break; } @@ -273,7 +269,7 @@ void __init iommu_hole_init(void) /* Fix up the north bridges */ for (num = 24; num < 32; num++) { - if (read_pci_config(0, num, 3, 0x00) != NB_ID_3) + if (!early_is_k8_nb(read_pci_config(0, num, 3, 0x00))) continue; /* Don't enable translation yet. That is done later. diff --git a/arch/x86_64/kernel/k8.c b/arch/x86_64/kernel/k8.c new file mode 100644 index 00000000000..6416682d33d --- /dev/null +++ b/arch/x86_64/kernel/k8.c @@ -0,0 +1,118 @@ +/* + * Shared support code for AMD K8 northbridges and derivates. + * Copyright 2006 Andi Kleen, SUSE Labs. Subject to GPLv2. + */ +#include +#include +#include +#include +#include +#include +#include + +int num_k8_northbridges; +EXPORT_SYMBOL(num_k8_northbridges); + +static u32 *flush_words; + +struct pci_device_id k8_nb_ids[] = { + { PCI_DEVICE(PCI_VENDOR_ID_AMD, 0x1103) }, + { PCI_DEVICE(PCI_VENDOR_ID_AMD, 0x1203) }, + {} +}; +EXPORT_SYMBOL(k8_nb_ids); + +struct pci_dev **k8_northbridges; +EXPORT_SYMBOL(k8_northbridges); + +static struct pci_dev *next_k8_northbridge(struct pci_dev *dev) +{ + do { + dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev); + if (!dev) + break; + } while (!pci_match_id(&k8_nb_ids[0], dev)); + return dev; +} + +int cache_k8_northbridges(void) +{ + int i; + struct pci_dev *dev; + if (num_k8_northbridges) + return 0; + + num_k8_northbridges = 0; + dev = NULL; + while ((dev = next_k8_northbridge(dev)) != NULL) + num_k8_northbridges++; + + k8_northbridges = kmalloc((num_k8_northbridges + 1) * sizeof(void *), + GFP_KERNEL); + if (!k8_northbridges) + return -ENOMEM; + + flush_words = kmalloc(num_k8_northbridges * sizeof(u32), GFP_KERNEL); + if (!flush_words) { + kfree(k8_northbridges); + return -ENOMEM; + } + + dev = NULL; + i = 0; + while ((dev = next_k8_northbridge(dev)) != NULL) { + k8_northbridges[i++] = dev; + pci_read_config_dword(dev, 0x9c, &flush_words[i]); + } + k8_northbridges[i] = NULL; + return 0; +} +EXPORT_SYMBOL_GPL(cache_k8_northbridges); + +/* Ignores subdevice/subvendor but as far as I can figure out + they're useless anyways */ +int __init early_is_k8_nb(u32 device) +{ + struct pci_device_id *id; + u32 vendor = device & 0xffff; + device >>= 16; + for (id = k8_nb_ids; id->vendor; id++) + if (vendor == id->vendor && device == id->device) + return 1; + return 0; +} + +void k8_flush_garts(void) +{ + int flushed, i; + unsigned long flags; + static DEFINE_SPINLOCK(gart_lock); + + /* Avoid races between AGP and IOMMU. In theory it's not needed + but I'm not sure if the hardware won't lose flush requests + when another is pending. This whole thing is so expensive anyways + that it doesn't matter to serialize more. -AK */ + spin_lock_irqsave(&gart_lock, flags); + flushed = 0; + for (i = 0; i < num_k8_northbridges; i++) { + pci_write_config_dword(k8_northbridges[i], 0x9c, + flush_words[i]|1); + flushed++; + } + for (i = 0; i < num_k8_northbridges; i++) { + u32 w; + /* Make sure the hardware actually executed the flush*/ + for (;;) { + pci_read_config_dword(k8_northbridges[i], + 0x9c, &w); + if (!(w & 1)) + break; + cpu_relax(); + } + } + spin_unlock_irqrestore(&gart_lock, flags); + if (!flushed) + printk("nothing to flush?\n"); +} +EXPORT_SYMBOL_GPL(k8_flush_garts); + diff --git a/arch/x86_64/kernel/pci-gart.c b/arch/x86_64/kernel/pci-gart.c index ea8f4041794..ded3af3bcee 100644 --- a/arch/x86_64/kernel/pci-gart.c +++ b/arch/x86_64/kernel/pci-gart.c @@ -32,6 +32,7 @@ #include #include #include +#include unsigned long iommu_bus_base; /* GART remapping area (physical) */ static unsigned long iommu_size; /* size of remapping area bytes */ @@ -46,8 +47,6 @@ u32 *iommu_gatt_base; /* Remapping table */ also seen with Qlogic at least). */ int iommu_fullflush = 1; -#define MAX_NB 8 - /* Allocation bitmap for the remapping area */ static DEFINE_SPINLOCK(iommu_bitmap_lock); static unsigned long *iommu_gart_bitmap; /* guarded by iommu_bitmap_lock */ @@ -63,13 +62,6 @@ static u32 gart_unmapped_entry; #define to_pages(addr,size) \ (round_up(((addr) & ~PAGE_MASK) + (size), PAGE_SIZE) >> PAGE_SHIFT) -#define for_all_nb(dev) \ - dev = NULL; \ - while ((dev = pci_get_device(PCI_VENDOR_ID_AMD, 0x1103, dev))!=NULL) - -static struct pci_dev *northbridges[MAX_NB]; -static u32 northbridge_flush_word[MAX_NB]; - #define EMERGENCY_PAGES 32 /* = 128KB */ #ifdef CONFIG_AGP @@ -120,44 +112,17 @@ static void free_iommu(unsigned long offset, int size) /* * Use global flush state to avoid races with multiple flushers. */ -static void flush_gart(struct device *dev) +static void flush_gart(void) { unsigned long flags; - int flushed = 0; - int i, max; - spin_lock_irqsave(&iommu_bitmap_lock, flags); - if (need_flush) { - max = 0; - for (i = 0; i < MAX_NB; i++) { - if (!northbridges[i]) - continue; - pci_write_config_dword(northbridges[i], 0x9c, - northbridge_flush_word[i] | 1); - flushed++; - max = i; - } - for (i = 0; i <= max; i++) { - u32 w; - if (!northbridges[i]) - continue; - /* Make sure the hardware actually executed the flush. */ - for (;;) { - pci_read_config_dword(northbridges[i], 0x9c, &w); - if (!(w & 1)) - break; - cpu_relax(); - } - } - if (!flushed) - printk("nothing to flush?\n"); + if (need_flush) { + k8_flush_garts(); need_flush = 0; } spin_unlock_irqrestore(&iommu_bitmap_lock, flags); } - - #ifdef CONFIG_IOMMU_LEAK #define SET_LEAK(x) if (iommu_leak_tab) \ @@ -266,7 +231,7 @@ static dma_addr_t gart_map_simple(struct device *dev, char *buf, size_t size, int dir) { dma_addr_t map = dma_map_area(dev, virt_to_bus(buf), size, dir); - flush_gart(dev); + flush_gart(); return map; } @@ -351,7 +316,7 @@ static int dma_map_sg_nonforce(struct device *dev, struct scatterlist *sg, s->dma_address = addr; s->dma_length = s->length; } - flush_gart(dev); + flush_gart(); return nents; } @@ -458,13 +423,13 @@ int gart_map_sg(struct device *dev, struct scatterlist *sg, int nents, int dir) if (dma_map_cont(sg, start, i, sg+out, pages, need) < 0) goto error; out++; - flush_gart(dev); + flush_gart(); if (out < nents) sg[out].dma_length = 0; return out; error: - flush_gart(NULL); + flush_gart(); gart_unmap_sg(dev, sg, nents, dir); /* When it was forced or merged try again in a dumb way */ if (force_iommu || iommu_merge) { @@ -532,10 +497,13 @@ static __init int init_k8_gatt(struct agp_kern_info *info) void *gatt; unsigned aper_base, new_aper_base; unsigned aper_size, gatt_size, new_aper_size; - + int i; + printk(KERN_INFO "PCI-DMA: Disabling AGP.\n"); aper_size = aper_base = info->aper_size = 0; - for_all_nb(dev) { + dev = NULL; + for (i = 0; i < num_k8_northbridges; i++) { + dev = k8_northbridges[i]; new_aper_base = read_aperture(dev, &new_aper_size); if (!new_aper_base) goto nommu; @@ -558,11 +526,12 @@ static __init int init_k8_gatt(struct agp_kern_info *info) panic("Cannot allocate GATT table"); memset(gatt, 0, gatt_size); agp_gatt_table = gatt; - - for_all_nb(dev) { + + for (i = 0; i < num_k8_northbridges; i++) { u32 ctl; u32 gatt_reg; + dev = k8_northbridges[i]; gatt_reg = __pa(gatt) >> 12; gatt_reg <<= 4; pci_write_config_dword(dev, 0x98, gatt_reg); @@ -573,7 +542,7 @@ static __init int init_k8_gatt(struct agp_kern_info *info) pci_write_config_dword(dev, 0x90, ctl); } - flush_gart(NULL); + flush_gart(); printk("PCI-DMA: aperture base @ %x size %u KB\n",aper_base, aper_size>>10); return 0; @@ -607,10 +576,14 @@ static int __init pci_iommu_init(void) struct agp_kern_info info; unsigned long aper_size; unsigned long iommu_start; - struct pci_dev *dev; unsigned long scratch; long i; + if (cache_k8_northbridges() < 0 || num_k8_northbridges == 0) { + printk(KERN_INFO "PCI-GART: No AMD northbridge found.\n"); + return -1; + } + #ifndef CONFIG_AGP_AMD64 no_agp = 1; #else @@ -637,14 +610,6 @@ static int __init pci_iommu_init(void) return -1; } - i = 0; - for_all_nb(dev) - i++; - if (i > MAX_NB) { - printk(KERN_ERR "PCI-GART: Too many northbridges (%ld). Disabled\n", i); - return -1; - } - printk(KERN_INFO "PCI-DMA: using GART IOMMU.\n"); aper_size = info.aper_size * 1024 * 1024; iommu_size = check_iommu_size(info.aper_base, aper_size); @@ -707,20 +672,8 @@ static int __init pci_iommu_init(void) for (i = EMERGENCY_PAGES; i < iommu_pages; i++) iommu_gatt_base[i] = gart_unmapped_entry; - for_all_nb(dev) { - u32 flag; - int cpu = PCI_SLOT(dev->devfn) - 24; - if (cpu >= MAX_NB) - continue; - northbridges[cpu] = dev; - pci_read_config_dword(dev, 0x9c, &flag); /* cache flush word */ - northbridge_flush_word[cpu] = flag; - } - - flush_gart(NULL); - + flush_gart(); dma_ops = &gart_dma_ops; - return 0; } diff --git a/arch/x86_64/pci/k8-bus.c b/arch/x86_64/pci/k8-bus.c index 3acf60ded2a..b50a7c7c47f 100644 --- a/arch/x86_64/pci/k8-bus.c +++ b/arch/x86_64/pci/k8-bus.c @@ -2,6 +2,7 @@ #include #include #include +#include /* * This discovers the pcibus <-> node mapping on AMD K8. @@ -18,7 +19,6 @@ #define NR_LDT_BUS_NUMBER_REGISTERS 3 #define SECONDARY_LDT_BUS_NUMBER(dword) ((dword >> 8) & 0xFF) #define SUBORDINATE_LDT_BUS_NUMBER(dword) ((dword >> 16) & 0xFF) -#define PCI_DEVICE_ID_K8HTCONFIG 0x1100 /** * fill_mp_bus_to_cpumask() @@ -28,8 +28,7 @@ __init static int fill_mp_bus_to_cpumask(void) { - struct pci_dev *nb_dev = NULL; - int i, j; + int i, j, k; u32 ldtbus, nid; static int lbnr[3] = { LDT_BUS_NUMBER_REGISTER_0, @@ -37,8 +36,9 @@ fill_mp_bus_to_cpumask(void) LDT_BUS_NUMBER_REGISTER_2 }; - while ((nb_dev = pci_get_device(PCI_VENDOR_ID_AMD, - PCI_DEVICE_ID_K8HTCONFIG, nb_dev))) { + cache_k8_northbridges(); + for (k = 0; k < num_k8_northbridges; k++) { + struct pci_dev *nb_dev = k8_northbridges[k]; pci_read_config_dword(nb_dev, NODE_ID_REGISTER, &nid); for (i = 0; i < NR_LDT_BUS_NUMBER_REGISTERS; i++) { diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c index ac3c33a2e37..229d015757f 100644 --- a/drivers/char/agp/amd64-agp.c +++ b/drivers/char/agp/amd64-agp.c @@ -15,11 +15,9 @@ #include #include #include /* PAGE_SIZE */ +#include #include "agp.h" -/* Will need to be increased if AMD64 ever goes >8-way. */ -#define MAX_HAMMER_GARTS 8 - /* PTE bits. */ #define GPTE_VALID 1 #define GPTE_COHERENT 2 @@ -53,28 +51,12 @@ #define ULI_X86_64_HTT_FEA_REG 0x50 #define ULI_X86_64_ENU_SCR_REG 0x54 -static int nr_garts; -static struct pci_dev * hammers[MAX_HAMMER_GARTS]; - static struct resource *aperture_resource; static int __initdata agp_try_unsupported = 1; -#define for_each_nb() for(gart_iterator=0;gart_iteratorgatt_table_real); - int gart_iterator; + int i; /* Configure AGP regs in each x86-64 host bridge. */ - for_each_nb() { + for (i = 0; i < num_k8_northbridges; i++) { agp_bridge->gart_bus_addr = - amd64_configure(hammers[gart_iterator],gatt_bus); + amd64_configure(k8_northbridges[i], gatt_bus); } + k8_flush_garts(); return 0; } @@ -236,12 +216,13 @@ static int amd_8151_configure(void) static void amd64_cleanup(void) { u32 tmp; - int gart_iterator; - for_each_nb() { + int i; + for (i = 0; i < num_k8_northbridges; i++) { + struct pci_dev *dev = k8_northbridges[i]; /* disable gart translation */ - pci_read_config_dword (hammers[gart_iterator], AMD64_GARTAPERTURECTL, &tmp); + pci_read_config_dword (dev, AMD64_GARTAPERTURECTL, &tmp); tmp &= ~AMD64_GARTEN; - pci_write_config_dword (hammers[gart_iterator], AMD64_GARTAPERTURECTL, tmp); + pci_write_config_dword (dev, AMD64_GARTAPERTURECTL, tmp); } } @@ -361,17 +342,15 @@ static __devinit int fix_northbridge(struct pci_dev *nb, struct pci_dev *agp, static __devinit int cache_nbs (struct pci_dev *pdev, u32 cap_ptr) { - struct pci_dev *loop_dev = NULL; - int i = 0; - - /* cache pci_devs of northbridges. */ - while ((loop_dev = pci_get_device(PCI_VENDOR_ID_AMD, 0x1103, loop_dev)) - != NULL) { - if (i == MAX_HAMMER_GARTS) { - printk(KERN_ERR PFX "Too many northbridges for AGP\n"); - return -1; - } - if (fix_northbridge(loop_dev, pdev, cap_ptr) < 0) { + int i; + + if (cache_k8_northbridges() < 0) + return -ENODEV; + + i = 0; + for (i = 0; i < num_k8_northbridges; i++) { + struct pci_dev *dev = k8_northbridges[i]; + if (fix_northbridge(dev, pdev, cap_ptr) < 0) { printk(KERN_ERR PFX "No usable aperture found.\n"); #ifdef __x86_64__ /* should port this to i386 */ @@ -379,10 +358,8 @@ static __devinit int cache_nbs (struct pci_dev *pdev, u32 cap_ptr) #endif return -1; } - hammers[i++] = loop_dev; } - nr_garts = i; - return i == 0 ? -1 : 0; + return 0; } /* Handle AMD 8151 quirks */ @@ -450,7 +427,7 @@ static int __devinit uli_agp_init(struct pci_dev *pdev) } /* shadow x86-64 registers into ULi registers */ - pci_read_config_dword (hammers[0], AMD64_GARTAPERTUREBASE, &httfea); + pci_read_config_dword (k8_northbridges[0], AMD64_GARTAPERTUREBASE, &httfea); /* if x86-64 aperture base is beyond 4G, exit here */ if ((httfea & 0x7fff) >> (32 - 25)) @@ -513,7 +490,7 @@ static int __devinit nforce3_agp_init(struct pci_dev *pdev) pci_write_config_dword(dev1, NVIDIA_X86_64_1_APSIZE, tmp); /* shadow x86-64 registers into NVIDIA registers */ - pci_read_config_dword (hammers[0], AMD64_GARTAPERTUREBASE, &apbase); + pci_read_config_dword (k8_northbridges[0], AMD64_GARTAPERTUREBASE, &apbase); /* if x86-64 aperture base is beyond 4G, exit here */ if ( (apbase & 0x7fff) >> (32 - 25) ) { @@ -754,10 +731,6 @@ static struct pci_driver agp_amd64_pci_driver = { int __init agp_amd64_init(void) { int err = 0; - static struct pci_device_id amd64nb[] = { - { PCI_DEVICE(PCI_VENDOR_ID_AMD, 0x1103) }, - { }, - }; if (agp_off) return -EINVAL; @@ -774,7 +747,7 @@ int __init agp_amd64_init(void) } /* First check that we have at least one AMD64 NB */ - if (!pci_dev_present(amd64nb)) + if (!pci_dev_present(k8_nb_ids)) return -ENODEV; /* Look for any AGP bridge */ diff --git a/include/asm-i386/k8.h b/include/asm-i386/k8.h new file mode 100644 index 00000000000..dfd88a6e604 --- /dev/null +++ b/include/asm-i386/k8.h @@ -0,0 +1 @@ +#include diff --git a/include/asm-x86_64/k8.h b/include/asm-x86_64/k8.h new file mode 100644 index 00000000000..699dd6961ed --- /dev/null +++ b/include/asm-x86_64/k8.h @@ -0,0 +1,14 @@ +#ifndef _ASM_K8_H +#define _ASM_K8_H 1 + +#include + +extern struct pci_device_id k8_nb_ids[]; + +extern int early_is_k8_nb(u32 value); +extern struct pci_dev **k8_northbridges; +extern int num_k8_northbridges; +extern int cache_k8_northbridges(void); +extern void k8_flush_garts(void); + +#endif -- cgit v1.2.3-70-g09d2 From a813ce432f27c4f5011c7b5ac9d2bbbfeb41d9a7 Mon Sep 17 00:00:00 2001 From: Andi Kleen Date: Mon, 26 Jun 2006 13:57:22 +0200 Subject: [PATCH] x86_64: Rename IOMMU option, fix help and mark option embedded. - Rename the GART_IOMMU option to IOMMU to make clear it's not just for AMD - Rewrite the help text to better emphatise this fact - Make it an embedded option because too many people get it wrong. To my astonishment I discovered the aacraid driver tests this symbol directly. This looks quite broken to me - it's an internal implementation detail of the PCI DMA API. Can the maintainer please clarify what this test was intended to do? Cc: linux-scsi@vger.kernel.org Cc: alan@redhat.com Cc: markh@osdl.org Signed-off-by: Andi Kleen Signed-off-by: Linus Torvalds --- arch/x86_64/Kconfig | 30 ++++++++++++++++-------------- arch/x86_64/Kconfig.debug | 2 +- arch/x86_64/kernel/Makefile | 2 +- arch/x86_64/kernel/io_apic.c | 2 +- arch/x86_64/kernel/pci-dma.c | 2 +- arch/x86_64/kernel/setup.c | 2 +- drivers/char/agp/Kconfig | 4 ++-- drivers/char/agp/amd64-agp.c | 4 ++-- drivers/scsi/aacraid/comminit.c | 5 ++++- include/asm-x86_64/pci.h | 2 +- include/asm-x86_64/proto.h | 2 +- 11 files changed, 31 insertions(+), 26 deletions(-) (limited to 'drivers/char') diff --git a/arch/x86_64/Kconfig b/arch/x86_64/Kconfig index fc75275d8c7..e8c52a1eec0 100644 --- a/arch/x86_64/Kconfig +++ b/arch/x86_64/Kconfig @@ -386,24 +386,26 @@ config HPET_EMULATE_RTC bool "Provide RTC interrupt" depends on HPET_TIMER && RTC=y -config GART_IOMMU - bool "K8 GART IOMMU support" +# Mark as embedded because too many people got it wrong. +# The code disables itself when not needed. +config IOMMU + bool "IOMMU support" if EMBEDDED default y select SWIOTLB select AGP depends on PCI help - Support for hardware IOMMU in AMD's Opteron/Athlon64 Processors - and for the bounce buffering software IOMMU. - Needed to run systems with more than 3GB of memory properly with - 32-bit PCI devices that do not support DAC (Double Address Cycle). - The IOMMU can be turned off at runtime with the iommu=off parameter. - Normally the kernel will take the right choice by itself. - This option includes a driver for the AMD Opteron/Athlon64 IOMMU - northbridge and a software emulation used on other systems without - hardware IOMMU. If unsure, say Y. - -# need this always selected by GART_IOMMU for the VIA workaround + Support for full DMA access of devices with 32bit memory access only + on systems with more than 3GB. This is usually needed for USB, + sound, many IDE/SATA chipsets and some other devices. + Provides a driver for the AMD Athlon64/Opteron/Turion/Sempron GART + based IOMMU and a software bounce buffer based IOMMU used on Intel + systems and as fallback. + The code is only active when needed (enough memory and limited + device) unless CONFIG_IOMMU_DEBUG or iommu=force is specified + too. + +# need this always selected by IOMMU for the VIA workaround config SWIOTLB bool @@ -503,7 +505,7 @@ config REORDER config K8_NB def_bool y - depends on AGP_AMD64 || GART_IOMMU || (PCI && NUMA) + depends on AGP_AMD64 || IOMMU || (PCI && NUMA) endmenu diff --git a/arch/x86_64/Kconfig.debug b/arch/x86_64/Kconfig.debug index ea31b4c6210..0226f08be87 100644 --- a/arch/x86_64/Kconfig.debug +++ b/arch/x86_64/Kconfig.debug @@ -13,7 +13,7 @@ config DEBUG_RODATA If in doubt, say "N". config IOMMU_DEBUG - depends on GART_IOMMU && DEBUG_KERNEL + depends on IOMMU && DEBUG_KERNEL bool "Enable IOMMU debugging" help Force the IOMMU to on even when you have less than 4GB of diff --git a/arch/x86_64/kernel/Makefile b/arch/x86_64/kernel/Makefile index f927d11065f..fd106bdddd6 100644 --- a/arch/x86_64/kernel/Makefile +++ b/arch/x86_64/kernel/Makefile @@ -28,7 +28,7 @@ obj-$(CONFIG_PM) += suspend.o obj-$(CONFIG_SOFTWARE_SUSPEND) += suspend_asm.o obj-$(CONFIG_CPU_FREQ) += cpufreq/ obj-$(CONFIG_EARLY_PRINTK) += early_printk.o -obj-$(CONFIG_GART_IOMMU) += pci-gart.o aperture.o +obj-$(CONFIG_IOMMU) += pci-gart.o aperture.o obj-$(CONFIG_SWIOTLB) += pci-swiotlb.o obj-$(CONFIG_KPROBES) += kprobes.o obj-$(CONFIG_X86_PM_TIMER) += pmtimer.o diff --git a/arch/x86_64/kernel/io_apic.c b/arch/x86_64/kernel/io_apic.c index 519cd4e6f9e..c768d8a036d 100644 --- a/arch/x86_64/kernel/io_apic.c +++ b/arch/x86_64/kernel/io_apic.c @@ -319,7 +319,7 @@ void __init check_ioapic(void) vendor &= 0xffff; switch (vendor) { case PCI_VENDOR_ID_VIA: -#ifdef CONFIG_GART_IOMMU +#ifdef CONFIG_IOMMU if ((end_pfn > MAX_DMA32_PFN || force_iommu) && !iommu_aperture_allowed) { diff --git a/arch/x86_64/kernel/pci-dma.c b/arch/x86_64/kernel/pci-dma.c index 117bcebe9eb..33926c36725 100644 --- a/arch/x86_64/kernel/pci-dma.c +++ b/arch/x86_64/kernel/pci-dma.c @@ -266,7 +266,7 @@ __init int iommu_setup(char *p) swiotlb = 1; #endif -#ifdef CONFIG_GART_IOMMU +#ifdef CONFIG_IOMMU gart_parse_options(p); #endif diff --git a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c index 9dadb9a1db2..816203d57e1 100644 --- a/arch/x86_64/kernel/setup.c +++ b/arch/x86_64/kernel/setup.c @@ -702,7 +702,7 @@ void __init setup_arch(char **cmdline_p) e820_setup_gap(); -#ifdef CONFIG_GART_IOMMU +#ifdef CONFIG_IOMMU iommu_hole_init(); #endif diff --git a/drivers/char/agp/Kconfig b/drivers/char/agp/Kconfig index 46685a54077..9826a399fa0 100644 --- a/drivers/char/agp/Kconfig +++ b/drivers/char/agp/Kconfig @@ -55,9 +55,9 @@ config AGP_AMD X on AMD Irongate, 761, and 762 chipsets. config AGP_AMD64 - tristate "AMD Opteron/Athlon64 on-CPU GART support" if !GART_IOMMU + tristate "AMD Opteron/Athlon64 on-CPU GART support" if !IOMMU depends on AGP && X86 - default y if GART_IOMMU + default y if IOMMU help This option gives you AGP support for the GLX component of X using the on-CPU northbridge of the AMD Athlon64/Opteron CPUs. diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c index 229d015757f..f690ee8cb73 100644 --- a/drivers/char/agp/amd64-agp.c +++ b/drivers/char/agp/amd64-agp.c @@ -292,7 +292,7 @@ static int __devinit aperture_valid(u64 aper, u32 size) /* * W*s centric BIOS sometimes only set up the aperture in the AGP * bridge, not the northbridge. On AMD64 this is handled early - * in aperture.c, but when GART_IOMMU is not enabled or we run + * in aperture.c, but when IOMMU is not enabled or we run * on a 32bit kernel this needs to be redone. * Unfortunately it is impossible to fix the aperture here because it's too late * to allocate that much memory. But at least error out cleanly instead of @@ -775,7 +775,7 @@ static void __exit agp_amd64_cleanup(void) /* On AMD64 the PCI driver needs to initialize this driver early for the IOMMU, so it has to be called via a backdoor. */ -#ifndef CONFIG_GART_IOMMU +#ifndef CONFIG_IOMMU module_init(agp_amd64_init); module_exit(agp_amd64_cleanup); #endif diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c index 35b0a6ebd3f..7cea514e810 100644 --- a/drivers/scsi/aacraid/comminit.c +++ b/drivers/scsi/aacraid/comminit.c @@ -104,8 +104,11 @@ static int aac_alloc_comm(struct aac_dev *dev, void **commaddr, unsigned long co * always true on real computers. It also has some slight problems * with the GART on x86-64. I've btw never tried DMA from PCI space * on this platform but don't be surprised if its problematic. + * [AK: something is very very wrong when a driver tests this symbol. + * Someone should figure out what the comment writer really meant here and fix + * the code. Or just remove that bad code. ] */ -#ifndef CONFIG_GART_IOMMU +#ifndef CONFIG_IOMMU if ((num_physpages << (PAGE_SHIFT - 12)) <= AAC_MAX_HOSTPHYSMEMPAGES) { init->HostPhysMemPages = cpu_to_le32(num_physpages << (PAGE_SHIFT-12)); diff --git a/include/asm-x86_64/pci.h b/include/asm-x86_64/pci.h index 2db0620d544..3374d34c4ac 100644 --- a/include/asm-x86_64/pci.h +++ b/include/asm-x86_64/pci.h @@ -52,7 +52,7 @@ extern int iommu_setup(char *opt); */ #define PCI_DMA_BUS_IS_PHYS (dma_ops->is_phys) -#ifdef CONFIG_GART_IOMMU +#ifdef CONFIG_IOMMU /* * x86-64 always supports DAC, but sometimes it is useful to force diff --git a/include/asm-x86_64/proto.h b/include/asm-x86_64/proto.h index 8abf2a43c94..1064533e095 100644 --- a/include/asm-x86_64/proto.h +++ b/include/asm-x86_64/proto.h @@ -116,7 +116,7 @@ extern int skip_ioapic_setup; extern int acpi_ht; extern int acpi_disabled; -#ifdef CONFIG_GART_IOMMU +#ifdef CONFIG_IOMMU extern int fallback_aper_order; extern int fallback_aper_force; extern int iommu_aperture; -- cgit v1.2.3-70-g09d2 From a09ab7e2fcd22f0490a270bb310536c651d53cb9 Mon Sep 17 00:00:00 2001 From: mark gross Date: Fri, 23 Jun 2006 15:13:07 -0700 Subject: [PATCH] type-oh bug in tlclk.c Mark Bellon found a bug in my tlclk driver. Thanks! I botch the register mask for store_received_ref_clk3a. See http://download.intel.com/design/network/manuals/30412001.pdf tables 124 and 136 for details. Signed-off-by: Mark Gross Signed-off-by: Linus Torvalds --- drivers/char/tlclk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/char') diff --git a/drivers/char/tlclk.c b/drivers/char/tlclk.c index f58ad7f6826..ef68d152d3e 100644 --- a/drivers/char/tlclk.c +++ b/drivers/char/tlclk.c @@ -343,7 +343,7 @@ static ssize_t store_received_ref_clk3b(struct device *d, val = (unsigned char)tmp; spin_lock_irqsave(&event_lock, flags); - SET_PORT_BITS(TLCLK_REG1, 0xef, val << 1); + SET_PORT_BITS(TLCLK_REG1, 0xdf, val << 1); spin_unlock_irqrestore(&event_lock, flags); return strnlen(buf, count); -- cgit v1.2.3-70-g09d2 From e29419fffceb8ec36def3c922040e1ca7bcd3de5 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 12 Jun 2006 15:20:16 -0700 Subject: [PATCH] 64bit resource: fix up printks for resources in misc drivers This is needed if we wish to change the size of the resource structures. Based on an original patch from Vivek Goyal Cc: Vivek Goyal Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- drivers/amba/bus.c | 5 +++-- drivers/atm/ambassador.c | 3 ++- drivers/atm/firestream.c | 5 +++-- drivers/block/sx8.c | 5 +++-- drivers/char/applicom.c | 9 ++++++--- drivers/ieee1394/ohci1394.c | 15 ++++++++------- drivers/infiniband/hw/ipath/ipath_driver.c | 8 ++++---- drivers/infiniband/hw/mthca/mthca_main.c | 5 +++-- drivers/input/serio/ct82c710.c | 6 +++--- drivers/isdn/hisax/telespci.c | 5 +++-- drivers/macintosh/macio_asic.c | 4 ++-- drivers/message/i2o/iop.c | 14 ++++++++------ drivers/mmc/mmci.c | 4 ++-- drivers/scsi/sata_via.c | 8 ++++---- 14 files changed, 54 insertions(+), 42 deletions(-) (limited to 'drivers/char') diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c index 889855d8d9f..9e3e2a69c03 100644 --- a/drivers/amba/bus.c +++ b/drivers/amba/bus.c @@ -180,8 +180,9 @@ static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL) amba_attr(id, "%08x\n", dev->periphid); amba_attr(irq0, "%u\n", dev->irq[0]); amba_attr(irq1, "%u\n", dev->irq[1]); -amba_attr(resource, "\t%08lx\t%08lx\t%08lx\n", - dev->res.start, dev->res.end, dev->res.flags); +amba_attr(resource, "\t%016llx\t%016llx\t%016lx\n", + (unsigned long long)dev->res.start, (unsigned long long)dev->res.end, + dev->res.flags); /** * amba_device_register - register an AMBA device diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c index 4b6bf19c39c..4048681f36d 100644 --- a/drivers/atm/ambassador.c +++ b/drivers/atm/ambassador.c @@ -2257,7 +2257,8 @@ static int __devinit amb_probe(struct pci_dev *pci_dev, const struct pci_device_ } PRINTD (DBG_INFO, "found Madge ATM adapter (amb) at" - " IO %lx, IRQ %u, MEM %p", pci_resource_start(pci_dev, 1), + " IO %llx, IRQ %u, MEM %p", + (unsigned long long)pci_resource_start(pci_dev, 1), irq, bus_to_virt(pci_resource_start(pci_dev, 0))); // check IO region diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c index f2eeaf9dc56..e1177169d57 100644 --- a/drivers/atm/firestream.c +++ b/drivers/atm/firestream.c @@ -1657,9 +1657,10 @@ static int __devinit fs_init (struct fs_dev *dev) func_enter (); pci_dev = dev->pci_dev; - printk (KERN_INFO "found a FireStream %d card, base %08lx, irq%d.\n", + printk (KERN_INFO "found a FireStream %d card, base %16llx, irq%d.\n", IS_FS50(dev)?50:155, - pci_resource_start(pci_dev, 0), dev->pci_dev->irq); + (unsigned long long)pci_resource_start(pci_dev, 0), + dev->pci_dev->irq); if (fs_debug & FS_DEBUG_INIT) my_hd ((unsigned char *) dev, sizeof (*dev)); diff --git a/drivers/block/sx8.c b/drivers/block/sx8.c index 2ae08b343b9..8144ce9f4df 100644 --- a/drivers/block/sx8.c +++ b/drivers/block/sx8.c @@ -1694,9 +1694,10 @@ static int carm_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) DPRINTK("waiting for probe_comp\n"); wait_for_completion(&host->probe_comp); - printk(KERN_INFO "%s: pci %s, ports %d, io %lx, irq %u, major %d\n", + printk(KERN_INFO "%s: pci %s, ports %d, io %llx, irq %u, major %d\n", host->name, pci_name(pdev), (int) CARM_MAX_PORTS, - pci_resource_start(pdev, 0), pdev->irq, host->major); + (unsigned long long)pci_resource_start(pdev, 0), + pdev->irq, host->major); carm_host_id++; pci_set_drvdata(pdev, host); diff --git a/drivers/char/applicom.c b/drivers/char/applicom.c index 9275d5e52e6..72fb60765c4 100644 --- a/drivers/char/applicom.c +++ b/drivers/char/applicom.c @@ -209,13 +209,16 @@ static int __init applicom_init(void) RamIO = ioremap(dev->resource[0].start, LEN_RAM_IO); if (!RamIO) { - printk(KERN_INFO "ac.o: Failed to ioremap PCI memory space at 0x%lx\n", dev->resource[0].start); + printk(KERN_INFO "ac.o: Failed to ioremap PCI memory " + "space at 0x%llx\n", + (unsigned long long)dev->resource[0].start); pci_disable_device(dev); return -EIO; } - printk(KERN_INFO "Applicom %s found at mem 0x%lx, irq %d\n", - applicom_pci_devnames[dev->device-1], dev->resource[0].start, + printk(KERN_INFO "Applicom %s found at mem 0x%llx, irq %d\n", + applicom_pci_devnames[dev->device-1], + (unsigned long long)dev->resource[0].start, dev->irq); boardno = ac_register_board(dev->resource[0].start, RamIO,0); diff --git a/drivers/ieee1394/ohci1394.c b/drivers/ieee1394/ohci1394.c index 3d278412e1c..f0d5f2b7de8 100644 --- a/drivers/ieee1394/ohci1394.c +++ b/drivers/ieee1394/ohci1394.c @@ -590,11 +590,11 @@ static void ohci_initialize(struct ti_ohci *ohci) buf = reg_read(ohci, OHCI1394_Version); sprintf (irq_buf, "%d", ohci->dev->irq); PRINT(KERN_INFO, "OHCI-1394 %d.%d (PCI): IRQ=[%s] " - "MMIO=[%lx-%lx] Max Packet=[%d] IR/IT contexts=[%d/%d]", + "MMIO=[%llx-%llx] Max Packet=[%d] IR/IT contexts=[%d/%d]", ((((buf) >> 16) & 0xf) + (((buf) >> 20) & 0xf) * 10), ((((buf) >> 4) & 0xf) + ((buf) & 0xf) * 10), irq_buf, - pci_resource_start(ohci->dev, 0), - pci_resource_start(ohci->dev, 0) + OHCI1394_REGISTER_SIZE - 1, + (unsigned long long)pci_resource_start(ohci->dev, 0), + (unsigned long long)pci_resource_start(ohci->dev, 0) + OHCI1394_REGISTER_SIZE - 1, ohci->max_packet_size, ohci->nb_iso_rcv_ctx, ohci->nb_iso_xmit_ctx); @@ -3270,15 +3270,16 @@ static int __devinit ohci1394_pci_probe(struct pci_dev *dev, * clearly says it's 2kb, so this shouldn't be a problem. */ ohci_base = pci_resource_start(dev, 0); if (pci_resource_len(dev, 0) < OHCI1394_REGISTER_SIZE) - PRINT(KERN_WARNING, "PCI resource length of %lx too small!", - pci_resource_len(dev, 0)); + PRINT(KERN_WARNING, "PCI resource length of 0x%llx too small!", + (unsigned long long)pci_resource_len(dev, 0)); /* Seems PCMCIA handles this internally. Not sure why. Seems * pretty bogus to force a driver to special case this. */ #ifndef PCMCIA if (!request_mem_region (ohci_base, OHCI1394_REGISTER_SIZE, OHCI1394_DRIVER_NAME)) - FAIL(-ENOMEM, "MMIO resource (0x%lx - 0x%lx) unavailable", - ohci_base, ohci_base + OHCI1394_REGISTER_SIZE); + FAIL(-ENOMEM, "MMIO resource (0x%llx - 0x%llx) unavailable", + (unsigned long long)ohci_base, + (unsigned long long)ohci_base + OHCI1394_REGISTER_SIZE); #endif ohci->init_state = OHCI_INIT_HAVE_MEM_REGION; diff --git a/drivers/infiniband/hw/ipath/ipath_driver.c b/drivers/infiniband/hw/ipath/ipath_driver.c index dddcdae736a..e4b897fa569 100644 --- a/drivers/infiniband/hw/ipath/ipath_driver.c +++ b/drivers/infiniband/hw/ipath/ipath_driver.c @@ -460,10 +460,10 @@ static int __devinit ipath_init_one(struct pci_dev *pdev, for (j = 0; j < 6; j++) { if (!pdev->resource[j].start) continue; - ipath_cdbg(VERBOSE, "BAR %d start %lx, end %lx, len %lx\n", - j, pdev->resource[j].start, - pdev->resource[j].end, - pci_resource_len(pdev, j)); + ipath_cdbg(VERBOSE, "BAR %d start %llx, end %llx, len %llx\n", + j, (unsigned long long)pdev->resource[j].start, + (unsigned long long)pdev->resource[j].end, + (unsigned long long)pci_resource_len(pdev, j)); } if (!addr) { diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c index 9b9ff7bff35..465fd220569 100644 --- a/drivers/infiniband/hw/mthca/mthca_main.c +++ b/drivers/infiniband/hw/mthca/mthca_main.c @@ -172,8 +172,9 @@ static int __devinit mthca_dev_lim(struct mthca_dev *mdev, struct mthca_dev_lim if (dev_lim->uar_size > pci_resource_len(mdev->pdev, 2)) { mthca_err(mdev, "HCA reported UAR size of 0x%x bigger than " - "PCI resource 2 size of 0x%lx, aborting.\n", - dev_lim->uar_size, pci_resource_len(mdev->pdev, 2)); + "PCI resource 2 size of 0x%llx, aborting.\n", + dev_lim->uar_size, + (unsigned long long)pci_resource_len(mdev->pdev, 2)); return -ENODEV; } diff --git a/drivers/input/serio/ct82c710.c b/drivers/input/serio/ct82c710.c index 096b6a0b5cc..1ac739ef2ff 100644 --- a/drivers/input/serio/ct82c710.c +++ b/drivers/input/serio/ct82c710.c @@ -189,7 +189,7 @@ static int __devinit ct82c710_probe(struct platform_device *dev) strlcpy(ct82c710_port->name, "C&T 82c710 mouse port", sizeof(ct82c710_port->name)); snprintf(ct82c710_port->phys, sizeof(ct82c710_port->phys), - "isa%04lx/serio0", CT82C710_DATA); + "isa%16llx/serio0", (unsigned long long)CT82C710_DATA); serio_register_port(ct82c710_port); @@ -241,8 +241,8 @@ static int __init ct82c710_init(void) serio_register_port(ct82c710_port); - printk(KERN_INFO "serio: C&T 82c710 mouse port at %#lx irq %d\n", - CT82C710_DATA, CT82C710_IRQ); + printk(KERN_INFO "serio: C&T 82c710 mouse port at %#llx irq %d\n", + (unsigned long long)CT82C710_DATA, CT82C710_IRQ); return 0; diff --git a/drivers/isdn/hisax/telespci.c b/drivers/isdn/hisax/telespci.c index e2bb4fd8e25..e82ab2251b8 100644 --- a/drivers/isdn/hisax/telespci.c +++ b/drivers/isdn/hisax/telespci.c @@ -311,8 +311,9 @@ setup_telespci(struct IsdnCard *card) } cs->hw.teles0.membase = ioremap(pci_resource_start(dev_tel, 0), PAGE_SIZE); - printk(KERN_INFO "Found: Zoran, base-address: 0x%lx, irq: 0x%x\n", - pci_resource_start(dev_tel, 0), dev_tel->irq); + printk(KERN_INFO "Found: Zoran, base-address: 0x%llx, irq: 0x%x\n", + (unsigned long long)pci_resource_start(dev_tel, 0), + dev_tel->irq); } else { printk(KERN_WARNING "TelesPCI: No PCI card found\n"); return(0); diff --git a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c index 431bd37225a..c687ac70394 100644 --- a/drivers/macintosh/macio_asic.c +++ b/drivers/macintosh/macio_asic.c @@ -428,10 +428,10 @@ static struct macio_dev * macio_add_one_device(struct macio_chip *chip, /* MacIO itself has a different reg, we use it's PCI base */ if (np == chip->of_node) { - sprintf(dev->ofdev.dev.bus_id, "%1d.%08lx:%.*s", + sprintf(dev->ofdev.dev.bus_id, "%1d.%016llx:%.*s", chip->lbus.index, #ifdef CONFIG_PCI - pci_resource_start(chip->lbus.pdev, 0), + (unsigned long long)pci_resource_start(chip->lbus.pdev, 0), #else 0, /* NuBus may want to do something better here */ #endif diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c index febbdd4e060..64cc92560b8 100644 --- a/drivers/message/i2o/iop.c +++ b/drivers/message/i2o/iop.c @@ -683,9 +683,10 @@ static int i2o_iop_systab_set(struct i2o_controller *c) c->mem_alloc = 1; sb->current_mem_size = 1 + res->end - res->start; sb->current_mem_base = res->start; - osm_info("%s: allocated %ld bytes of PCI memory at " - "0x%08lX.\n", c->name, - 1 + res->end - res->start, res->start); + osm_info("%s: allocated %llu bytes of PCI memory at " + "0x%016llX.\n", c->name, + (unsigned long long)(1 + res->end - res->start), + (unsigned long long)res->start); } } @@ -704,9 +705,10 @@ static int i2o_iop_systab_set(struct i2o_controller *c) c->io_alloc = 1; sb->current_io_size = 1 + res->end - res->start; sb->current_mem_base = res->start; - osm_info("%s: allocated %ld bytes of PCI I/O at 0x%08lX" - ".\n", c->name, 1 + res->end - res->start, - res->start); + osm_info("%s: allocated %llu bytes of PCI I/O at " + "0x%016llX.\n", c->name, + (unsigned long long)(1 + res->end - res->start), + (unsigned long long)res->start); } } diff --git a/drivers/mmc/mmci.c b/drivers/mmc/mmci.c index da8e4d7339c..8576a65ca1c 100644 --- a/drivers/mmc/mmci.c +++ b/drivers/mmc/mmci.c @@ -546,9 +546,9 @@ static int mmci_probe(struct amba_device *dev, void *id) mmc_add_host(mmc); - printk(KERN_INFO "%s: MMCI rev %x cfg %02x at 0x%08lx irq %d,%d\n", + printk(KERN_INFO "%s: MMCI rev %x cfg %02x at 0x%016llx irq %d,%d\n", mmc_hostname(mmc), amba_rev(dev), amba_config(dev), - dev->res.start, dev->irq[0], dev->irq[1]); + (unsigned long long)dev->res.start, dev->irq[0], dev->irq[1]); init_timer(&host->timer); host->timer.data = (unsigned long)host; diff --git a/drivers/scsi/sata_via.c b/drivers/scsi/sata_via.c index 322890b400a..75c4f0cbda1 100644 --- a/drivers/scsi/sata_via.c +++ b/drivers/scsi/sata_via.c @@ -335,10 +335,10 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) if ((pci_resource_start(pdev, i) == 0) || (pci_resource_len(pdev, i) < bar_sizes[i])) { dev_printk(KERN_ERR, &pdev->dev, - "invalid PCI BAR %u (sz 0x%lx, val 0x%lx)\n", - i, - pci_resource_start(pdev, i), - pci_resource_len(pdev, i)); + "invalid PCI BAR %u (sz 0x%llx, val 0x%llx)\n", + i, + (unsigned long long)pci_resource_start(pdev, i), + (unsigned long long)pci_resource_len(pdev, i)); rc = -ENODEV; goto err_out_regions; } -- cgit v1.2.3-70-g09d2 From 34af946a22724c4e2b204957f2b24b22a0fb121c Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Tue, 27 Jun 2006 02:53:55 -0700 Subject: [PATCH] spin/rwlock init cleanups locking init cleanups: - convert " = SPIN_LOCK_UNLOCKED" to spin_lock_init() or DEFINE_SPINLOCK() - convert rwlocks in a similar manner this patch was generated automatically. Motivation: - cleanliness - lockdep needs control of lock initialization, which the open-coded variants do not give - it's also useful for -rt and for lock debugging in general Signed-off-by: Ingo Molnar Signed-off-by: Arjan van de Ven Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/ia64/sn/kernel/irq.c | 2 +- arch/mips/kernel/smtc.c | 4 ++-- arch/powerpc/platforms/cell/spufs/switch.c | 2 +- arch/powerpc/platforms/powermac/pfunc_core.c | 2 +- arch/powerpc/platforms/pseries/eeh_event.c | 2 +- arch/powerpc/sysdev/mmio_nvram.c | 2 +- arch/xtensa/kernel/time.c | 2 +- arch/xtensa/kernel/traps.c | 2 +- drivers/char/drm/drm_memory_debug.h | 2 +- drivers/char/drm/via_dmablit.c | 2 +- drivers/char/epca.c | 2 +- drivers/char/moxa.c | 2 +- drivers/char/specialix.c | 2 +- drivers/char/sx.c | 2 +- drivers/isdn/gigaset/common.c | 2 +- drivers/leds/led-core.c | 2 +- drivers/leds/led-triggers.c | 2 +- drivers/misc/ibmasm/module.c | 2 +- drivers/pcmcia/m8xx_pcmcia.c | 4 ++-- drivers/rapidio/rio-access.c | 4 ++-- drivers/rtc/rtc-sa1100.c | 2 +- drivers/rtc/rtc-vr41xx.c | 2 +- drivers/s390/block/dasd_eer.c | 2 +- drivers/scsi/libata-core.c | 2 +- drivers/sn/ioc3.c | 2 +- drivers/video/backlight/hp680_bl.c | 2 +- fs/nfsd/nfs4state.c | 2 +- fs/ocfs2/cluster/heartbeat.c | 2 +- fs/ocfs2/cluster/tcp.c | 2 +- fs/ocfs2/dlm/dlmdomain.c | 2 +- fs/ocfs2/dlm/dlmlock.c | 2 +- fs/ocfs2/dlm/dlmrecovery.c | 4 ++-- fs/ocfs2/dlmglue.c | 2 +- fs/ocfs2/journal.c | 2 +- include/asm-alpha/core_t2.h | 2 +- kernel/audit.c | 2 +- mm/sparse.c | 2 +- net/ipv6/route.c | 2 +- net/sunrpc/auth_gss/gss_krb5_seal.c | 2 +- net/tipc/bcast.c | 4 ++-- net/tipc/bearer.c | 2 +- net/tipc/config.c | 2 +- net/tipc/dbg.c | 2 +- net/tipc/handler.c | 2 +- net/tipc/name_table.c | 4 ++-- net/tipc/net.c | 2 +- net/tipc/node.c | 2 +- net/tipc/port.c | 4 ++-- net/tipc/ref.c | 4 ++-- net/tipc/subscr.c | 2 +- net/tipc/user_reg.c | 2 +- 51 files changed, 59 insertions(+), 59 deletions(-) (limited to 'drivers/char') diff --git a/arch/ia64/sn/kernel/irq.c b/arch/ia64/sn/kernel/irq.c index dc8e2b69671..677c6c0fd66 100644 --- a/arch/ia64/sn/kernel/irq.c +++ b/arch/ia64/sn/kernel/irq.c @@ -27,7 +27,7 @@ static void unregister_intr_pda(struct sn_irq_info *sn_irq_info); int sn_force_interrupt_flag = 1; extern int sn_ioif_inited; struct list_head **sn_irq_lh; -static spinlock_t sn_irq_info_lock = SPIN_LOCK_UNLOCKED; /* non-IRQ lock */ +static DEFINE_SPINLOCK(sn_irq_info_lock); /* non-IRQ lock */ u64 sn_intr_alloc(nasid_t local_nasid, int local_widget, struct sn_irq_info *sn_irq_info, diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c index 2e8e52c135e..70cf09afdf5 100644 --- a/arch/mips/kernel/smtc.c +++ b/arch/mips/kernel/smtc.c @@ -367,7 +367,7 @@ void mipsmt_prepare_cpus(void) dvpe(); dmt(); - freeIPIq.lock = SPIN_LOCK_UNLOCKED; + spin_lock_init(&freeIPIq.lock); /* * We probably don't have as many VPEs as we do SMP "CPUs", @@ -375,7 +375,7 @@ void mipsmt_prepare_cpus(void) */ for (i=0; ilscsa = lscsa; - csa->register_lock = SPIN_LOCK_UNLOCKED; + spin_lock_init(&csa->register_lock); /* Set LS pages reserved to allow for user-space mapping. */ for (p = lscsa->ls; p < lscsa->ls + LS_SIZE; p += PAGE_SIZE) diff --git a/arch/powerpc/platforms/powermac/pfunc_core.c b/arch/powerpc/platforms/powermac/pfunc_core.c index 047f954a89e..93e7505debc 100644 --- a/arch/powerpc/platforms/powermac/pfunc_core.c +++ b/arch/powerpc/platforms/powermac/pfunc_core.c @@ -546,7 +546,7 @@ struct pmf_device { }; static LIST_HEAD(pmf_devices); -static spinlock_t pmf_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(pmf_lock); static DEFINE_MUTEX(pmf_irq_mutex); static void pmf_release_device(struct kref *kref) diff --git a/arch/powerpc/platforms/pseries/eeh_event.c b/arch/powerpc/platforms/pseries/eeh_event.c index 8f2d12935b9..45ccc687e57 100644 --- a/arch/powerpc/platforms/pseries/eeh_event.c +++ b/arch/powerpc/platforms/pseries/eeh_event.c @@ -35,7 +35,7 @@ */ /* EEH event workqueue setup. */ -static spinlock_t eeh_eventlist_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(eeh_eventlist_lock); LIST_HEAD(eeh_eventlist); static void eeh_thread_launcher(void *); DECLARE_WORK(eeh_event_wq, eeh_thread_launcher, NULL); diff --git a/arch/powerpc/sysdev/mmio_nvram.c b/arch/powerpc/sysdev/mmio_nvram.c index 74e0d31a355..615350d46b5 100644 --- a/arch/powerpc/sysdev/mmio_nvram.c +++ b/arch/powerpc/sysdev/mmio_nvram.c @@ -32,7 +32,7 @@ static void __iomem *mmio_nvram_start; static long mmio_nvram_len; -static spinlock_t mmio_nvram_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(mmio_nvram_lock); static ssize_t mmio_nvram_read(char *buf, size_t count, loff_t *index) { diff --git a/arch/xtensa/kernel/time.c b/arch/xtensa/kernel/time.c index 937d81f62f4..fe14909f45e 100644 --- a/arch/xtensa/kernel/time.c +++ b/arch/xtensa/kernel/time.c @@ -29,7 +29,7 @@ extern volatile unsigned long wall_jiffies; -spinlock_t rtc_lock = SPIN_LOCK_UNLOCKED; +DEFINE_SPINLOCK(rtc_lock); EXPORT_SYMBOL(rtc_lock); diff --git a/arch/xtensa/kernel/traps.c b/arch/xtensa/kernel/traps.c index 225d64d73f0..27e409089a7 100644 --- a/arch/xtensa/kernel/traps.c +++ b/arch/xtensa/kernel/traps.c @@ -461,7 +461,7 @@ void show_code(unsigned int *pc) } } -spinlock_t die_lock = SPIN_LOCK_UNLOCKED; +DEFINE_SPINLOCK(die_lock); void die(const char * str, struct pt_regs * regs, long err) { diff --git a/drivers/char/drm/drm_memory_debug.h b/drivers/char/drm/drm_memory_debug.h index 6543b9a14c4..d117cc99719 100644 --- a/drivers/char/drm/drm_memory_debug.h +++ b/drivers/char/drm/drm_memory_debug.h @@ -43,7 +43,7 @@ typedef struct drm_mem_stats { unsigned long bytes_freed; } drm_mem_stats_t; -static spinlock_t drm_mem_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(drm_mem_lock); static unsigned long drm_ram_available = 0; /* In pages */ static unsigned long drm_ram_used = 0; static drm_mem_stats_t drm_mem_stats[] = diff --git a/drivers/char/drm/via_dmablit.c b/drivers/char/drm/via_dmablit.c index b7f17457b42..78a81a4a99c 100644 --- a/drivers/char/drm/via_dmablit.c +++ b/drivers/char/drm/via_dmablit.c @@ -557,7 +557,7 @@ via_init_dmablit(drm_device_t *dev) blitq->num_outstanding = 0; blitq->is_active = 0; blitq->aborting = 0; - blitq->blit_lock = SPIN_LOCK_UNLOCKED; + spin_lock_init(&blitq->blit_lock); for (j=0; jblit_queue + j); } diff --git a/drivers/char/epca.c b/drivers/char/epca.c index 9cad8501d62..dc0602ae850 100644 --- a/drivers/char/epca.c +++ b/drivers/char/epca.c @@ -80,7 +80,7 @@ static int invalid_lilo_config; /* The ISA boards do window flipping into the same spaces so its only sane with a single lock. It's still pretty efficient */ -static spinlock_t epca_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(epca_lock); /* ----------------------------------------------------------------------- MAXBOARDS is typically 12, but ISA and EISA cards are restricted to diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c index f43c2e04ead..01247cccb89 100644 --- a/drivers/char/moxa.c +++ b/drivers/char/moxa.c @@ -301,7 +301,7 @@ static struct tty_operations moxa_ops = { .tiocmset = moxa_tiocmset, }; -static spinlock_t moxa_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(moxa_lock); #ifdef CONFIG_PCI static int moxa_get_PCI_conf(struct pci_dev *p, int board_type, moxa_board_conf * board) diff --git a/drivers/char/specialix.c b/drivers/char/specialix.c index 1b5330299e3..d2d6b01dcd0 100644 --- a/drivers/char/specialix.c +++ b/drivers/char/specialix.c @@ -2477,7 +2477,7 @@ static int __init specialix_init(void) #endif for (i = 0; i < SX_NBOARD; i++) - sx_board[i].lock = SPIN_LOCK_UNLOCKED; + spin_lock_init(&sx_board[i].lock); if (sx_init_drivers()) { func_exit(); diff --git a/drivers/char/sx.c b/drivers/char/sx.c index 3b474723027..76b9107f7f8 100644 --- a/drivers/char/sx.c +++ b/drivers/char/sx.c @@ -2320,7 +2320,7 @@ static int sx_init_portstructs (int nboards, int nports) #ifdef NEW_WRITE_LOCKING port->gs.port_write_mutex = MUTEX; #endif - port->gs.driver_lock = SPIN_LOCK_UNLOCKED; + spin_lock_init(&port->gs.driver_lock); /* * Initializing wait queue */ diff --git a/drivers/isdn/gigaset/common.c b/drivers/isdn/gigaset/common.c index acb7e265678..2a56bf33a67 100644 --- a/drivers/isdn/gigaset/common.c +++ b/drivers/isdn/gigaset/common.c @@ -981,7 +981,7 @@ exit: EXPORT_SYMBOL_GPL(gigaset_stop); static LIST_HEAD(drivers); -static spinlock_t driver_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(driver_lock); struct cardstate *gigaset_get_cs_by_id(int id) { diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c index fe6541326c7..9b015f9af35 100644 --- a/drivers/leds/led-core.c +++ b/drivers/leds/led-core.c @@ -18,7 +18,7 @@ #include #include "leds.h" -rwlock_t leds_list_lock = RW_LOCK_UNLOCKED; +DEFINE_RWLOCK(leds_list_lock); LIST_HEAD(leds_list); EXPORT_SYMBOL_GPL(leds_list); diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c index 5e2cd8be119..1b1ce652396 100644 --- a/drivers/leds/led-triggers.c +++ b/drivers/leds/led-triggers.c @@ -26,7 +26,7 @@ /* * Nests outside led_cdev->trigger_lock */ -static rwlock_t triggers_list_lock = RW_LOCK_UNLOCKED; +static DEFINE_RWLOCK(triggers_list_lock); static LIST_HEAD(trigger_list); ssize_t led_trigger_store(struct class_device *dev, const char *buf, diff --git a/drivers/misc/ibmasm/module.c b/drivers/misc/ibmasm/module.c index 1fdf03fd2da..9706cc19134 100644 --- a/drivers/misc/ibmasm/module.c +++ b/drivers/misc/ibmasm/module.c @@ -85,7 +85,7 @@ static int __devinit ibmasm_init_one(struct pci_dev *pdev, const struct pci_devi } memset(sp, 0, sizeof(struct service_processor)); - sp->lock = SPIN_LOCK_UNLOCKED; + spin_lock_init(&sp->lock); INIT_LIST_HEAD(&sp->command_queue); pci_set_drvdata(pdev, (void *)sp); diff --git a/drivers/pcmcia/m8xx_pcmcia.c b/drivers/pcmcia/m8xx_pcmcia.c index 0e07d953511..d0f68ab8f04 100644 --- a/drivers/pcmcia/m8xx_pcmcia.c +++ b/drivers/pcmcia/m8xx_pcmcia.c @@ -157,7 +157,7 @@ MODULE_LICENSE("Dual MPL/GPL"); static int pcmcia_schlvl = PCMCIA_SCHLVL; -static spinlock_t events_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(events_lock); #define PCMCIA_SOCKET_KEY_5V 1 @@ -644,7 +644,7 @@ static struct platform_device m8xx_device = { }; static u32 pending_events[PCMCIA_SOCKETS_NO]; -static spinlock_t pending_event_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(pending_event_lock); static irqreturn_t m8xx_interrupt(int irq, void *dev, struct pt_regs *regs) { diff --git a/drivers/rapidio/rio-access.c b/drivers/rapidio/rio-access.c index b9fab2ae3a3..8b56bbdd011 100644 --- a/drivers/rapidio/rio-access.c +++ b/drivers/rapidio/rio-access.c @@ -17,8 +17,8 @@ * These interrupt-safe spinlocks protect all accesses to RIO * configuration space and doorbell access. */ -static spinlock_t rio_config_lock = SPIN_LOCK_UNLOCKED; -static spinlock_t rio_doorbell_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(rio_config_lock); +static DEFINE_SPINLOCK(rio_doorbell_lock); /* * Wrappers for all RIO configuration access functions. They just check diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c index ab486fbc828..9cd1cb304bb 100644 --- a/drivers/rtc/rtc-sa1100.c +++ b/drivers/rtc/rtc-sa1100.c @@ -45,7 +45,7 @@ static unsigned long rtc_freq = 1024; static struct rtc_time rtc_alarm; -static spinlock_t sa1100_rtc_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(sa1100_rtc_lock); static int rtc_update_alarm(struct rtc_time *alrm) { diff --git a/drivers/rtc/rtc-vr41xx.c b/drivers/rtc/rtc-vr41xx.c index 33e029207e2..4b9291dd444 100644 --- a/drivers/rtc/rtc-vr41xx.c +++ b/drivers/rtc/rtc-vr41xx.c @@ -93,7 +93,7 @@ static void __iomem *rtc2_base; static unsigned long epoch = 1970; /* Jan 1 1970 00:00:00 */ -static spinlock_t rtc_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(rtc_lock); static char rtc_name[] = "RTC"; static unsigned long periodic_frequency; static unsigned long periodic_count; diff --git a/drivers/s390/block/dasd_eer.c b/drivers/s390/block/dasd_eer.c index 2d946b6ca07..2d8af709947 100644 --- a/drivers/s390/block/dasd_eer.c +++ b/drivers/s390/block/dasd_eer.c @@ -89,7 +89,7 @@ struct eerbuffer { }; static LIST_HEAD(bufferlist); -static spinlock_t bufferlock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(bufferlock); static DECLARE_WAIT_QUEUE_HEAD(dasd_eer_read_wait_queue); /* diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 6c66877be2b..855ce9a9d94 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c @@ -5733,7 +5733,7 @@ module_init(ata_init); module_exit(ata_exit); static unsigned long ratelimit_time; -static spinlock_t ata_ratelimit_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(ata_ratelimit_lock); int ata_ratelimit(void) { diff --git a/drivers/sn/ioc3.c b/drivers/sn/ioc3.c index 501316b198e..ed946311d3a 100644 --- a/drivers/sn/ioc3.c +++ b/drivers/sn/ioc3.c @@ -26,7 +26,7 @@ static DECLARE_RWSEM(ioc3_devices_rwsem); static struct ioc3_submodule *ioc3_submodules[IOC3_MAX_SUBMODULES]; static struct ioc3_submodule *ioc3_ethernet; -static rwlock_t ioc3_submodules_lock = RW_LOCK_UNLOCKED; +static DEFINE_RWLOCK(ioc3_submodules_lock); /* NIC probing code */ diff --git a/drivers/video/backlight/hp680_bl.c b/drivers/video/backlight/hp680_bl.c index a71e984c93d..ffc72ae3ada 100644 --- a/drivers/video/backlight/hp680_bl.c +++ b/drivers/video/backlight/hp680_bl.c @@ -27,7 +27,7 @@ static int hp680bl_suspended; static int current_intensity = 0; -static spinlock_t bl_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(bl_lock); static struct backlight_device *hp680_backlight_device; static void hp680bl_send_intensity(struct backlight_device *bd) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 1630b5670dc..7c7d01672d3 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -123,7 +123,7 @@ static void release_stateid(struct nfs4_stateid *stp, int flags); */ /* recall_lock protects the del_recall_lru */ -static spinlock_t recall_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(recall_lock); static struct list_head del_recall_lru; static void diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c index 21f38accd03..1d26cfcd9f8 100644 --- a/fs/ocfs2/cluster/heartbeat.c +++ b/fs/ocfs2/cluster/heartbeat.c @@ -54,7 +54,7 @@ static DECLARE_RWSEM(o2hb_callback_sem); * multiple hb threads are watching multiple regions. A node is live * whenever any of the threads sees activity from the node in its region. */ -static spinlock_t o2hb_live_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(o2hb_live_lock); static struct list_head o2hb_live_slots[O2NM_MAX_NODES]; static unsigned long o2hb_live_node_bitmap[BITS_TO_LONGS(O2NM_MAX_NODES)]; static LIST_HEAD(o2hb_node_events); diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c index 0f60cc0d398..1591eb37a72 100644 --- a/fs/ocfs2/cluster/tcp.c +++ b/fs/ocfs2/cluster/tcp.c @@ -108,7 +108,7 @@ ##args); \ } while (0) -static rwlock_t o2net_handler_lock = RW_LOCK_UNLOCKED; +static DEFINE_RWLOCK(o2net_handler_lock); static struct rb_root o2net_handler_tree = RB_ROOT; static struct o2net_node o2net_nodes[O2NM_MAX_NODES]; diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c index ba27c5c5e95..b8c23f7ba67 100644 --- a/fs/ocfs2/dlm/dlmdomain.c +++ b/fs/ocfs2/dlm/dlmdomain.c @@ -88,7 +88,7 @@ out_free: * */ -spinlock_t dlm_domain_lock = SPIN_LOCK_UNLOCKED; +DEFINE_SPINLOCK(dlm_domain_lock); LIST_HEAD(dlm_domains); static DECLARE_WAIT_QUEUE_HEAD(dlm_domain_events); diff --git a/fs/ocfs2/dlm/dlmlock.c b/fs/ocfs2/dlm/dlmlock.c index d6f89577e25..5ca57ec650c 100644 --- a/fs/ocfs2/dlm/dlmlock.c +++ b/fs/ocfs2/dlm/dlmlock.c @@ -53,7 +53,7 @@ #define MLOG_MASK_PREFIX ML_DLM #include "cluster/masklog.h" -static spinlock_t dlm_cookie_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(dlm_cookie_lock); static u64 dlm_next_cookie = 1; static enum dlm_status dlm_send_remote_lock_request(struct dlm_ctxt *dlm, diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c index da399013516..29b2845f370 100644 --- a/fs/ocfs2/dlm/dlmrecovery.c +++ b/fs/ocfs2/dlm/dlmrecovery.c @@ -98,8 +98,8 @@ static void dlm_mig_lockres_worker(struct dlm_work_item *item, void *data); static u64 dlm_get_next_mig_cookie(void); -static spinlock_t dlm_reco_state_lock = SPIN_LOCK_UNLOCKED; -static spinlock_t dlm_mig_cookie_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(dlm_reco_state_lock); +static DEFINE_SPINLOCK(dlm_mig_cookie_lock); static u64 dlm_mig_cookie = 1; static u64 dlm_get_next_mig_cookie(void) diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c index 64cd52860c8..4acd37286bd 100644 --- a/fs/ocfs2/dlmglue.c +++ b/fs/ocfs2/dlmglue.c @@ -242,7 +242,7 @@ static void ocfs2_build_lock_name(enum ocfs2_lock_type type, mlog_exit_void(); } -static spinlock_t ocfs2_dlm_tracking_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(ocfs2_dlm_tracking_lock); static void ocfs2_add_lockres_tracking(struct ocfs2_lock_res *res, struct ocfs2_dlm_debug *dlm_debug) diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c index 3fe8781c22c..910a601b2e9 100644 --- a/fs/ocfs2/journal.c +++ b/fs/ocfs2/journal.c @@ -49,7 +49,7 @@ #include "buffer_head_io.h" -spinlock_t trans_inc_lock = SPIN_LOCK_UNLOCKED; +DEFINE_SPINLOCK(trans_inc_lock); static int ocfs2_force_read_journal(struct inode *inode); static int ocfs2_recover_node(struct ocfs2_super *osb, diff --git a/include/asm-alpha/core_t2.h b/include/asm-alpha/core_t2.h index dba70c62a16..457c34b6eb0 100644 --- a/include/asm-alpha/core_t2.h +++ b/include/asm-alpha/core_t2.h @@ -435,7 +435,7 @@ static inline void t2_outl(u32 b, unsigned long addr) set_hae(msb); \ } -static spinlock_t t2_hae_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(t2_hae_lock); __EXTERN_INLINE u8 t2_readb(const volatile void __iomem *xaddr) { diff --git a/kernel/audit.c b/kernel/audit.c index 7dfac7031bd..82443fb433e 100644 --- a/kernel/audit.c +++ b/kernel/audit.c @@ -818,7 +818,7 @@ err: */ unsigned int audit_serial(void) { - static spinlock_t serial_lock = SPIN_LOCK_UNLOCKED; + static DEFINE_SPINLOCK(serial_lock); static unsigned int serial = 0; unsigned long flags; diff --git a/mm/sparse.c b/mm/sparse.c index e0a3fe48aa3..c7a2b3a0e46 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -45,7 +45,7 @@ static struct mem_section *sparse_index_alloc(int nid) static int sparse_index_init(unsigned long section_nr, int nid) { - static spinlock_t index_init_lock = SPIN_LOCK_UNLOCKED; + static DEFINE_SPINLOCK(index_init_lock); unsigned long root = SECTION_NR_TO_ROOT(section_nr); struct mem_section *section; int ret = 0; diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 8a777932786..e728980160d 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -349,7 +349,7 @@ static struct rt6_info *rt6_select(struct rt6_info **head, int oif, (strict & RT6_SELECT_F_REACHABLE) && last && last != rt0) { /* no entries matched; do round-robin */ - static spinlock_t lock = SPIN_LOCK_UNLOCKED; + static DEFINE_SPINLOCK(lock); spin_lock(&lock); *head = rt0->u.next; rt0->u.next = last->u.next; diff --git a/net/sunrpc/auth_gss/gss_krb5_seal.c b/net/sunrpc/auth_gss/gss_krb5_seal.c index f43311221a7..2f312164d6d 100644 --- a/net/sunrpc/auth_gss/gss_krb5_seal.c +++ b/net/sunrpc/auth_gss/gss_krb5_seal.c @@ -70,7 +70,7 @@ # define RPCDBG_FACILITY RPCDBG_AUTH #endif -spinlock_t krb5_seq_lock = SPIN_LOCK_UNLOCKED; +DEFINE_SPINLOCK(krb5_seq_lock); u32 gss_get_mic_kerberos(struct gss_ctx *gss_ctx, struct xdr_buf *text, diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c index 54128040a12..1bb75703f38 100644 --- a/net/tipc/bcast.c +++ b/net/tipc/bcast.c @@ -117,7 +117,7 @@ struct bclink { static struct bcbearer *bcbearer = NULL; static struct bclink *bclink = NULL; static struct link *bcl = NULL; -static spinlock_t bc_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(bc_lock); char tipc_bclink_name[] = "multicast-link"; @@ -796,7 +796,7 @@ int tipc_bclink_init(void) memset(bclink, 0, sizeof(struct bclink)); INIT_LIST_HEAD(&bcl->waiting_ports); bcl->next_out_no = 1; - bclink->node.lock = SPIN_LOCK_UNLOCKED; + spin_lock_init(&bclink->node.lock); bcl->owner = &bclink->node; bcl->max_pkt = MAX_PKT_DEFAULT_MCAST; tipc_link_set_queue_limits(bcl, BCLINK_WIN_DEFAULT); diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index 4fa24b5e891..7ef17a449cf 100644 --- a/net/tipc/bearer.c +++ b/net/tipc/bearer.c @@ -566,7 +566,7 @@ restart: b_ptr->link_req = tipc_disc_init_link_req(b_ptr, &m_ptr->bcast_addr, bcast_scope, 2); } - b_ptr->publ.lock = SPIN_LOCK_UNLOCKED; + spin_lock_init(&b_ptr->publ.lock); write_unlock_bh(&tipc_net_lock); info("Enabled bearer <%s>, discovery domain %s, priority %u\n", name, addr_string_fill(addr_string, bcast_scope), priority); diff --git a/net/tipc/config.c b/net/tipc/config.c index 3ec502fac8c..285e1bc2d88 100644 --- a/net/tipc/config.c +++ b/net/tipc/config.c @@ -63,7 +63,7 @@ struct manager { static struct manager mng = { 0}; -static spinlock_t config_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(config_lock); static const void *req_tlv_area; /* request message TLV area */ static int req_tlv_space; /* request message TLV area size */ diff --git a/net/tipc/dbg.c b/net/tipc/dbg.c index 26ef95d5fe3..55130655e1e 100644 --- a/net/tipc/dbg.c +++ b/net/tipc/dbg.c @@ -41,7 +41,7 @@ #define MAX_STRING 512 static char print_string[MAX_STRING]; -static spinlock_t print_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(print_lock); static struct print_buf cons_buf = { NULL, 0, NULL, NULL }; struct print_buf *TIPC_CONS = &cons_buf; diff --git a/net/tipc/handler.c b/net/tipc/handler.c index 966f70a1b60..ae6ddf00a1a 100644 --- a/net/tipc/handler.c +++ b/net/tipc/handler.c @@ -44,7 +44,7 @@ struct queue_item { static kmem_cache_t *tipc_queue_item_cache; static struct list_head signal_queue_head; -static spinlock_t qitem_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(qitem_lock); static int handler_enabled = 0; static void process_signal_queue(unsigned long dummy); diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c index 38571306aba..a6926ff07bc 100644 --- a/net/tipc/name_table.c +++ b/net/tipc/name_table.c @@ -101,7 +101,7 @@ struct name_table { static struct name_table table = { NULL } ; static atomic_t rsv_publ_ok = ATOMIC_INIT(0); -rwlock_t tipc_nametbl_lock = RW_LOCK_UNLOCKED; +DEFINE_RWLOCK(tipc_nametbl_lock); static int hash(int x) @@ -172,7 +172,7 @@ static struct name_seq *tipc_nameseq_create(u32 type, struct hlist_head *seq_hea } memset(nseq, 0, sizeof(*nseq)); - nseq->lock = SPIN_LOCK_UNLOCKED; + spin_lock_init(&nseq->lock); nseq->type = type; nseq->sseqs = sseq; dbg("tipc_nameseq_create(): nseq = %p, type %u, ssseqs %p, ff: %u\n", diff --git a/net/tipc/net.c b/net/tipc/net.c index f7c8223ddf7..e5a359ab493 100644 --- a/net/tipc/net.c +++ b/net/tipc/net.c @@ -115,7 +115,7 @@ * - A local spin_lock protecting the queue of subscriber events. */ -rwlock_t tipc_net_lock = RW_LOCK_UNLOCKED; +DEFINE_RWLOCK(tipc_net_lock); struct network tipc_net = { NULL }; struct node *tipc_net_select_remote_node(u32 addr, u32 ref) diff --git a/net/tipc/node.c b/net/tipc/node.c index ce9678efa98..861322b935d 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c @@ -77,7 +77,7 @@ struct node *tipc_node_create(u32 addr) memset(n_ptr, 0, sizeof(*n_ptr)); n_ptr->addr = addr; - n_ptr->lock = SPIN_LOCK_UNLOCKED; + spin_lock_init(&n_ptr->lock); INIT_LIST_HEAD(&n_ptr->nsub); n_ptr->owner = c_ptr; tipc_cltr_attach_node(c_ptr, n_ptr); diff --git a/net/tipc/port.c b/net/tipc/port.c index 47d97404e3e..3251c8d8e53 100644 --- a/net/tipc/port.c +++ b/net/tipc/port.c @@ -57,8 +57,8 @@ static struct sk_buff *msg_queue_head = NULL; static struct sk_buff *msg_queue_tail = NULL; -spinlock_t tipc_port_list_lock = SPIN_LOCK_UNLOCKED; -static spinlock_t queue_lock = SPIN_LOCK_UNLOCKED; +DEFINE_SPINLOCK(tipc_port_list_lock); +static DEFINE_SPINLOCK(queue_lock); static LIST_HEAD(ports); static void port_handle_node_down(unsigned long ref); diff --git a/net/tipc/ref.c b/net/tipc/ref.c index d2f0cce10e2..596d3c8ff75 100644 --- a/net/tipc/ref.c +++ b/net/tipc/ref.c @@ -63,7 +63,7 @@ struct ref_table tipc_ref_table = { NULL }; -static rwlock_t ref_table_lock = RW_LOCK_UNLOCKED; +static DEFINE_RWLOCK(ref_table_lock); /** * tipc_ref_table_init - create reference table for objects @@ -87,7 +87,7 @@ int tipc_ref_table_init(u32 requested_size, u32 start) index_mask = sz - 1; for (i = sz - 1; i >= 0; i--) { table[i].object = NULL; - table[i].lock = SPIN_LOCK_UNLOCKED; + spin_lock_init(&table[i].lock); table[i].data.next_plus_upper = (start & ~index_mask) + i - 1; } tipc_ref_table.entries = table; diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c index fc171875660..e19b4bcd67e 100644 --- a/net/tipc/subscr.c +++ b/net/tipc/subscr.c @@ -457,7 +457,7 @@ int tipc_subscr_start(void) int res = -1; memset(&topsrv, 0, sizeof (topsrv)); - topsrv.lock = SPIN_LOCK_UNLOCKED; + spin_lock_init(&topsrv.lock); INIT_LIST_HEAD(&topsrv.subscriber_list); spin_lock_bh(&topsrv.lock); diff --git a/net/tipc/user_reg.c b/net/tipc/user_reg.c index 3f3f933976e..1e3ae57c722 100644 --- a/net/tipc/user_reg.c +++ b/net/tipc/user_reg.c @@ -67,7 +67,7 @@ struct tipc_user { static struct tipc_user *users = NULL; static u32 next_free_user = MAX_USERID + 1; -static spinlock_t reg_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(reg_lock); /** * reg_init - create TIPC user registry (but don't activate it) -- cgit v1.2.3-70-g09d2 From 283fef59d6e934e8da11631446ea8e2e93fce14c Mon Sep 17 00:00:00 2001 From: Paul Fulghum Date: Tue, 27 Jun 2006 02:54:00 -0700 Subject: [PATCH] tty: fix TCSBRK comment Fix TCSBRK comment to prevent confusion or accidental removal. Signed-off-by: Paul Fulghum Cc: Alan Cox Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/tty_io.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 8b2a5996986..bd74e82d8a7 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c @@ -2621,10 +2621,9 @@ int tty_ioctl(struct inode * inode, struct file * file, tty->driver->break_ctl(tty, 0); return 0; case TCSBRK: /* SVID version: non-zero arg --> no break */ - /* - * XXX is the above comment correct, or the - * code below correct? Is this ioctl used at - * all by anyone? + /* non-zero arg means wait for all output data + * to be sent (performed above) but don't send break. + * This is used by the tcdrain() termios function. */ if (!arg) return send_break(tty, 250); -- cgit v1.2.3-70-g09d2 From 33979734cd35ae0624337cdbc529921e4350d96f Mon Sep 17 00:00:00 2001 From: "akpm@osdl.org" Date: Tue, 27 Jun 2006 02:54:04 -0700 Subject: [PATCH] IPMI: use schedule in kthread Corey Minyard The kthread used to speed up polling for IPMI was using udelay in its busy-wait polling loop when the lower-level state machine told it to do a short delay. This just used CPU and didn't help scheduling, thus causing bad problems with other tasks. Call schedule() instead. Signed-off-by: Corey Minyard Acked-by: Matt Domsch Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/ipmi/ipmi_si_intf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/char') diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index 02a7dd7a8a5..101c14b9b26 100644 --- a/drivers/char/ipmi/ipmi_si_intf.c +++ b/drivers/char/ipmi/ipmi_si_intf.c @@ -809,7 +809,7 @@ static int ipmi_thread(void *data) /* do nothing */ } else if (smi_result == SI_SM_CALL_WITH_DELAY) - udelay(1); + schedule(); else schedule_timeout_interruptible(1); } -- cgit v1.2.3-70-g09d2 From b65b5b59f98aa317df399318b0b2770f50732d3c Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 27 Jun 2006 02:54:05 -0700 Subject: [PATCH] stallion clean up There are two locking sets involved. One locks the board mappings and the other is the tty open/close locking. The low level code was clearly designed to be ported to OS's with spin locks already so pretty much comes out in the wash Signed-off-by: Alan Cox Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/stallion.c | 208 ++++++++++++++++++++---------------------------- 1 file changed, 86 insertions(+), 122 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c index a9c5a7230f8..bf361a5ba70 100644 --- a/drivers/char/stallion.c +++ b/drivers/char/stallion.c @@ -140,15 +140,6 @@ static char *stl_drvversion = "5.6.0"; static struct tty_driver *stl_serial; -/* - * We will need to allocate a temporary write buffer for chars that - * come direct from user space. The problem is that a copy from user - * space might cause a page fault (typically on a system that is - * swapping!). All ports will share one buffer - since if the system - * is already swapping a shared buffer won't make things any worse. - */ -static char *stl_tmpwritebuf; - /* * Define a local default termios struct. All ports will be created * with this termios initially. Basically all it defines is a raw port @@ -362,6 +353,14 @@ static unsigned char stl_vecmap[] = { 0xff, 0xff, 0x00, 0x02, 0x01, 0xff, 0xff, 0x03 }; +/* + * Lock ordering is that you may not take stallion_lock holding + * brd_lock. + */ + +static spinlock_t brd_lock; /* Guard the board mapping */ +static spinlock_t stallion_lock; /* Guard the tty driver */ + /* * Set up enable and disable macros for the ECH boards. They require * the secondary io address space to be activated and deactivated. @@ -725,17 +724,7 @@ static struct class *stallion_class; static int __init stallion_module_init(void) { - unsigned long flags; - -#ifdef DEBUG - printk("init_module()\n"); -#endif - - save_flags(flags); - cli(); stl_init(); - restore_flags(flags); - return 0; } @@ -746,7 +735,6 @@ static void __exit stallion_module_exit(void) stlbrd_t *brdp; stlpanel_t *panelp; stlport_t *portp; - unsigned long flags; int i, j, k; #ifdef DEBUG @@ -756,9 +744,6 @@ static void __exit stallion_module_exit(void) printk(KERN_INFO "Unloading %s: version %s\n", stl_drvtitle, stl_drvversion); - save_flags(flags); - cli(); - /* * Free up all allocated resources used by the ports. This includes * memory and interrupts. As part of this process we will also do @@ -770,7 +755,6 @@ static void __exit stallion_module_exit(void) if (i) { printk("STALLION: failed to un-register tty driver, " "errno=%d\n", -i); - restore_flags(flags); return; } for (i = 0; i < 4; i++) { @@ -783,8 +767,6 @@ static void __exit stallion_module_exit(void) "errno=%d\n", -i); class_destroy(stallion_class); - kfree(stl_tmpwritebuf); - for (i = 0; (i < stl_nrbrds); i++) { if ((brdp = stl_brds[i]) == (stlbrd_t *) NULL) continue; @@ -814,8 +796,6 @@ static void __exit stallion_module_exit(void) kfree(brdp); stl_brds[i] = (stlbrd_t *) NULL; } - - restore_flags(flags); } module_init(stallion_module_init); @@ -948,7 +928,7 @@ static stlbrd_t *stl_allocbrd(void) brdp = kzalloc(sizeof(stlbrd_t), GFP_KERNEL); if (!brdp) { - printk("STALLION: failed to allocate memory (size=%d)\n", + printk("STALLION: failed to allocate memory (size=%Zd)\n", sizeof(stlbrd_t)); return NULL; } @@ -1066,16 +1046,17 @@ static int stl_waitcarrier(stlport_t *portp, struct file *filp) rc = 0; doclocal = 0; + spin_lock_irqsave(&stallion_lock, flags); + if (portp->tty->termios->c_cflag & CLOCAL) doclocal++; - save_flags(flags); - cli(); portp->openwaitcnt++; if (! tty_hung_up_p(filp)) portp->refcount--; for (;;) { + /* Takes brd_lock internally */ stl_setsignals(portp, 1, 1); if (tty_hung_up_p(filp) || ((portp->flags & ASYNC_INITIALIZED) == 0)) { @@ -1093,13 +1074,14 @@ static int stl_waitcarrier(stlport_t *portp, struct file *filp) rc = -ERESTARTSYS; break; } + /* FIXME */ interruptible_sleep_on(&portp->open_wait); } if (! tty_hung_up_p(filp)) portp->refcount++; portp->openwaitcnt--; - restore_flags(flags); + spin_unlock_irqrestore(&stallion_lock, flags); return rc; } @@ -1119,16 +1101,15 @@ static void stl_close(struct tty_struct *tty, struct file *filp) if (portp == (stlport_t *) NULL) return; - save_flags(flags); - cli(); + spin_lock_irqsave(&stallion_lock, flags); if (tty_hung_up_p(filp)) { - restore_flags(flags); + spin_unlock_irqrestore(&stallion_lock, flags); return; } if ((tty->count == 1) && (portp->refcount != 1)) portp->refcount = 1; if (portp->refcount-- > 1) { - restore_flags(flags); + spin_unlock_irqrestore(&stallion_lock, flags); return; } @@ -1142,11 +1123,18 @@ static void stl_close(struct tty_struct *tty, struct file *filp) * (The sc26198 has no "end-of-data" interrupt only empty FIFO) */ tty->closing = 1; + + spin_unlock_irqrestore(&stallion_lock, flags); + if (portp->closing_wait != ASYNC_CLOSING_WAIT_NONE) tty_wait_until_sent(tty, portp->closing_wait); stl_waituntilsent(tty, (HZ / 2)); + + spin_lock_irqsave(&stallion_lock, flags); portp->flags &= ~ASYNC_INITIALIZED; + spin_unlock_irqrestore(&stallion_lock, flags); + stl_disableintrs(portp); if (tty->termios->c_cflag & HUPCL) stl_setsignals(portp, 0, 0); @@ -1173,7 +1161,6 @@ static void stl_close(struct tty_struct *tty, struct file *filp) portp->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); wake_up_interruptible(&portp->close_wait); - restore_flags(flags); } /*****************************************************************************/ @@ -1195,9 +1182,6 @@ static int stl_write(struct tty_struct *tty, const unsigned char *buf, int count (int) tty, (int) buf, count); #endif - if ((tty == (struct tty_struct *) NULL) || - (stl_tmpwritebuf == (char *) NULL)) - return 0; portp = tty->driver_data; if (portp == (stlport_t *) NULL) return 0; @@ -1302,11 +1286,6 @@ static void stl_flushchars(struct tty_struct *tty) if (portp->tx.buf == (char *) NULL) return; -#if 0 - if (tty->stopped || tty->hw_stopped || - (portp->tx.head == portp->tx.tail)) - return; -#endif stl_startrxtx(portp, -1, 1); } @@ -1977,12 +1956,14 @@ static int stl_eiointr(stlbrd_t *brdp) unsigned int iobase; int handled = 0; + spin_lock(&brd_lock); panelp = brdp->panels[0]; iobase = panelp->iobase; while (inb(brdp->iostatus) & EIO_INTRPEND) { handled = 1; (* panelp->isr)(panelp, iobase); } + spin_unlock(&brd_lock); return handled; } @@ -2168,7 +2149,7 @@ static int __init stl_initports(stlbrd_t *brdp, stlpanel_t *panelp) portp = kzalloc(sizeof(stlport_t), GFP_KERNEL); if (!portp) { printk("STALLION: failed to allocate memory " - "(size=%d)\n", sizeof(stlport_t)); + "(size=%Zd)\n", sizeof(stlport_t)); break; } @@ -2304,7 +2285,7 @@ static inline int stl_initeio(stlbrd_t *brdp) panelp = kzalloc(sizeof(stlpanel_t), GFP_KERNEL); if (!panelp) { printk(KERN_WARNING "STALLION: failed to allocate memory " - "(size=%d)\n", sizeof(stlpanel_t)); + "(size=%Zd)\n", sizeof(stlpanel_t)); return -ENOMEM; } @@ -2478,7 +2459,7 @@ static inline int stl_initech(stlbrd_t *brdp) panelp = kzalloc(sizeof(stlpanel_t), GFP_KERNEL); if (!panelp) { printk("STALLION: failed to allocate memory " - "(size=%d)\n", sizeof(stlpanel_t)); + "(size=%Zd)\n", sizeof(stlpanel_t)); break; } panelp->magic = STL_PANELMAGIC; @@ -2879,8 +2860,7 @@ static int stl_getportstats(stlport_t *portp, comstats_t __user *cp) portp->stats.lflags = 0; portp->stats.rxbuffered = 0; - save_flags(flags); - cli(); + spin_lock_irqsave(&stallion_lock, flags); if (portp->tty != (struct tty_struct *) NULL) { if (portp->tty->driver_data == portp) { portp->stats.ttystate = portp->tty->flags; @@ -2894,7 +2874,7 @@ static int stl_getportstats(stlport_t *portp, comstats_t __user *cp) } } } - restore_flags(flags); + spin_unlock_irqrestore(&stallion_lock, flags); head = portp->tx.head; tail = portp->tx.tail; @@ -3055,14 +3035,6 @@ static int __init stl_init(void) if (!stl_serial) return -1; -/* - * Allocate a temporary write buffer. - */ - stl_tmpwritebuf = kmalloc(STL_TXBUFSIZE, GFP_KERNEL); - if (!stl_tmpwritebuf) - printk("STALLION: failed to allocate memory (size=%d)\n", - STL_TXBUFSIZE); - /* * Set up a character driver for per board stuff. This is mainly used * to do stats ioctls on the ports. @@ -3147,11 +3119,13 @@ static int stl_cd1400panelinit(stlbrd_t *brdp, stlpanel_t *panelp) unsigned int gfrcr; int chipmask, i, j; int nrchips, uartaddr, ioaddr; + unsigned long flags; #ifdef DEBUG printk("stl_panelinit(brdp=%x,panelp=%x)\n", (int) brdp, (int) panelp); #endif + spin_lock_irqsave(&brd_lock, flags); BRDENABLE(panelp->brdnr, panelp->pagenr); /* @@ -3189,6 +3163,7 @@ static int stl_cd1400panelinit(stlbrd_t *brdp, stlpanel_t *panelp) } BRDDISABLE(panelp->brdnr); + spin_unlock_irqrestore(&brd_lock, flags); return chipmask; } @@ -3200,6 +3175,7 @@ static int stl_cd1400panelinit(stlbrd_t *brdp, stlpanel_t *panelp) static void stl_cd1400portinit(stlbrd_t *brdp, stlpanel_t *panelp, stlport_t *portp) { + unsigned long flags; #ifdef DEBUG printk("stl_cd1400portinit(brdp=%x,panelp=%x,portp=%x)\n", (int) brdp, (int) panelp, (int) portp); @@ -3209,6 +3185,7 @@ static void stl_cd1400portinit(stlbrd_t *brdp, stlpanel_t *panelp, stlport_t *po (portp == (stlport_t *) NULL)) return; + spin_lock_irqsave(&brd_lock, flags); portp->ioaddr = panelp->iobase + (((brdp->brdtype == BRD_ECHPCI) || (portp->portnr < 8)) ? 0 : EREG_BANKSIZE); portp->uartaddr = (portp->portnr & 0x04) << 5; @@ -3219,6 +3196,7 @@ static void stl_cd1400portinit(stlbrd_t *brdp, stlpanel_t *panelp, stlport_t *po stl_cd1400setreg(portp, LIVR, (portp->portnr << 3)); portp->hwid = stl_cd1400getreg(portp, GFRCR); BRDDISABLE(portp->brdnr); + spin_unlock_irqrestore(&brd_lock, flags); } /*****************************************************************************/ @@ -3428,8 +3406,7 @@ static void stl_cd1400setport(stlport_t *portp, struct termios *tiosp) tiosp->c_cc[VSTART], tiosp->c_cc[VSTOP]); #endif - save_flags(flags); - cli(); + spin_lock_irqsave(&brd_lock, flags); BRDENABLE(portp->brdnr, portp->pagenr); stl_cd1400setreg(portp, CAR, (portp->portnr & 0x3)); srer = stl_cd1400getreg(portp, SRER); @@ -3466,7 +3443,7 @@ static void stl_cd1400setport(stlport_t *portp, struct termios *tiosp) portp->sigs &= ~TIOCM_CD; stl_cd1400setreg(portp, SRER, ((srer & ~sreroff) | sreron)); BRDDISABLE(portp->brdnr); - restore_flags(flags); + spin_unlock_irqrestore(&brd_lock, flags); } /*****************************************************************************/ @@ -3492,8 +3469,7 @@ static void stl_cd1400setsignals(stlport_t *portp, int dtr, int rts) if (rts > 0) msvr2 = MSVR2_RTS; - save_flags(flags); - cli(); + spin_lock_irqsave(&brd_lock, flags); BRDENABLE(portp->brdnr, portp->pagenr); stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03)); if (rts >= 0) @@ -3501,7 +3477,7 @@ static void stl_cd1400setsignals(stlport_t *portp, int dtr, int rts) if (dtr >= 0) stl_cd1400setreg(portp, MSVR1, msvr1); BRDDISABLE(portp->brdnr); - restore_flags(flags); + spin_unlock_irqrestore(&brd_lock, flags); } /*****************************************************************************/ @@ -3520,14 +3496,13 @@ static int stl_cd1400getsignals(stlport_t *portp) printk("stl_cd1400getsignals(portp=%x)\n", (int) portp); #endif - save_flags(flags); - cli(); + spin_lock_irqsave(&brd_lock, flags); BRDENABLE(portp->brdnr, portp->pagenr); stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03)); msvr1 = stl_cd1400getreg(portp, MSVR1); msvr2 = stl_cd1400getreg(portp, MSVR2); BRDDISABLE(portp->brdnr); - restore_flags(flags); + spin_unlock_irqrestore(&brd_lock, flags); sigs = 0; sigs |= (msvr1 & MSVR1_DCD) ? TIOCM_CD : 0; @@ -3569,15 +3544,14 @@ static void stl_cd1400enablerxtx(stlport_t *portp, int rx, int tx) else if (rx > 0) ccr |= CCR_RXENABLE; - save_flags(flags); - cli(); + spin_lock_irqsave(&brd_lock, flags); BRDENABLE(portp->brdnr, portp->pagenr); stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03)); stl_cd1400ccrwait(portp); stl_cd1400setreg(portp, CCR, ccr); stl_cd1400ccrwait(portp); BRDDISABLE(portp->brdnr); - restore_flags(flags); + spin_unlock_irqrestore(&brd_lock, flags); } /*****************************************************************************/ @@ -3609,8 +3583,7 @@ static void stl_cd1400startrxtx(stlport_t *portp, int rx, int tx) else if (rx > 0) sreron |= SRER_RXDATA; - save_flags(flags); - cli(); + spin_lock_irqsave(&brd_lock, flags); BRDENABLE(portp->brdnr, portp->pagenr); stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03)); stl_cd1400setreg(portp, SRER, @@ -3618,7 +3591,7 @@ static void stl_cd1400startrxtx(stlport_t *portp, int rx, int tx) BRDDISABLE(portp->brdnr); if (tx > 0) set_bit(ASYI_TXBUSY, &portp->istate); - restore_flags(flags); + spin_unlock_irqrestore(&brd_lock, flags); } /*****************************************************************************/ @@ -3634,13 +3607,12 @@ static void stl_cd1400disableintrs(stlport_t *portp) #ifdef DEBUG printk("stl_cd1400disableintrs(portp=%x)\n", (int) portp); #endif - save_flags(flags); - cli(); + spin_lock_irqsave(&brd_lock, flags); BRDENABLE(portp->brdnr, portp->pagenr); stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03)); stl_cd1400setreg(portp, SRER, 0); BRDDISABLE(portp->brdnr); - restore_flags(flags); + spin_unlock_irqrestore(&brd_lock, flags); } /*****************************************************************************/ @@ -3653,8 +3625,7 @@ static void stl_cd1400sendbreak(stlport_t *portp, int len) printk("stl_cd1400sendbreak(portp=%x,len=%d)\n", (int) portp, len); #endif - save_flags(flags); - cli(); + spin_lock_irqsave(&brd_lock, flags); BRDENABLE(portp->brdnr, portp->pagenr); stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03)); stl_cd1400setreg(portp, SRER, @@ -3664,7 +3635,7 @@ static void stl_cd1400sendbreak(stlport_t *portp, int len) portp->brklen = len; if (len == 1) portp->stats.txbreaks++; - restore_flags(flags); + spin_unlock_irqrestore(&brd_lock, flags); } /*****************************************************************************/ @@ -3688,8 +3659,7 @@ static void stl_cd1400flowctrl(stlport_t *portp, int state) if (tty == (struct tty_struct *) NULL) return; - save_flags(flags); - cli(); + spin_lock_irqsave(&brd_lock, flags); BRDENABLE(portp->brdnr, portp->pagenr); stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03)); @@ -3729,7 +3699,7 @@ static void stl_cd1400flowctrl(stlport_t *portp, int state) } BRDDISABLE(portp->brdnr); - restore_flags(flags); + spin_unlock_irqrestore(&brd_lock, flags); } /*****************************************************************************/ @@ -3753,8 +3723,7 @@ static void stl_cd1400sendflow(stlport_t *portp, int state) if (tty == (struct tty_struct *) NULL) return; - save_flags(flags); - cli(); + spin_lock_irqsave(&brd_lock, flags); BRDENABLE(portp->brdnr, portp->pagenr); stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03)); if (state) { @@ -3769,7 +3738,7 @@ static void stl_cd1400sendflow(stlport_t *portp, int state) stl_cd1400ccrwait(portp); } BRDDISABLE(portp->brdnr); - restore_flags(flags); + spin_unlock_irqrestore(&brd_lock, flags); } /*****************************************************************************/ @@ -3785,8 +3754,7 @@ static void stl_cd1400flush(stlport_t *portp) if (portp == (stlport_t *) NULL) return; - save_flags(flags); - cli(); + spin_lock_irqsave(&brd_lock, flags); BRDENABLE(portp->brdnr, portp->pagenr); stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03)); stl_cd1400ccrwait(portp); @@ -3794,7 +3762,7 @@ static void stl_cd1400flush(stlport_t *portp) stl_cd1400ccrwait(portp); portp->tx.tail = portp->tx.head; BRDDISABLE(portp->brdnr); - restore_flags(flags); + spin_unlock_irqrestore(&brd_lock, flags); } /*****************************************************************************/ @@ -3833,6 +3801,7 @@ static void stl_cd1400eiointr(stlpanel_t *panelp, unsigned int iobase) (int) panelp, iobase); #endif + spin_lock(&brd_lock); outb(SVRR, iobase); svrtype = inb(iobase + EREG_DATA); if (panelp->nrports > 4) { @@ -3846,6 +3815,8 @@ static void stl_cd1400eiointr(stlpanel_t *panelp, unsigned int iobase) stl_cd1400txisr(panelp, iobase); else if (svrtype & SVRR_MDM) stl_cd1400mdmisr(panelp, iobase); + + spin_unlock(&brd_lock); } /*****************************************************************************/ @@ -4433,8 +4404,7 @@ static void stl_sc26198setport(stlport_t *portp, struct termios *tiosp) tiosp->c_cc[VSTART], tiosp->c_cc[VSTOP]); #endif - save_flags(flags); - cli(); + spin_lock_irqsave(&brd_lock, flags); BRDENABLE(portp->brdnr, portp->pagenr); stl_sc26198setreg(portp, IMR, 0); stl_sc26198updatereg(portp, MR0, mr0); @@ -4461,7 +4431,7 @@ static void stl_sc26198setport(stlport_t *portp, struct termios *tiosp) portp->imr = (portp->imr & ~imroff) | imron; stl_sc26198setreg(portp, IMR, portp->imr); BRDDISABLE(portp->brdnr); - restore_flags(flags); + spin_unlock_irqrestore(&brd_lock, flags); } /*****************************************************************************/ @@ -4491,13 +4461,12 @@ static void stl_sc26198setsignals(stlport_t *portp, int dtr, int rts) else if (rts > 0) iopioron |= IPR_RTS; - save_flags(flags); - cli(); + spin_lock_irqsave(&brd_lock, flags); BRDENABLE(portp->brdnr, portp->pagenr); stl_sc26198setreg(portp, IOPIOR, ((stl_sc26198getreg(portp, IOPIOR) & ~iopioroff) | iopioron)); BRDDISABLE(portp->brdnr); - restore_flags(flags); + spin_unlock_irqrestore(&brd_lock, flags); } /*****************************************************************************/ @@ -4516,12 +4485,11 @@ static int stl_sc26198getsignals(stlport_t *portp) printk("stl_sc26198getsignals(portp=%x)\n", (int) portp); #endif - save_flags(flags); - cli(); + spin_lock_irqsave(&brd_lock, flags); BRDENABLE(portp->brdnr, portp->pagenr); ipr = stl_sc26198getreg(portp, IPR); BRDDISABLE(portp->brdnr); - restore_flags(flags); + spin_unlock_irqrestore(&brd_lock, flags); sigs = 0; sigs |= (ipr & IPR_DCD) ? 0 : TIOCM_CD; @@ -4558,13 +4526,12 @@ static void stl_sc26198enablerxtx(stlport_t *portp, int rx, int tx) else if (rx > 0) ccr |= CR_RXENABLE; - save_flags(flags); - cli(); + spin_lock_irqsave(&brd_lock, flags); BRDENABLE(portp->brdnr, portp->pagenr); stl_sc26198setreg(portp, SCCR, ccr); BRDDISABLE(portp->brdnr); portp->crenable = ccr; - restore_flags(flags); + spin_unlock_irqrestore(&brd_lock, flags); } /*****************************************************************************/ @@ -4593,15 +4560,14 @@ static void stl_sc26198startrxtx(stlport_t *portp, int rx, int tx) else if (rx > 0) imr |= IR_RXRDY | IR_RXBREAK | IR_RXWATCHDOG; - save_flags(flags); - cli(); + spin_lock_irqsave(&brd_lock, flags); BRDENABLE(portp->brdnr, portp->pagenr); stl_sc26198setreg(portp, IMR, imr); BRDDISABLE(portp->brdnr); portp->imr = imr; if (tx > 0) set_bit(ASYI_TXBUSY, &portp->istate); - restore_flags(flags); + spin_unlock_irqrestore(&brd_lock, flags); } /*****************************************************************************/ @@ -4618,13 +4584,12 @@ static void stl_sc26198disableintrs(stlport_t *portp) printk("stl_sc26198disableintrs(portp=%x)\n", (int) portp); #endif - save_flags(flags); - cli(); + spin_lock_irqsave(&brd_lock, flags); BRDENABLE(portp->brdnr, portp->pagenr); portp->imr = 0; stl_sc26198setreg(portp, IMR, 0); BRDDISABLE(portp->brdnr); - restore_flags(flags); + spin_unlock_irqrestore(&brd_lock, flags); } /*****************************************************************************/ @@ -4637,8 +4602,7 @@ static void stl_sc26198sendbreak(stlport_t *portp, int len) printk("stl_sc26198sendbreak(portp=%x,len=%d)\n", (int) portp, len); #endif - save_flags(flags); - cli(); + spin_lock_irqsave(&brd_lock, flags); BRDENABLE(portp->brdnr, portp->pagenr); if (len == 1) { stl_sc26198setreg(portp, SCCR, CR_TXSTARTBREAK); @@ -4647,7 +4611,7 @@ static void stl_sc26198sendbreak(stlport_t *portp, int len) stl_sc26198setreg(portp, SCCR, CR_TXSTOPBREAK); } BRDDISABLE(portp->brdnr); - restore_flags(flags); + spin_unlock_irqrestore(&brd_lock, flags); } /*****************************************************************************/ @@ -4672,8 +4636,7 @@ static void stl_sc26198flowctrl(stlport_t *portp, int state) if (tty == (struct tty_struct *) NULL) return; - save_flags(flags); - cli(); + spin_lock_irqsave(&brd_lock, flags); BRDENABLE(portp->brdnr, portp->pagenr); if (state) { @@ -4719,7 +4682,7 @@ static void stl_sc26198flowctrl(stlport_t *portp, int state) } BRDDISABLE(portp->brdnr); - restore_flags(flags); + spin_unlock_irqrestore(&brd_lock, flags); } /*****************************************************************************/ @@ -4744,8 +4707,7 @@ static void stl_sc26198sendflow(stlport_t *portp, int state) if (tty == (struct tty_struct *) NULL) return; - save_flags(flags); - cli(); + spin_lock_irqsave(&brd_lock, flags); BRDENABLE(portp->brdnr, portp->pagenr); if (state) { mr0 = stl_sc26198getreg(portp, MR0); @@ -4765,7 +4727,7 @@ static void stl_sc26198sendflow(stlport_t *portp, int state) stl_sc26198setreg(portp, MR0, mr0); } BRDDISABLE(portp->brdnr); - restore_flags(flags); + spin_unlock_irqrestore(&brd_lock, flags); } /*****************************************************************************/ @@ -4781,14 +4743,13 @@ static void stl_sc26198flush(stlport_t *portp) if (portp == (stlport_t *) NULL) return; - save_flags(flags); - cli(); + spin_lock_irqsave(&brd_lock, flags); BRDENABLE(portp->brdnr, portp->pagenr); stl_sc26198setreg(portp, SCCR, CR_TXRESET); stl_sc26198setreg(portp, SCCR, portp->crenable); BRDDISABLE(portp->brdnr); portp->tx.tail = portp->tx.head; - restore_flags(flags); + spin_unlock_irqrestore(&brd_lock, flags); } /*****************************************************************************/ @@ -4815,12 +4776,11 @@ static int stl_sc26198datastate(stlport_t *portp) if (test_bit(ASYI_TXBUSY, &portp->istate)) return 1; - save_flags(flags); - cli(); + spin_lock_irqsave(&brd_lock, flags); BRDENABLE(portp->brdnr, portp->pagenr); sr = stl_sc26198getreg(portp, SR); BRDDISABLE(portp->brdnr); - restore_flags(flags); + spin_unlock_irqrestore(&brd_lock, flags); return (sr & SR_TXEMPTY) ? 0 : 1; } @@ -4878,6 +4838,8 @@ static void stl_sc26198intr(stlpanel_t *panelp, unsigned int iobase) stlport_t *portp; unsigned int iack; + spin_lock(&brd_lock); + /* * Work around bug in sc26198 chip... Cannot have A6 address * line of UART high, else iack will be returned as 0. @@ -4893,6 +4855,8 @@ static void stl_sc26198intr(stlpanel_t *panelp, unsigned int iobase) stl_sc26198txisr(portp); else stl_sc26198otherisr(portp, iack); + + spin_unlock(&brd_lock); } /*****************************************************************************/ -- cgit v1.2.3-70-g09d2 From 62c83cde9282a9580994a12b3063e677181b5ebe Mon Sep 17 00:00:00 2001 From: Jim Cromie Date: Tue, 27 Jun 2006 02:54:13 -0700 Subject: [PATCH] chardev: GPIO for SCx200 & PC-8736x: whitespace pre-clean GPIO SUPPORT FOR SCx200 & PC8736x The patch-set reworks the 2.4 vintage scx200_gpio driver for modern 2.6, and refactors GPIO support to reuse it in a new driver for the GPIO on PC-8736x chips. Its handy for the Soekris.com net-4801, which has both chips. These patches have been seen recently on Kernel-Mentors, and then Kernel-Newbies ML, where Jesper Juhl kindly reviewed it. His feedback has been incorporated. Thanks Jesper ! Its also gone to soekris-tech@soekris.com for possible testing by linux folks, I've gotten 1 promise so far. Theyre mostly BSD folk over there, but we'll see.. Device-file & Sysfs The driver preserves the existing device-file interface, including the write/cmd set, but adds v to 'view' the pin-settings & configs by inducing, via gpio_dump(), a dev_info() call. Its a fairly crappy way to get status, but it sticks to the syslog approach, conservatively. Allowing users to voluntarily trigger logging is good, it gives them a familiar way to confirm their app's control & use of the pins, and I've thus reduced the pin-mode-updates from dev_info to dev_dbg. I've recently bolted on a proto sysfs interface for both new drivers. Im not including those patches here; they (the patch + doc-pre-patch) are still quite raw (and unreviewed on KNML), and since they 'invent' a convention for GPIO, a proper vetting is needed. Since this patchset is much bigger than my previous ones, Id like to keep things simpler, and address it 1st, before bolting on more stuff. The driver-split The Geode CPU and the PC-87366 Super-IO chip have GPIO units which share a common pin-architecture (same pin features, with same bits controlling), but with different addressing mechanics and port organizations. The vintage driver expresses the pin capabilities with pin-mode commands [OoPpTt],etc that change the pin configurations, and since the 2 chips share pin-arch, we can reuse the read(), write() commands, once the implementation is suitably adjusted. The patchset adds a vtable: struct nsc_gpio_ops, to abstract the existing gpio operations, then adjusts fileops.write() code to invoke operations via that vtable. Driver specific open()s set private_data to the vtable so its available for use by write(). The vtable gets the gpio_dump() too, since its user-friendly, and (could be construed as) part of the current device-file interface. To support use of dev_dbg() in write() & _dump(), the vtable gets a dev ptr too, set by both scx200 & pc8736x _gpio drivers. heres how the pins are presented in syslog: [ 1890.176223] scx200_gpio.0: io00: 0x0044 TS OD PUE EDGE LO DEBOUNCE [ 1890.287223] scx200_gpio.0: io01: 0x0003 OE PP PUD EDGE LO nsc_gpio.c: new file is new home of several file-ops methods, which are modified to get their vtable from filp->private_data, and use it where needed. scx200_gpio.c: keeps some of its existing gpio routines, but now wires them up via the vtable (they're invoked by nsc_gpio.c:nsc_gpio_write() thru this vtable). A driver-spcific open() initializes filp->private_data with the vtable. Once the split is clean, and the scx200_gpio driver is working, we copy and modify the function and variable names, and rework the access-method bodies for the different addressing scheme. Heres a working overview of the patchset: # series file for GPIO # Spring Cleaning gpio-scx/patch.preclean # scripts/Lindent fixes, editor-ctrl comments # API Modernization gpio-scx/patch.api26 # what I learned from LDD3 gpio-scx/patch.platform-dev-2 # get pdev, support for dev_dbg() gpio-scx/patch.unsigned-minor # fix to match std practice # Debuggability gpio-scx/patch.dump-diet # shrink gpio_dump() gpio-scx/patch.viewpins # add new 'command' to call dump() gpio-scx/patch.init-refactor # pull shadow-register init to sub # Access-Abstraction (add vtable) gpio-scx/patch.access-vtable # introduce nsg_gpio_ops vtable, w dump gpio-scx/patch.vtable-calls # add & use the vtable in scx200_gpio gpio-scx/patch.nscgpio-shell # add empty driver for common-fops # move code under abstraction gpio-scx/patch.migrate-fops # move file-ops methods from scx200_gpio gpio-scx/patch.common-dump # mv scx200.c:scx200_gpio_dump() to nsc_gpio.c gpio-scx/patch.add-pc8736x-gpio # add new driver, like old, w chip adapt # gpio-scx/patch.add-DEBUG # enable all dev_dbg()s # Cleanups # finish printk -> dev_dbg() etc gpio-scx/patch.pdev-pc8736x # new drvr needs pdev too, gpio-scx/patch.devdbg-nscgpio # add device to 'vtable', use in dev_dbg() # gpio-scx/patch.pin-config-view # another 'c' 'command' # gpio-scx/quiet-getset # take out excess dbg stuff (pretty quiet now) gpio-scx/patch.shadow-current # imitate scx200_gpio's shadow regs in pc87* # post KMentors-post patches .. gpio-scx/patch.mutexes # use mutexes for config-locks gpio-scx/patch.viewpins-values # extend dump to obsolete separate 'c' cmd gpio-scx/patch.kconfig # add stuff for kbuild # TBC # combine api26 with pdev, which is just one step. # merge c&v commands to single do-all-fn # delay viewpins, dump-diet should also un-ifdef it too. diff.sys-gpio-rollup-1 This patch: Removed editor format-control comments, and used scripts/Lindent to clean up whitespace, then deleted the bogus chunks :-( Signed-off-by: Jim Cromie Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/i386/kernel/scx200.c | 7 ------- drivers/char/scx200_gpio.c | 26 +++++++++----------------- include/linux/scx200.h | 7 ------- include/linux/scx200_gpio.h | 7 ------- 4 files changed, 9 insertions(+), 38 deletions(-) (limited to 'drivers/char') diff --git a/arch/i386/kernel/scx200.c b/arch/i386/kernel/scx200.c index 321f5fd26e7..4d3d8e811fe 100644 --- a/arch/i386/kernel/scx200.c +++ b/arch/i386/kernel/scx200.c @@ -159,10 +159,3 @@ EXPORT_SYMBOL(scx200_gpio_base); EXPORT_SYMBOL(scx200_gpio_shadow); EXPORT_SYMBOL(scx200_gpio_configure); EXPORT_SYMBOL(scx200_cb_base); - -/* - Local variables: - compile-command: "make -k -C ../../.. SUBDIRS=arch/i386/kernel modules" - c-basic-offset: 8 - End: -*/ diff --git a/drivers/char/scx200_gpio.c b/drivers/char/scx200_gpio.c index 664a6e97eb1..dd051ea6755 100644 --- a/drivers/char/scx200_gpio.c +++ b/drivers/char/scx200_gpio.c @@ -1,4 +1,4 @@ -/* linux/drivers/char/scx200_gpio.c +/* linux/drivers/char/scx200_gpio.c National Semiconductor SCx200 GPIO driver. Allows a user space process to play with the GPIO pins. @@ -26,7 +26,7 @@ static int major = 0; /* default to dynamic major */ module_param(major, int, 0); MODULE_PARM_DESC(major, "Major device number"); -static ssize_t scx200_gpio_write(struct file *file, const char __user *data, +static ssize_t scx200_gpio_write(struct file *file, const char __user *data, size_t len, loff_t *ppos) { unsigned m = iminor(file->f_dentry->d_inode); @@ -34,15 +34,14 @@ static ssize_t scx200_gpio_write(struct file *file, const char __user *data, for (i = 0; i < len; ++i) { char c; - if (get_user(c, data+i)) + if (get_user(c, data + i)) return -EFAULT; - switch (c) - { - case '0': - scx200_gpio_set(m, 0); + switch (c) { + case '0': + scx200_gpio_set(m, 0); break; - case '1': - scx200_gpio_set(m, 1); + case '1': + scx200_gpio_set(m, 1); break; case 'O': printk(KERN_INFO NAME ": GPIO%d output enabled\n", m); @@ -83,7 +82,7 @@ static ssize_t scx200_gpio_read(struct file *file, char __user *buf, value = scx200_gpio_get(m); if (put_user(value ? '1' : '0', buf)) return -EFAULT; - + return 1; } @@ -140,10 +139,3 @@ static void __exit scx200_gpio_cleanup(void) module_init(scx200_gpio_init); module_exit(scx200_gpio_cleanup); - -/* - Local variables: - compile-command: "make -k -C ../.. SUBDIRS=drivers/char modules" - c-basic-offset: 8 - End: -*/ diff --git a/include/linux/scx200.h b/include/linux/scx200.h index a22f9e173ad..693c0557e70 100644 --- a/include/linux/scx200.h +++ b/include/linux/scx200.h @@ -49,10 +49,3 @@ extern unsigned scx200_cb_base; #define SCx200_REV 0x3d /* Revision Register */ #define SCx200_CBA 0x3e /* Configuration Base Address Register */ #define SCx200_CBA_SCRATCH 0x64 /* Configuration Base Address Scratchpad */ - -/* - Local variables: - compile-command: "make -C ../.. bzImage modules" - c-basic-offset: 8 - End: -*/ diff --git a/include/linux/scx200_gpio.h b/include/linux/scx200_gpio.h index 30cdd648ba7..83ab8a1521f 100644 --- a/include/linux/scx200_gpio.h +++ b/include/linux/scx200_gpio.h @@ -87,10 +87,3 @@ static inline void scx200_gpio_change(int index) { #undef __SCx200_GPIO_SHADOW #undef __SCx200_GPIO_INDEX #undef __SCx200_GPIO_OUT - -/* - Local variables: - compile-command: "make -C ../.. bzImage modules" - c-basic-offset: 8 - End: -*/ -- cgit v1.2.3-70-g09d2 From 7d7f212661d68d231fdfaead03dda0dd44d5bbbb Mon Sep 17 00:00:00 2001 From: Jim Cromie Date: Tue, 27 Jun 2006 02:54:14 -0700 Subject: [PATCH] chardev: GPIO for SCx200 & PC-8736x: modernize driver init to 2.6 api Adopt many modern 2.6 coding practices, ala LDD3, chapter 3. Changes are limited to initialization calls from module init, ie: cdev_init, cdev_add, *_chrdev_region, mkdev. Signed-off-by: Jim Cromie Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/scx200_gpio.c | 53 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 12 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/scx200_gpio.c b/drivers/char/scx200_gpio.c index dd051ea6755..507a5bf567c 100644 --- a/drivers/char/scx200_gpio.c +++ b/drivers/char/scx200_gpio.c @@ -14,6 +14,9 @@ #include #include +#include +#include + #include #define NAME "scx200_gpio" @@ -26,6 +29,8 @@ static int major = 0; /* default to dynamic major */ module_param(major, int, 0); MODULE_PARM_DESC(major, "Major device number"); +extern void scx200_gpio_dump(unsigned index); + static ssize_t scx200_gpio_write(struct file *file, const char __user *data, size_t len, loff_t *ppos) { @@ -108,33 +113,57 @@ static struct file_operations scx200_gpio_fops = { .release = scx200_gpio_release, }; +struct cdev *scx200_devices; +int num_devs = 32; + static int __init scx200_gpio_init(void) { - int r; + int rc, i; + dev_t dev = MKDEV(major, 0); printk(KERN_DEBUG NAME ": NatSemi SCx200 GPIO Driver\n"); if (!scx200_gpio_present()) { - printk(KERN_ERR NAME ": no SCx200 gpio pins available\n"); + printk(KERN_ERR NAME ": no SCx200 gpio present\n"); return -ENODEV; } - - r = register_chrdev(major, NAME, &scx200_gpio_fops); - if (r < 0) { - printk(KERN_ERR NAME ": unable to register character device\n"); - return r; + if (major) + rc = register_chrdev_region(dev, num_devs, "scx200_gpio"); + else { + rc = alloc_chrdev_region(&dev, 0, num_devs, "scx200_gpio"); + major = MAJOR(dev); } - if (!major) { - major = r; - printk(KERN_DEBUG NAME ": got dynamic major %d\n", major); + if (rc < 0) { + printk(KERN_ERR NAME ": SCx200 chrdev_region: %d\n", rc); + return rc; + } + scx200_devices = kzalloc(num_devs * sizeof(struct cdev), GFP_KERNEL); + if (!scx200_devices) { + rc = -ENOMEM; + goto fail_malloc; + } + for (i = 0; i < num_devs; i++) { + struct cdev *cdev = &scx200_devices[i]; + cdev_init(cdev, &scx200_gpio_fops); + cdev->owner = THIS_MODULE; + cdev->ops = &scx200_gpio_fops; + rc = cdev_add(cdev, MKDEV(major, i), 1); + /* Fail gracefully if need be */ + if (rc) + printk(KERN_ERR NAME "Error %d on minor %d", rc, i); } - return 0; + return 0; /* succeed */ + +fail_malloc: + unregister_chrdev_region(dev, num_devs); + return rc; } static void __exit scx200_gpio_cleanup(void) { - unregister_chrdev(major, NAME); + kfree(scx200_devices); + unregister_chrdev_region(MKDEV(major, 0), num_devs); } module_init(scx200_gpio_init); -- cgit v1.2.3-70-g09d2 From 979b5ec3a7055d35b212f657e80257ec1346aa0e Mon Sep 17 00:00:00 2001 From: Jim Cromie Date: Tue, 27 Jun 2006 02:54:14 -0700 Subject: [PATCH] chardev: GPIO for SCx200 & PC-8736x: add platforn_device for use w dev_dbg Add a platform-device to scx200_gpio, and use its struct device dev member (ie: devp) in dev_dbg() once. There are 2 alternatives here (Im soliciting guidance/commentary): - use isa_device, if/when its added to the kernel. - alter scx200.c to EXPORT_GPL its private devp so that both scx200_gpio, and the (to be added) nsc_gpio module can use it. Since the available devp is in 'grandparent', this seems like too much 'action at a distance'. Signed-off-by: Jim Cromie Cc: Greg KH Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/scx200_gpio.c | 53 +++++++++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 17 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/scx200_gpio.c b/drivers/char/scx200_gpio.c index 507a5bf567c..e6e52c48697 100644 --- a/drivers/char/scx200_gpio.c +++ b/drivers/char/scx200_gpio.c @@ -6,11 +6,13 @@ Copyright (c) 2001,2002 Christer Weinigel */ #include +#include #include #include #include #include #include +#include #include #include @@ -20,6 +22,9 @@ #include #define NAME "scx200_gpio" +#define DEVNAME NAME + +static struct platform_device *pdev; MODULE_AUTHOR("Christer Weinigel "); MODULE_DESCRIPTION("NatSemi SCx200 GPIO Pin Driver"); @@ -114,56 +119,70 @@ static struct file_operations scx200_gpio_fops = { }; struct cdev *scx200_devices; -int num_devs = 32; +static int num_pins = 32; static int __init scx200_gpio_init(void) { int rc, i; dev_t dev = MKDEV(major, 0); - printk(KERN_DEBUG NAME ": NatSemi SCx200 GPIO Driver\n"); - if (!scx200_gpio_present()) { printk(KERN_ERR NAME ": no SCx200 gpio present\n"); return -ENODEV; } + + /* support dev_dbg() with pdev->dev */ + pdev = platform_device_alloc(DEVNAME, 0); + if (!pdev) + return -ENOMEM; + + rc = platform_device_add(pdev); + if (rc) + goto undo_malloc; + if (major) - rc = register_chrdev_region(dev, num_devs, "scx200_gpio"); + rc = register_chrdev_region(dev, num_pins, "scx200_gpio"); else { - rc = alloc_chrdev_region(&dev, 0, num_devs, "scx200_gpio"); + rc = alloc_chrdev_region(&dev, 0, num_pins, "scx200_gpio"); major = MAJOR(dev); } if (rc < 0) { - printk(KERN_ERR NAME ": SCx200 chrdev_region: %d\n", rc); - return rc; + dev_err(&pdev->dev, "SCx200 chrdev_region err: %d\n", rc); + goto undo_platform_device_add; } - scx200_devices = kzalloc(num_devs * sizeof(struct cdev), GFP_KERNEL); + scx200_devices = kzalloc(num_pins * sizeof(struct cdev), GFP_KERNEL); if (!scx200_devices) { rc = -ENOMEM; - goto fail_malloc; + goto undo_chrdev_region; } - for (i = 0; i < num_devs; i++) { + for (i = 0; i < num_pins; i++) { struct cdev *cdev = &scx200_devices[i]; cdev_init(cdev, &scx200_gpio_fops); cdev->owner = THIS_MODULE; - cdev->ops = &scx200_gpio_fops; rc = cdev_add(cdev, MKDEV(major, i), 1); - /* Fail gracefully if need be */ + /* tolerate 'minor' errors */ if (rc) - printk(KERN_ERR NAME "Error %d on minor %d", rc, i); + dev_err(&pdev->dev, "Error %d on minor %d", rc, i); } - return 0; /* succeed */ + return 0; /* succeed */ -fail_malloc: - unregister_chrdev_region(dev, num_devs); +undo_chrdev_region: + unregister_chrdev_region(dev, num_pins); +undo_platform_device_add: + platform_device_put(pdev); +undo_malloc: + kfree(pdev); return rc; } static void __exit scx200_gpio_cleanup(void) { kfree(scx200_devices); - unregister_chrdev_region(MKDEV(major, 0), num_devs); + unregister_chrdev_region(MKDEV(major, 0), num_pins); + platform_device_put(pdev); + platform_device_unregister(pdev); + /* kfree(pdev); */ } module_init(scx200_gpio_init); -- cgit v1.2.3-70-g09d2 From 9550a339e1ab1709dd53d92a1b76eecae2df9f3c Mon Sep 17 00:00:00 2001 From: Jim Cromie Date: Tue, 27 Jun 2006 02:54:16 -0700 Subject: [PATCH] chardev: GPIO for SCx200 & PC-8736x: add 'v' command to device-file Add a new driver command: 'v' which calls gpio_dump() on the pin. The output goes to the log, like all other INFO messages in the original driver. Giving the user control over the feedback they 'need' is construed to be a user-friendly feature, and allows us (later) to dial down many INFO messages to DEBUG log-level. Signed-off-by: Jim Cromie Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/i386/kernel/scx200.c | 3 +-- drivers/char/scx200_gpio.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'drivers/char') diff --git a/arch/i386/kernel/scx200.c b/arch/i386/kernel/scx200.c index 9e96a785dd0..009e6aa16f7 100644 --- a/arch/i386/kernel/scx200.c +++ b/arch/i386/kernel/scx200.c @@ -105,7 +105,6 @@ u32 scx200_gpio_configure(unsigned index, u32 mask, u32 bits) return config; } -#if 0 void scx200_gpio_dump(unsigned index) { u32 config = scx200_gpio_configure(index, ~0, 0); @@ -120,7 +119,6 @@ void scx200_gpio_dump(unsigned index) (config & 32) ? "HI" : "LO", /* trigger on rising/falling edge */ (config & 64) ? "DEBOUNCE" : ""); /* debounce */ } -#endif /* 0 */ static int __init scx200_init(void) { @@ -141,4 +139,5 @@ module_exit(scx200_cleanup); EXPORT_SYMBOL(scx200_gpio_base); EXPORT_SYMBOL(scx200_gpio_shadow); EXPORT_SYMBOL(scx200_gpio_configure); +EXPORT_SYMBOL(scx200_gpio_dump); EXPORT_SYMBOL(scx200_cb_base); diff --git a/drivers/char/scx200_gpio.c b/drivers/char/scx200_gpio.c index e6e52c48697..a1a56c5c8a8 100644 --- a/drivers/char/scx200_gpio.c +++ b/drivers/char/scx200_gpio.c @@ -41,6 +41,7 @@ static ssize_t scx200_gpio_write(struct file *file, const char __user *data, { unsigned m = iminor(file->f_dentry->d_inode); size_t i; + int err = 0; for (i = 0; i < len; ++i) { char c; @@ -77,8 +78,23 @@ static ssize_t scx200_gpio_write(struct file *file, const char __user *data, printk(KERN_INFO NAME ": GPIO%d pull up disabled\n", m); scx200_gpio_configure(m, ~4, 0); break; + + case 'v': + /* View Current pin settings */ + scx200_gpio_dump(m); + break; + case '\n': + /* end of settings string, do nothing */ + break; + default: + printk(KERN_ERR NAME + ": GPIO-%2d bad setting: chr<0x%2x>\n", m, + (int)c); + err++; } } + if (err) + return -EINVAL; /* full string handled, report error */ return len; } -- cgit v1.2.3-70-g09d2 From fe3a168a2ce1c93837cdf8fe27a3e67795155f90 Mon Sep 17 00:00:00 2001 From: Jim Cromie Date: Tue, 27 Jun 2006 02:54:18 -0700 Subject: [PATCH] chardev: GPIO for SCx200 & PC-8736x: add gpio-ops vtable Abstract the gpio operations into a new nsc_gpio_ops vtable. Signed-off-by: Jim Cromie Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/scx200_gpio.c | 13 +++++++++++++ include/linux/nsc_gpio.h | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 include/linux/nsc_gpio.h (limited to 'drivers/char') diff --git a/drivers/char/scx200_gpio.c b/drivers/char/scx200_gpio.c index a1a56c5c8a8..f9994ed0181 100644 --- a/drivers/char/scx200_gpio.c +++ b/drivers/char/scx200_gpio.c @@ -20,6 +20,7 @@ #include #include +#include #define NAME "scx200_gpio" #define DEVNAME NAME @@ -36,6 +37,18 @@ MODULE_PARM_DESC(major, "Major device number"); extern void scx200_gpio_dump(unsigned index); +struct nsc_gpio_ops scx200_access = { + .owner = THIS_MODULE, + .gpio_config = scx200_gpio_configure, + .gpio_dump = scx200_gpio_dump, + .gpio_get = scx200_gpio_get, + .gpio_set = scx200_gpio_set, + .gpio_set_high = scx200_gpio_set_high, + .gpio_set_low = scx200_gpio_set_low, + .gpio_change = scx200_gpio_change, + .gpio_current = scx200_gpio_current +}; + static ssize_t scx200_gpio_write(struct file *file, const char __user *data, size_t len, loff_t *ppos) { diff --git a/include/linux/nsc_gpio.h b/include/linux/nsc_gpio.h new file mode 100644 index 00000000000..3ad8ae9dcb5 --- /dev/null +++ b/include/linux/nsc_gpio.h @@ -0,0 +1,33 @@ +/** + nsc_gpio.c + + National Semiconductor GPIO common access methods. + + struct nsc_gpio_ops abstracts the low-level access + operations for the GPIO units on 2 NSC chip families; the GEODE + integrated CPU, and the PC-8736[03456] integrated PC-peripheral + chips. + + The GPIO units on these chips have the same pin architecture, but + the access methods differ. Thus, scx200_gpio and pc8736x_gpio + implement their own versions of these routines; and use the common + file-operations routines implemented in nsc_gpio module. + + Copyright (c) 2005 Jim Cromie + + NB: this work was tested on the Geode SC-1100 and PC-87366 chips. + NSC sold the GEODE line to AMD, and the PC-8736x line to Winbond. +*/ + +struct nsc_gpio_ops { + struct module* owner; + u32 (*gpio_config) (unsigned iminor, u32 mask, u32 bits); + void (*gpio_dump) (unsigned iminor); + int (*gpio_get) (unsigned iminor); + void (*gpio_set) (unsigned iminor, int state); + void (*gpio_set_high)(unsigned iminor); + void (*gpio_set_low) (unsigned iminor); + void (*gpio_change) (unsigned iminor); + int (*gpio_current) (unsigned iminor); +}; + -- cgit v1.2.3-70-g09d2 From c3dc8071eedaac8c8a05c30fe20b78452a818dd9 Mon Sep 17 00:00:00 2001 From: Jim Cromie Date: Tue, 27 Jun 2006 02:54:18 -0700 Subject: [PATCH] chardev: GPIO for SCx200 & PC-8736x: dispatch via vtable Now actually call the gpio operations thru the vtable. Signed-off-by: Jim Cromie Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/scx200_gpio.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/scx200_gpio.c b/drivers/char/scx200_gpio.c index f9994ed0181..15dfb95ebc7 100644 --- a/drivers/char/scx200_gpio.c +++ b/drivers/char/scx200_gpio.c @@ -53,6 +53,7 @@ static ssize_t scx200_gpio_write(struct file *file, const char __user *data, size_t len, loff_t *ppos) { unsigned m = iminor(file->f_dentry->d_inode); + struct nsc_gpio_ops *amp = file->private_data; size_t i; int err = 0; @@ -62,39 +63,39 @@ static ssize_t scx200_gpio_write(struct file *file, const char __user *data, return -EFAULT; switch (c) { case '0': - scx200_gpio_set(m, 0); + amp->gpio_set(m, 0); break; case '1': - scx200_gpio_set(m, 1); + amp->gpio_set(m, 1); break; case 'O': printk(KERN_INFO NAME ": GPIO%d output enabled\n", m); - scx200_gpio_configure(m, ~1, 1); + amp->gpio_config(m, ~1, 1); break; case 'o': printk(KERN_INFO NAME ": GPIO%d output disabled\n", m); - scx200_gpio_configure(m, ~1, 0); + amp->gpio_config(m, ~1, 0); break; case 'T': printk(KERN_INFO NAME ": GPIO%d output is push pull\n", m); - scx200_gpio_configure(m, ~2, 2); + amp->gpio_config(m, ~2, 2); break; case 't': printk(KERN_INFO NAME ": GPIO%d output is open drain\n", m); - scx200_gpio_configure(m, ~2, 0); + amp->gpio_config(m, ~2, 0); break; case 'P': printk(KERN_INFO NAME ": GPIO%d pull up enabled\n", m); - scx200_gpio_configure(m, ~4, 4); + amp->gpio_config(m, ~4, 4); break; case 'p': printk(KERN_INFO NAME ": GPIO%d pull up disabled\n", m); - scx200_gpio_configure(m, ~4, 0); + amp->gpio_config(m, ~4, 0); break; case 'v': /* View Current pin settings */ - scx200_gpio_dump(m); + amp->gpio_dump(m); break; case '\n': /* end of settings string, do nothing */ @@ -117,8 +118,9 @@ static ssize_t scx200_gpio_read(struct file *file, char __user *buf, { unsigned m = iminor(file->f_dentry->d_inode); int value; + struct nsc_gpio_ops *amp = file->private_data; - value = scx200_gpio_get(m); + value = amp->gpio_get(m); if (put_user(value ? '1' : '0', buf)) return -EFAULT; @@ -128,6 +130,8 @@ static ssize_t scx200_gpio_read(struct file *file, char __user *buf, static int scx200_gpio_open(struct inode *inode, struct file *file) { unsigned m = iminor(inode); + file->private_data = &scx200_access; + if (m > 63) return -EINVAL; return nonseekable_open(inode, file); -- cgit v1.2.3-70-g09d2 From 1ca5df0a4cbd17a9536e63c5f69d4717c6538eb0 Mon Sep 17 00:00:00 2001 From: Jim Cromie Date: Tue, 27 Jun 2006 02:54:19 -0700 Subject: [PATCH] chardev: GPIO for SCx200 & PC-8736x: add empty common-module Add the nsc_gpio common-support module as an empty shell. Next patch starts the migration of the common gpio support routines. Signed-off-by: Jim Cromie Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/Makefile | 2 +- drivers/char/nsc_gpio.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 drivers/char/nsc_gpio.c (limited to 'drivers/char') diff --git a/drivers/char/Makefile b/drivers/char/Makefile index 524105597ea..8bcaf4d8035 100644 --- a/drivers/char/Makefile +++ b/drivers/char/Makefile @@ -81,7 +81,7 @@ obj-$(CONFIG_COBALT_LCD) += lcd.o obj-$(CONFIG_PPDEV) += ppdev.o obj-$(CONFIG_NWBUTTON) += nwbutton.o obj-$(CONFIG_NWFLASH) += nwflash.o -obj-$(CONFIG_SCx200_GPIO) += scx200_gpio.o +obj-$(CONFIG_SCx200_GPIO) += scx200_gpio.o nsc_gpio.o obj-$(CONFIG_CS5535_GPIO) += cs5535_gpio.o obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o obj-$(CONFIG_TANBAC_TB0219) += tb0219.o diff --git a/drivers/char/nsc_gpio.c b/drivers/char/nsc_gpio.c new file mode 100644 index 00000000000..42d95904967 --- /dev/null +++ b/drivers/char/nsc_gpio.c @@ -0,0 +1,45 @@ +/* linux/drivers/char/nsc_gpio.c + + National Semiconductor common GPIO device-file/VFS methods. + Allows a user space process to control the GPIO pins. + + Copyright (c) 2001,2002 Christer Weinigel + Copyright (c) 2005 Jim Cromie +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define NAME "nsc_gpio" + +MODULE_AUTHOR("Jim Cromie "); +MODULE_DESCRIPTION("NatSemi GPIO Common Methods"); +MODULE_LICENSE("GPL"); + +static int __init nsc_gpio_init(void) +{ + printk(KERN_DEBUG NAME " initializing\n"); + return 0; +} + +static void __exit nsc_gpio_cleanup(void) +{ + printk(KERN_DEBUG NAME " cleanup\n"); +} + +/* prepare for + common routines for both scx200_gpio and pc87360_gpio +EXPORT_SYMBOL(scx200_gpio_write); +EXPORT_SYMBOL(scx200_gpio_read); +EXPORT_SYMBOL(scx200_gpio_release); +*/ + +module_init(nsc_gpio_init); +module_exit(nsc_gpio_cleanup); -- cgit v1.2.3-70-g09d2 From 1a66fdf083bf2b60c4d12feb970bc7373b59e33a Mon Sep 17 00:00:00 2001 From: Jim Cromie Date: Tue, 27 Jun 2006 02:54:20 -0700 Subject: [PATCH] chardev: GPIO for SCx200 & PC-8736x: migrate file-ops to common module Now that the read(), write() file-ops are dispatching gpio-ops via the vtable, they are generic, and can be moved 'verbatim' to the nsc_gpio common-support module. After the move, various symbols are renamed to update 'scx200_' to 'nsc_', and headers are adjusted accordingly. Signed-off-by: Jim Cromie Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/nsc_gpio.c | 97 +++++++++++++++++++++++++++++++++++++++++----- drivers/char/scx200_gpio.c | 88 ++++------------------------------------- include/linux/nsc_gpio.h | 5 +++ 3 files changed, 100 insertions(+), 90 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/nsc_gpio.c b/drivers/char/nsc_gpio.c index 42d95904967..3842c272711 100644 --- a/drivers/char/nsc_gpio.c +++ b/drivers/char/nsc_gpio.c @@ -19,9 +19,89 @@ #define NAME "nsc_gpio" -MODULE_AUTHOR("Jim Cromie "); -MODULE_DESCRIPTION("NatSemi GPIO Common Methods"); -MODULE_LICENSE("GPL"); +ssize_t nsc_gpio_write(struct file *file, const char __user *data, + size_t len, loff_t *ppos) +{ + unsigned m = iminor(file->f_dentry->d_inode); + struct nsc_gpio_ops *amp = file->private_data; + size_t i; + int err = 0; + + for (i = 0; i < len; ++i) { + char c; + if (get_user(c, data + i)) + return -EFAULT; + switch (c) { + case '0': + amp->gpio_set(m, 0); + break; + case '1': + amp->gpio_set(m, 1); + break; + case 'O': + printk(KERN_INFO NAME ": GPIO%d output enabled\n", m); + amp->gpio_config(m, ~1, 1); + break; + case 'o': + printk(KERN_INFO NAME ": GPIO%d output disabled\n", m); + amp->gpio_config(m, ~1, 0); + break; + case 'T': + printk(KERN_INFO NAME ": GPIO%d output is push pull\n", + m); + amp->gpio_config(m, ~2, 2); + break; + case 't': + printk(KERN_INFO NAME ": GPIO%d output is open drain\n", + m); + amp->gpio_config(m, ~2, 0); + break; + case 'P': + printk(KERN_INFO NAME ": GPIO%d pull up enabled\n", m); + amp->gpio_config(m, ~4, 4); + break; + case 'p': + printk(KERN_INFO NAME ": GPIO%d pull up disabled\n", m); + amp->gpio_config(m, ~4, 0); + break; + + case 'v': + /* View Current pin settings */ + amp->gpio_dump(m); + break; + case '\n': + /* end of settings string, do nothing */ + break; + default: + printk(KERN_ERR NAME + ": GPIO-%2d bad setting: chr<0x%2x>\n", m, + (int)c); + err++; + } + } + if (err) + return -EINVAL; /* full string handled, report error */ + + return len; +} + +ssize_t nsc_gpio_read(struct file *file, char __user * buf, + size_t len, loff_t * ppos) +{ + unsigned m = iminor(file->f_dentry->d_inode); + int value; + struct nsc_gpio_ops *amp = file->private_data; + + value = amp->gpio_get(m); + if (put_user(value ? '1' : '0', buf)) + return -EFAULT; + + return 1; +} + +/* common routines for both scx200_gpio and pc87360_gpio */ +EXPORT_SYMBOL(nsc_gpio_write); +EXPORT_SYMBOL(nsc_gpio_read); static int __init nsc_gpio_init(void) { @@ -34,12 +114,9 @@ static void __exit nsc_gpio_cleanup(void) printk(KERN_DEBUG NAME " cleanup\n"); } -/* prepare for - common routines for both scx200_gpio and pc87360_gpio -EXPORT_SYMBOL(scx200_gpio_write); -EXPORT_SYMBOL(scx200_gpio_read); -EXPORT_SYMBOL(scx200_gpio_release); -*/ - module_init(nsc_gpio_init); module_exit(nsc_gpio_cleanup); + +MODULE_AUTHOR("Jim Cromie "); +MODULE_DESCRIPTION("NatSemi GPIO Common Methods"); +MODULE_LICENSE("GPL"); diff --git a/drivers/char/scx200_gpio.c b/drivers/char/scx200_gpio.c index 15dfb95ebc7..eb9a8477759 100644 --- a/drivers/char/scx200_gpio.c +++ b/drivers/char/scx200_gpio.c @@ -37,6 +37,12 @@ MODULE_PARM_DESC(major, "Major device number"); extern void scx200_gpio_dump(unsigned index); +extern ssize_t nsc_gpio_write(struct file *file, const char __user *data, + size_t len, loff_t *ppos); + +extern ssize_t nsc_gpio_read(struct file *file, char __user *buf, + size_t len, loff_t *ppos); + struct nsc_gpio_ops scx200_access = { .owner = THIS_MODULE, .gpio_config = scx200_gpio_configure, @@ -49,84 +55,6 @@ struct nsc_gpio_ops scx200_access = { .gpio_current = scx200_gpio_current }; -static ssize_t scx200_gpio_write(struct file *file, const char __user *data, - size_t len, loff_t *ppos) -{ - unsigned m = iminor(file->f_dentry->d_inode); - struct nsc_gpio_ops *amp = file->private_data; - size_t i; - int err = 0; - - for (i = 0; i < len; ++i) { - char c; - if (get_user(c, data + i)) - return -EFAULT; - switch (c) { - case '0': - amp->gpio_set(m, 0); - break; - case '1': - amp->gpio_set(m, 1); - break; - case 'O': - printk(KERN_INFO NAME ": GPIO%d output enabled\n", m); - amp->gpio_config(m, ~1, 1); - break; - case 'o': - printk(KERN_INFO NAME ": GPIO%d output disabled\n", m); - amp->gpio_config(m, ~1, 0); - break; - case 'T': - printk(KERN_INFO NAME ": GPIO%d output is push pull\n", m); - amp->gpio_config(m, ~2, 2); - break; - case 't': - printk(KERN_INFO NAME ": GPIO%d output is open drain\n", m); - amp->gpio_config(m, ~2, 0); - break; - case 'P': - printk(KERN_INFO NAME ": GPIO%d pull up enabled\n", m); - amp->gpio_config(m, ~4, 4); - break; - case 'p': - printk(KERN_INFO NAME ": GPIO%d pull up disabled\n", m); - amp->gpio_config(m, ~4, 0); - break; - - case 'v': - /* View Current pin settings */ - amp->gpio_dump(m); - break; - case '\n': - /* end of settings string, do nothing */ - break; - default: - printk(KERN_ERR NAME - ": GPIO-%2d bad setting: chr<0x%2x>\n", m, - (int)c); - err++; - } - } - if (err) - return -EINVAL; /* full string handled, report error */ - - return len; -} - -static ssize_t scx200_gpio_read(struct file *file, char __user *buf, - size_t len, loff_t *ppos) -{ - unsigned m = iminor(file->f_dentry->d_inode); - int value; - struct nsc_gpio_ops *amp = file->private_data; - - value = amp->gpio_get(m); - if (put_user(value ? '1' : '0', buf)) - return -EFAULT; - - return 1; -} - static int scx200_gpio_open(struct inode *inode, struct file *file) { unsigned m = iminor(inode); @@ -145,8 +73,8 @@ static int scx200_gpio_release(struct inode *inode, struct file *file) static struct file_operations scx200_gpio_fops = { .owner = THIS_MODULE, - .write = scx200_gpio_write, - .read = scx200_gpio_read, + .write = nsc_gpio_write, + .read = nsc_gpio_read, .open = scx200_gpio_open, .release = scx200_gpio_release, }; diff --git a/include/linux/nsc_gpio.h b/include/linux/nsc_gpio.h index 3ad8ae9dcb5..27bf66f7386 100644 --- a/include/linux/nsc_gpio.h +++ b/include/linux/nsc_gpio.h @@ -31,3 +31,8 @@ struct nsc_gpio_ops { int (*gpio_current) (unsigned iminor); }; +extern ssize_t nsc_gpio_write(struct file *file, const char __user *data, + size_t len, loff_t *ppos); + +extern ssize_t nsc_gpio_read(struct file *file, char __user *buf, + size_t len, loff_t *ppos); -- cgit v1.2.3-70-g09d2 From 0e41ef3c51ea7dbb764616f60a90700647fc8518 Mon Sep 17 00:00:00 2001 From: Jim Cromie Date: Tue, 27 Jun 2006 02:54:20 -0700 Subject: [PATCH] chardev: GPIO for SCx200 & PC-8736x: migrate gpio_dump to common module Since the meaning of config-bits is the same for scx200 and pc8736x _gpios, we can share a function to deliver this to user. Since it is called via the vtable, its also completely replaceable. For now, we keep using printk... Signed-off-by: Jim Cromie Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/i386/kernel/scx200.c | 16 ---------------- drivers/char/nsc_gpio.c | 16 +++++++++++++++- drivers/char/scx200_gpio.c | 4 ++-- 3 files changed, 17 insertions(+), 19 deletions(-) (limited to 'drivers/char') diff --git a/arch/i386/kernel/scx200.c b/arch/i386/kernel/scx200.c index 27be55349c6..edead73ebef 100644 --- a/arch/i386/kernel/scx200.c +++ b/arch/i386/kernel/scx200.c @@ -110,21 +110,6 @@ u32 scx200_gpio_configure(unsigned index, u32 mask, u32 bits) return config; } -void scx200_gpio_dump(unsigned index) -{ - u32 config = scx200_gpio_configure(index, ~0, 0); - - printk(KERN_INFO NAME ": GPIO-%02u: 0x%08lx %s %s %s %s %s %s %s\n", - index, (unsigned long) config, - (config & 1) ? "OE" : "TS", /* output enabled / tristate */ - (config & 2) ? "PP" : "OD", /* push pull / open drain */ - (config & 4) ? "PUE" : "PUD", /* pull up enabled/disabled */ - (config & 8) ? "LOCKED" : "", /* locked / unlocked */ - (config & 16) ? "LEVEL" : "EDGE", /* level/edge input */ - (config & 32) ? "HI" : "LO", /* trigger on rising/falling edge */ - (config & 64) ? "DEBOUNCE" : ""); /* debounce */ -} - static int __init scx200_init(void) { printk(KERN_INFO NAME ": NatSemi SCx200 Driver\n"); @@ -144,5 +129,4 @@ module_exit(scx200_cleanup); EXPORT_SYMBOL(scx200_gpio_base); EXPORT_SYMBOL(scx200_gpio_shadow); EXPORT_SYMBOL(scx200_gpio_configure); -EXPORT_SYMBOL(scx200_gpio_dump); EXPORT_SYMBOL(scx200_cb_base); diff --git a/drivers/char/nsc_gpio.c b/drivers/char/nsc_gpio.c index 3842c272711..72b0a5791ed 100644 --- a/drivers/char/nsc_gpio.c +++ b/drivers/char/nsc_gpio.c @@ -19,6 +19,19 @@ #define NAME "nsc_gpio" +void nsc_gpio_dump(unsigned index, u32 config) +{ + printk(KERN_INFO NAME ": GPIO-%02u: 0x%08lx %s %s %s %s %s %s %s\n", + index, (unsigned long)config, + (config & 1) ? "OE" : "TS", /* output-enabled/tristate */ + (config & 2) ? "PP" : "OD", /* push pull / open drain */ + (config & 4) ? "PUE" : "PUD", /* pull up enabled/disabled */ + (config & 8) ? "LOCKED" : "", /* locked / unlocked */ + (config & 16) ? "LEVEL" : "EDGE",/* level/edge input */ + (config & 32) ? "HI" : "LO", /* trigger on rise/fall edge */ + (config & 64) ? "DEBOUNCE" : ""); /* debounce */ +} + ssize_t nsc_gpio_write(struct file *file, const char __user *data, size_t len, loff_t *ppos) { @@ -99,9 +112,10 @@ ssize_t nsc_gpio_read(struct file *file, char __user * buf, return 1; } -/* common routines for both scx200_gpio and pc87360_gpio */ +/* common file-ops routines for both scx200_gpio and pc87360_gpio */ EXPORT_SYMBOL(nsc_gpio_write); EXPORT_SYMBOL(nsc_gpio_read); +EXPORT_SYMBOL(nsc_gpio_dump); static int __init nsc_gpio_init(void) { diff --git a/drivers/char/scx200_gpio.c b/drivers/char/scx200_gpio.c index eb9a8477759..442367b3f5d 100644 --- a/drivers/char/scx200_gpio.c +++ b/drivers/char/scx200_gpio.c @@ -35,7 +35,7 @@ static int major = 0; /* default to dynamic major */ module_param(major, int, 0); MODULE_PARM_DESC(major, "Major device number"); -extern void scx200_gpio_dump(unsigned index); +extern void nsc_gpio_dump(unsigned index); extern ssize_t nsc_gpio_write(struct file *file, const char __user *data, size_t len, loff_t *ppos); @@ -46,7 +46,7 @@ extern ssize_t nsc_gpio_read(struct file *file, char __user *buf, struct nsc_gpio_ops scx200_access = { .owner = THIS_MODULE, .gpio_config = scx200_gpio_configure, - .gpio_dump = scx200_gpio_dump, + .gpio_dump = nsc_gpio_dump, .gpio_get = scx200_gpio_get, .gpio_set = scx200_gpio_set, .gpio_set_high = scx200_gpio_set_high, -- cgit v1.2.3-70-g09d2 From 681a3e7dab868a8c390724494e8b79dc596b9e0f Mon Sep 17 00:00:00 2001 From: Jim Cromie Date: Tue, 27 Jun 2006 02:54:21 -0700 Subject: [PATCH] chardev: GPIO for SCx200 & PC-8736x: add new pc8736x_gpio module Add the brand new pc8736x_gpio driver. This is mostly based upon scx200_gpio.c, but the platform_dev is treated separately, since its fairly big too. Signed-off-by: Jim Cromie Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/Makefile | 2 +- drivers/char/nsc_gpio.c | 1 - drivers/char/pc8736x_gpio.c | 296 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 297 insertions(+), 2 deletions(-) create mode 100644 drivers/char/pc8736x_gpio.c (limited to 'drivers/char') diff --git a/drivers/char/Makefile b/drivers/char/Makefile index 8bcaf4d8035..a6c528aa35a 100644 --- a/drivers/char/Makefile +++ b/drivers/char/Makefile @@ -81,7 +81,7 @@ obj-$(CONFIG_COBALT_LCD) += lcd.o obj-$(CONFIG_PPDEV) += ppdev.o obj-$(CONFIG_NWBUTTON) += nwbutton.o obj-$(CONFIG_NWFLASH) += nwflash.o -obj-$(CONFIG_SCx200_GPIO) += scx200_gpio.o nsc_gpio.o +obj-$(CONFIG_SCx200_GPIO) += scx200_gpio.o nsc_gpio.o pc8736x_gpio.o obj-$(CONFIG_CS5535_GPIO) += cs5535_gpio.o obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o obj-$(CONFIG_TANBAC_TB0219) += tb0219.o diff --git a/drivers/char/nsc_gpio.c b/drivers/char/nsc_gpio.c index 72b0a5791ed..929d68486c1 100644 --- a/drivers/char/nsc_gpio.c +++ b/drivers/char/nsc_gpio.c @@ -77,7 +77,6 @@ ssize_t nsc_gpio_write(struct file *file, const char __user *data, printk(KERN_INFO NAME ": GPIO%d pull up disabled\n", m); amp->gpio_config(m, ~4, 0); break; - case 'v': /* View Current pin settings */ amp->gpio_dump(m); diff --git a/drivers/char/pc8736x_gpio.c b/drivers/char/pc8736x_gpio.c new file mode 100644 index 00000000000..83f24279f54 --- /dev/null +++ b/drivers/char/pc8736x_gpio.c @@ -0,0 +1,296 @@ +/* linux/drivers/char/pc8736x_gpio.c + + National Semiconductor PC8736x GPIO driver. Allows a user space + process to play with the GPIO pins. + + Copyright (c) 2005 Jim Cromie + + adapted from linux/drivers/char/scx200_gpio.c + Copyright (c) 2001,2002 Christer Weinigel , +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define NAME "pc8736x_gpio" + +MODULE_AUTHOR("Jim Cromie "); +MODULE_DESCRIPTION("NatSemi SCx200 GPIO Pin Driver"); +MODULE_LICENSE("GPL"); + +static int major; /* default to dynamic major */ +module_param(major, int, 0); +MODULE_PARM_DESC(major, "Major device number"); + +static DEFINE_SPINLOCK(pc8736x_gpio_config_lock); +static unsigned pc8736x_gpio_base; + +#define SIO_BASE1 0x2E /* 1st command-reg to check */ +#define SIO_BASE2 0x4E /* alt command-reg to check */ +#define SIO_BASE_OFFSET 0x20 + +#define SIO_SID 0x20 /* SuperI/O ID Register */ +#define SIO_SID_VALUE 0xe9 /* Expected value in SuperI/O ID Register */ + +#define SIO_CF1 0x21 /* chip config, bit0 is chip enable */ + +#define SIO_UNIT_SEL 0x7 /* unit select reg */ +#define SIO_UNIT_ACT 0x30 /* unit enable */ +#define SIO_GPIO_UNIT 0x7 /* unit number of GPIO */ +#define SIO_VLM_UNIT 0x0D +#define SIO_TMS_UNIT 0x0E + +/* config-space addrs to read/write each unit's runtime addr */ +#define SIO_BASE_HADDR 0x60 +#define SIO_BASE_LADDR 0x61 + +/* GPIO config-space pin-control addresses */ +#define SIO_GPIO_PIN_SELECT 0xF0 +#define SIO_GPIO_PIN_CONFIG 0xF1 +#define SIO_GPIO_PIN_EVENT 0xF2 + +static unsigned char superio_cmd = 0; +static unsigned char selected_device = 0xFF; /* bogus start val */ + +/* GPIO port runtime access, functionality */ +static int port_offset[] = { 0, 4, 8, 10 }; /* non-uniform offsets ! */ +/* static int event_capable[] = { 1, 1, 0, 0 }; ports 2,3 are hobbled */ + +#define PORT_OUT 0 +#define PORT_IN 1 +#define PORT_EVT_EN 2 +#define PORT_EVT_STST 3 + +static inline void superio_outb(int addr, int val) +{ + outb_p(addr, superio_cmd); + outb_p(val, superio_cmd + 1); +} + +static inline int superio_inb(int addr) +{ + outb_p(addr, superio_cmd); + return inb_p(superio_cmd + 1); +} + +static int pc8736x_superio_present(void) +{ + /* try the 2 possible values, read a hardware reg to verify */ + superio_cmd = SIO_BASE1; + if (superio_inb(SIO_SID) == SIO_SID_VALUE) + return superio_cmd; + + superio_cmd = SIO_BASE2; + if (superio_inb(SIO_SID) == SIO_SID_VALUE) + return superio_cmd; + + return 0; +} + +static void device_select(unsigned devldn) +{ + superio_outb(SIO_UNIT_SEL, devldn); + selected_device = devldn; +} + +static void select_pin(unsigned iminor) +{ + /* select GPIO port/pin from device minor number */ + device_select(SIO_GPIO_UNIT); + superio_outb(SIO_GPIO_PIN_SELECT, + ((iminor << 1) & 0xF0) | (iminor & 0x7)); +} + +static inline u32 pc8736x_gpio_configure_fn(unsigned index, u32 mask, u32 bits, + u32 func_slct) +{ + u32 config, new_config; + unsigned long flags; + + spin_lock_irqsave(&pc8736x_gpio_config_lock, flags); + + device_select(SIO_GPIO_UNIT); + select_pin(index); + + /* read current config value */ + config = superio_inb(func_slct); + + /* set new config */ + new_config = (config & mask) | bits; + superio_outb(func_slct, new_config); + + spin_unlock_irqrestore(&pc8736x_gpio_config_lock, flags); + + return config; +} + +static u32 pc8736x_gpio_configure(unsigned index, u32 mask, u32 bits) +{ + return pc8736x_gpio_configure_fn(index, mask, bits, + SIO_GPIO_PIN_CONFIG); +} + +static int pc8736x_gpio_get(unsigned minor) +{ + int port, bit, val; + + port = minor >> 3; + bit = minor & 7; + val = inb_p(pc8736x_gpio_base + port_offset[port] + PORT_IN); + val >>= bit; + val &= 1; + + printk(KERN_INFO NAME ": _gpio_get(%d from %x bit %d) == val %d\n", + minor, pc8736x_gpio_base + port_offset[port] + PORT_IN, bit, + val); + + return val; +} + +static void pc8736x_gpio_set(unsigned minor, int val) +{ + int port, bit, curval; + + minor &= 0x1f; + port = minor >> 3; + bit = minor & 7; + curval = inb_p(pc8736x_gpio_base + port_offset[port] + PORT_OUT); + + printk(KERN_INFO NAME + ": addr:%x cur:%x bit-pos:%d cur-bit:%x + new:%d -> bit-new:%d\n", + pc8736x_gpio_base + port_offset[port] + PORT_OUT, + curval, bit, (curval & ~(1 << bit)), val, (val << bit)); + + val = (curval & ~(1 << bit)) | (val << bit); + + printk(KERN_INFO NAME ": gpio_set(minor:%d port:%d bit:%d" + ") %2x -> %2x\n", minor, port, bit, curval, val); + + outb_p(val, pc8736x_gpio_base + port_offset[port] + PORT_OUT); + + curval = inb_p(pc8736x_gpio_base + port_offset[port] + PORT_OUT); + val = inb_p(pc8736x_gpio_base + port_offset[port] + PORT_IN); + + printk(KERN_INFO NAME ": wrote %x, read: %x\n", curval, val); +} + +static void pc8736x_gpio_set_high(unsigned index) +{ + pc8736x_gpio_set(index, 1); +} + +static void pc8736x_gpio_set_low(unsigned index) +{ + pc8736x_gpio_set(index, 0); +} + +static int pc8736x_gpio_current(unsigned index) +{ + printk(KERN_WARNING NAME ": pc8736x_gpio_current unimplemented\n"); + return 0; +} + +static void pc8736x_gpio_change(unsigned index) +{ + pc8736x_gpio_set(index, !pc8736x_gpio_get(index)); +} + +extern void nsc_gpio_dump(unsigned iminor); + +static struct nsc_gpio_ops pc8736x_access = { + .owner = THIS_MODULE, + .gpio_config = pc8736x_gpio_configure, + .gpio_dump = nsc_gpio_dump, + .gpio_get = pc8736x_gpio_get, + .gpio_set = pc8736x_gpio_set, + .gpio_set_high = pc8736x_gpio_set_high, + .gpio_set_low = pc8736x_gpio_set_low, + .gpio_change = pc8736x_gpio_change, + .gpio_current = pc8736x_gpio_current +}; + +static int pc8736x_gpio_open(struct inode *inode, struct file *file) +{ + unsigned m = iminor(inode); + file->private_data = &pc8736x_access; + + printk(KERN_NOTICE NAME " open %d\n", m); + + if (m > 63) + return -EINVAL; + return nonseekable_open(inode, file); +} + +static struct file_operations pc8736x_gpio_fops = { + .owner = THIS_MODULE, + .open = pc8736x_gpio_open, + .write = nsc_gpio_write, + .read = nsc_gpio_read, +}; + +static int __init pc8736x_gpio_init(void) +{ + int r, rc; + + printk(KERN_DEBUG NAME " initializing\n"); + + if (!pc8736x_superio_present()) { + printk(KERN_ERR NAME ": no device found\n"); + return -ENODEV; + } + + /* Verify that chip and it's GPIO unit are both enabled. + My BIOS does this, so I take minimum action here + */ + rc = superio_inb(SIO_CF1); + if (!(rc & 0x01)) { + printk(KERN_ERR NAME ": device not enabled\n"); + return -ENODEV; + } + device_select(SIO_GPIO_UNIT); + if (!superio_inb(SIO_UNIT_ACT)) { + printk(KERN_ERR NAME ": GPIO unit not enabled\n"); + return -ENODEV; + } + + /* read GPIO unit base address */ + pc8736x_gpio_base = (superio_inb(SIO_BASE_HADDR) << 8 + | superio_inb(SIO_BASE_LADDR)); + + if (request_region(pc8736x_gpio_base, 16, NAME)) + printk(KERN_INFO NAME ": GPIO ioport %x reserved\n", + pc8736x_gpio_base); + + r = register_chrdev(major, NAME, &pc8736x_gpio_fops); + if (r < 0) { + printk(KERN_ERR NAME ": unable to register character device\n"); + return r; + } + if (!major) { + major = r; + printk(KERN_DEBUG NAME ": got dynamic major %d\n", major); + } + + pc8736x_init_shadow(); + return 0; +} + +static void __exit pc8736x_gpio_cleanup(void) +{ + printk(KERN_DEBUG NAME " cleanup\n"); + + release_region(pc8736x_gpio_base, 16); + + unregister_chrdev(major, NAME); +} + +module_init(pc8736x_gpio_init); +module_exit(pc8736x_gpio_cleanup); -- cgit v1.2.3-70-g09d2 From 58b087cda1e9e46c7061c2282f92bd8e1970bfe7 Mon Sep 17 00:00:00 2001 From: Jim Cromie Date: Tue, 27 Jun 2006 02:54:22 -0700 Subject: [PATCH] chardev: GPIO for SCx200 & PC-8736x: add platform_device for use w dev_dbg Adds platform-device to (just introduced) driver, and uses it to replace many printks with dev_dbg() etc. This could trivially be merged into previous patch, but this way matches better with the corresponding patch that does the same change to scx200_gpio. Signed-off-by: Jim Cromie Cc: Greg KH Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/pc8736x_gpio.c | 102 +++++++++++++++++++++++++++----------------- 1 file changed, 64 insertions(+), 38 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/pc8736x_gpio.c b/drivers/char/pc8736x_gpio.c index 83f24279f54..b16fbef816c 100644 --- a/drivers/char/pc8736x_gpio.c +++ b/drivers/char/pc8736x_gpio.c @@ -17,13 +17,14 @@ #include #include #include +#include #include #include -#define NAME "pc8736x_gpio" +#define DEVNAME "pc8736x_gpio" MODULE_AUTHOR("Jim Cromie "); -MODULE_DESCRIPTION("NatSemi SCx200 GPIO Pin Driver"); +MODULE_DESCRIPTION("NatSemi PC-8736x GPIO Pin Driver"); MODULE_LICENSE("GPL"); static int major; /* default to dynamic major */ @@ -42,6 +43,8 @@ static unsigned pc8736x_gpio_base; #define SIO_CF1 0x21 /* chip config, bit0 is chip enable */ +#define PC8736X_GPIO_SIZE 16 + #define SIO_UNIT_SEL 0x7 /* unit select reg */ #define SIO_UNIT_ACT 0x30 /* unit enable */ #define SIO_GPIO_UNIT 0x7 /* unit number of GPIO */ @@ -69,6 +72,8 @@ static int port_offset[] = { 0, 4, 8, 10 }; /* non-uniform offsets ! */ #define PORT_EVT_EN 2 #define PORT_EVT_STST 3 +static struct platform_device *pdev; /* use in dev_*() */ + static inline void superio_outb(int addr, int val) { outb_p(addr, superio_cmd); @@ -148,9 +153,9 @@ static int pc8736x_gpio_get(unsigned minor) val >>= bit; val &= 1; - printk(KERN_INFO NAME ": _gpio_get(%d from %x bit %d) == val %d\n", - minor, pc8736x_gpio_base + port_offset[port] + PORT_IN, bit, - val); + dev_dbg(&pdev->dev, "_gpio_get(%d from %x bit %d) == val %d\n", + minor, pc8736x_gpio_base + port_offset[port] + PORT_IN, bit, + val); return val; } @@ -164,22 +169,21 @@ static void pc8736x_gpio_set(unsigned minor, int val) bit = minor & 7; curval = inb_p(pc8736x_gpio_base + port_offset[port] + PORT_OUT); - printk(KERN_INFO NAME - ": addr:%x cur:%x bit-pos:%d cur-bit:%x + new:%d -> bit-new:%d\n", - pc8736x_gpio_base + port_offset[port] + PORT_OUT, - curval, bit, (curval & ~(1 << bit)), val, (val << bit)); + dev_dbg(&pdev->dev, "addr:%x cur:%x bit-pos:%d cur-bit:%x + new:%d -> bit-new:%d\n", + pc8736x_gpio_base + port_offset[port] + PORT_OUT, + curval, bit, (curval & ~(1 << bit)), val, (val << bit)); val = (curval & ~(1 << bit)) | (val << bit); - printk(KERN_INFO NAME ": gpio_set(minor:%d port:%d bit:%d" - ") %2x -> %2x\n", minor, port, bit, curval, val); + dev_dbg(&pdev->dev, "gpio_set(minor:%d port:%d bit:%d)" + " %2x -> %2x\n", minor, port, bit, curval, val); outb_p(val, pc8736x_gpio_base + port_offset[port] + PORT_OUT); curval = inb_p(pc8736x_gpio_base + port_offset[port] + PORT_OUT); val = inb_p(pc8736x_gpio_base + port_offset[port] + PORT_IN); - printk(KERN_INFO NAME ": wrote %x, read: %x\n", curval, val); + dev_dbg(&pdev->dev, "wrote %x, read: %x\n", curval, val); } static void pc8736x_gpio_set_high(unsigned index) @@ -194,7 +198,7 @@ static void pc8736x_gpio_set_low(unsigned index) static int pc8736x_gpio_current(unsigned index) { - printk(KERN_WARNING NAME ": pc8736x_gpio_current unimplemented\n"); + dev_warn(&pdev->dev, "pc8736x_gpio_current unimplemented\n"); return 0; } @@ -222,7 +226,7 @@ static int pc8736x_gpio_open(struct inode *inode, struct file *file) unsigned m = iminor(inode); file->private_data = &pc8736x_access; - printk(KERN_NOTICE NAME " open %d\n", m); + dev_dbg(&pdev->dev, "open %d\n", m); if (m > 63) return -EINVAL; @@ -230,21 +234,31 @@ static int pc8736x_gpio_open(struct inode *inode, struct file *file) } static struct file_operations pc8736x_gpio_fops = { - .owner = THIS_MODULE, - .open = pc8736x_gpio_open, - .write = nsc_gpio_write, - .read = nsc_gpio_read, + .owner = THIS_MODULE, + .open = pc8736x_gpio_open, + .write = nsc_gpio_write, + .read = nsc_gpio_read, }; static int __init pc8736x_gpio_init(void) { - int r, rc; + int rc = 0; + + pdev = platform_device_alloc(DEVNAME, 0); + if (!pdev) + return -ENOMEM; - printk(KERN_DEBUG NAME " initializing\n"); + rc = platform_device_add(pdev); + if (rc) { + rc = -ENODEV; + goto undo_platform_dev_alloc; + } + dev_info(&pdev->dev, "NatSemi pc8736x GPIO Driver Initializing\n"); if (!pc8736x_superio_present()) { - printk(KERN_ERR NAME ": no device found\n"); - return -ENODEV; + rc = -ENODEV; + dev_err(&pdev->dev, "no device found\n"); + goto undo_platform_dev_add; } /* Verify that chip and it's GPIO unit are both enabled. @@ -252,44 +266,56 @@ static int __init pc8736x_gpio_init(void) */ rc = superio_inb(SIO_CF1); if (!(rc & 0x01)) { - printk(KERN_ERR NAME ": device not enabled\n"); - return -ENODEV; + rc = -ENODEV; + dev_err(&pdev->dev, "device not enabled\n"); + goto undo_platform_dev_add; } device_select(SIO_GPIO_UNIT); if (!superio_inb(SIO_UNIT_ACT)) { - printk(KERN_ERR NAME ": GPIO unit not enabled\n"); - return -ENODEV; + rc = -ENODEV; + dev_err(&pdev->dev, "GPIO unit not enabled\n"); + goto undo_platform_dev_add; } - /* read GPIO unit base address */ + /* read the GPIO unit base addr that chip responds to */ pc8736x_gpio_base = (superio_inb(SIO_BASE_HADDR) << 8 | superio_inb(SIO_BASE_LADDR)); - if (request_region(pc8736x_gpio_base, 16, NAME)) - printk(KERN_INFO NAME ": GPIO ioport %x reserved\n", - pc8736x_gpio_base); + if (!request_region(pc8736x_gpio_base, 16, DEVNAME)) { + rc = -ENODEV; + dev_err(&pdev->dev, "GPIO ioport %x busy\n", + pc8736x_gpio_base); + goto undo_platform_dev_add; + } + dev_info(&pdev->dev, "GPIO ioport %x reserved\n", pc8736x_gpio_base); - r = register_chrdev(major, NAME, &pc8736x_gpio_fops); - if (r < 0) { - printk(KERN_ERR NAME ": unable to register character device\n"); - return r; + rc = register_chrdev(major, DEVNAME, &pc8736x_gpio_fops); + if (rc < 0) { + dev_err(&pdev->dev, "register-chrdev failed: %d\n", rc); + goto undo_platform_dev_add; } if (!major) { - major = r; - printk(KERN_DEBUG NAME ": got dynamic major %d\n", major); + major = rc; + dev_dbg(&pdev->dev, "got dynamic major %d\n", major); } pc8736x_init_shadow(); return 0; + +undo_platform_dev_add: + platform_device_put(pdev); +undo_platform_dev_alloc: + kfree(pdev); + return rc; } static void __exit pc8736x_gpio_cleanup(void) { - printk(KERN_DEBUG NAME " cleanup\n"); + dev_dbg(&pdev->dev, " cleanup\n"); release_region(pc8736x_gpio_base, 16); - unregister_chrdev(major, NAME); + unregister_chrdev(major, DEVNAME); } module_init(pc8736x_gpio_init); -- cgit v1.2.3-70-g09d2 From f31000e573da052b6b8bcc21faff520b4e2eda7a Mon Sep 17 00:00:00 2001 From: Jim Cromie Date: Tue, 27 Jun 2006 02:54:23 -0700 Subject: [PATCH] chardev: GPIO for SCx200 & PC-8736x: use dev_dbg in common module Use of dev_dbg() and friends is considered good practice. dev_dbg() needs a struct device *devp, but nsc_gpio is only a helper module, so it doesnt have/need its own. To provide devp to the user-modules (scx200 & pc8736x _gpio), we add it to the vtable, and set it during init. Also squeeze nsc_gpio_dump()'s format a little. [ 199.259879] pc8736x_gpio.0: io09: 0x0044 TS OD PUE EDGE LO DEBOUNCE Signed-off-by: Jim Cromie Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/nsc_gpio.c | 45 +++++++++++++++++++++++++-------------------- drivers/char/pc8736x_gpio.c | 3 +-- drivers/char/scx200_gpio.c | 11 +++-------- include/linux/nsc_gpio.h | 6 +++++- 4 files changed, 34 insertions(+), 31 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/nsc_gpio.c b/drivers/char/nsc_gpio.c index 929d68486c1..d0b5d65a73f 100644 --- a/drivers/char/nsc_gpio.c +++ b/drivers/char/nsc_gpio.c @@ -14,22 +14,27 @@ #include #include #include +#include #include #include #define NAME "nsc_gpio" -void nsc_gpio_dump(unsigned index, u32 config) +void nsc_gpio_dump(struct nsc_gpio_ops *amp, unsigned index) { - printk(KERN_INFO NAME ": GPIO-%02u: 0x%08lx %s %s %s %s %s %s %s\n", - index, (unsigned long)config, - (config & 1) ? "OE" : "TS", /* output-enabled/tristate */ - (config & 2) ? "PP" : "OD", /* push pull / open drain */ - (config & 4) ? "PUE" : "PUD", /* pull up enabled/disabled */ - (config & 8) ? "LOCKED" : "", /* locked / unlocked */ - (config & 16) ? "LEVEL" : "EDGE",/* level/edge input */ - (config & 32) ? "HI" : "LO", /* trigger on rise/fall edge */ - (config & 64) ? "DEBOUNCE" : ""); /* debounce */ + /* retrieve current config w/o changing it */ + u32 config = amp->gpio_config(index, ~0, 0); + + /* user requested via 'v' command, so its INFO */ + dev_info(amp->dev, "io%02u: 0x%04x %s %s %s %s %s %s %s\n", + index, config, + (config & 1) ? "OE" : "TS", /* output-enabled/tristate */ + (config & 2) ? "PP" : "OD", /* push pull / open drain */ + (config & 4) ? "PUE" : "PUD", /* pull up enabled/disabled */ + (config & 8) ? "LOCKED" : "", /* locked / unlocked */ + (config & 16) ? "LEVEL" : "EDGE",/* level/edge input */ + (config & 32) ? "HI" : "LO", /* trigger on rise/fall edge */ + (config & 64) ? "DEBOUNCE" : ""); /* debounce */ } ssize_t nsc_gpio_write(struct file *file, const char __user *data, @@ -37,6 +42,7 @@ ssize_t nsc_gpio_write(struct file *file, const char __user *data, { unsigned m = iminor(file->f_dentry->d_inode); struct nsc_gpio_ops *amp = file->private_data; + struct device *dev = amp->dev; size_t i; int err = 0; @@ -52,42 +58,41 @@ ssize_t nsc_gpio_write(struct file *file, const char __user *data, amp->gpio_set(m, 1); break; case 'O': - printk(KERN_INFO NAME ": GPIO%d output enabled\n", m); + dev_dbg(dev, "GPIO%d output enabled\n", m); amp->gpio_config(m, ~1, 1); break; case 'o': - printk(KERN_INFO NAME ": GPIO%d output disabled\n", m); + dev_dbg(dev, "GPIO%d output disabled\n", m); amp->gpio_config(m, ~1, 0); break; case 'T': - printk(KERN_INFO NAME ": GPIO%d output is push pull\n", + dev_dbg(dev, "GPIO%d output is push pull\n", m); amp->gpio_config(m, ~2, 2); break; case 't': - printk(KERN_INFO NAME ": GPIO%d output is open drain\n", + dev_dbg(dev, "GPIO%d output is open drain\n", m); amp->gpio_config(m, ~2, 0); break; case 'P': - printk(KERN_INFO NAME ": GPIO%d pull up enabled\n", m); + dev_dbg(dev, "GPIO%d pull up enabled\n", m); amp->gpio_config(m, ~4, 4); break; case 'p': - printk(KERN_INFO NAME ": GPIO%d pull up disabled\n", m); + dev_dbg(dev, "GPIO%d pull up disabled\n", m); amp->gpio_config(m, ~4, 0); break; case 'v': /* View Current pin settings */ - amp->gpio_dump(m); + amp->gpio_dump(amp, m); break; case '\n': /* end of settings string, do nothing */ break; default: - printk(KERN_ERR NAME - ": GPIO-%2d bad setting: chr<0x%2x>\n", m, - (int)c); + dev_err(dev, "io%2d bad setting: chr<0x%2x>\n", + m, (int)c); err++; } } diff --git a/drivers/char/pc8736x_gpio.c b/drivers/char/pc8736x_gpio.c index b16fbef816c..48ff1fc8b06 100644 --- a/drivers/char/pc8736x_gpio.c +++ b/drivers/char/pc8736x_gpio.c @@ -207,8 +207,6 @@ static void pc8736x_gpio_change(unsigned index) pc8736x_gpio_set(index, !pc8736x_gpio_get(index)); } -extern void nsc_gpio_dump(unsigned iminor); - static struct nsc_gpio_ops pc8736x_access = { .owner = THIS_MODULE, .gpio_config = pc8736x_gpio_configure, @@ -260,6 +258,7 @@ static int __init pc8736x_gpio_init(void) dev_err(&pdev->dev, "no device found\n"); goto undo_platform_dev_add; } + pc8736x_access.dev = &pdev->dev; /* Verify that chip and it's GPIO unit are both enabled. My BIOS does this, so I take minimum action here diff --git a/drivers/char/scx200_gpio.c b/drivers/char/scx200_gpio.c index 442367b3f5d..5a280a33040 100644 --- a/drivers/char/scx200_gpio.c +++ b/drivers/char/scx200_gpio.c @@ -35,14 +35,6 @@ static int major = 0; /* default to dynamic major */ module_param(major, int, 0); MODULE_PARM_DESC(major, "Major device number"); -extern void nsc_gpio_dump(unsigned index); - -extern ssize_t nsc_gpio_write(struct file *file, const char __user *data, - size_t len, loff_t *ppos); - -extern ssize_t nsc_gpio_read(struct file *file, char __user *buf, - size_t len, loff_t *ppos); - struct nsc_gpio_ops scx200_access = { .owner = THIS_MODULE, .gpio_config = scx200_gpio_configure, @@ -101,6 +93,9 @@ static int __init scx200_gpio_init(void) if (rc) goto undo_malloc; + /* nsc_gpio uses dev_dbg(), so needs this */ + scx200_access.dev = &pdev->dev; + if (major) rc = register_chrdev_region(dev, num_pins, "scx200_gpio"); else { diff --git a/include/linux/nsc_gpio.h b/include/linux/nsc_gpio.h index 27bf66f7386..135742cfada 100644 --- a/include/linux/nsc_gpio.h +++ b/include/linux/nsc_gpio.h @@ -22,13 +22,14 @@ struct nsc_gpio_ops { struct module* owner; u32 (*gpio_config) (unsigned iminor, u32 mask, u32 bits); - void (*gpio_dump) (unsigned iminor); + void (*gpio_dump) (struct nsc_gpio_ops *amp, unsigned iminor); int (*gpio_get) (unsigned iminor); void (*gpio_set) (unsigned iminor, int state); void (*gpio_set_high)(unsigned iminor); void (*gpio_set_low) (unsigned iminor); void (*gpio_change) (unsigned iminor); int (*gpio_current) (unsigned iminor); + struct device* dev; /* for dev_dbg() support, set in init */ }; extern ssize_t nsc_gpio_write(struct file *file, const char __user *data, @@ -36,3 +37,6 @@ extern ssize_t nsc_gpio_write(struct file *file, const char __user *data, extern ssize_t nsc_gpio_read(struct file *file, char __user *buf, size_t len, loff_t *ppos); + +extern void nsc_gpio_dump(struct nsc_gpio_ops *amp, unsigned index); + -- cgit v1.2.3-70-g09d2 From 6cad56fd884b7eb85ae193c94b688fe76680fcbf Mon Sep 17 00:00:00 2001 From: Jim Cromie Date: Tue, 27 Jun 2006 02:54:24 -0700 Subject: [PATCH] chardev: GPIO for SCx200 & PC-8736x: fix gpio_current, use shadow regs Add a working gpio_current() to pc8736x_gpio.c (the previous implementation just threw a dev_warn), and fix gpio_change() to use gpio_current() rather than the incorrect (and temporary) gpio_get(). Initialize shadow-regs so this all works. Signed-off-by: Jim Cromie Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/pc8736x_gpio.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/pc8736x_gpio.c b/drivers/char/pc8736x_gpio.c index 48ff1fc8b06..b8183d50833 100644 --- a/drivers/char/pc8736x_gpio.c +++ b/drivers/char/pc8736x_gpio.c @@ -33,6 +33,7 @@ MODULE_PARM_DESC(major, "Major device number"); static DEFINE_SPINLOCK(pc8736x_gpio_config_lock); static unsigned pc8736x_gpio_base; +static u8 pc8736x_gpio_shadow[4]; #define SIO_BASE1 0x2E /* 1st command-reg to check */ #define SIO_BASE2 0x4E /* alt command-reg to check */ @@ -184,6 +185,7 @@ static void pc8736x_gpio_set(unsigned minor, int val) val = inb_p(pc8736x_gpio_base + port_offset[port] + PORT_IN); dev_dbg(&pdev->dev, "wrote %x, read: %x\n", curval, val); + pc8736x_gpio_shadow[port] = val; } static void pc8736x_gpio_set_high(unsigned index) @@ -196,15 +198,18 @@ static void pc8736x_gpio_set_low(unsigned index) pc8736x_gpio_set(index, 0); } -static int pc8736x_gpio_current(unsigned index) +static int pc8736x_gpio_current(unsigned minor) { - dev_warn(&pdev->dev, "pc8736x_gpio_current unimplemented\n"); - return 0; + int port, bit; + minor &= 0x1f; + port = minor >> 3; + bit = minor & 7; + return ((pc8736x_gpio_shadow[port] >> bit) & 0x01); } static void pc8736x_gpio_change(unsigned index) { - pc8736x_gpio_set(index, !pc8736x_gpio_get(index)); + pc8736x_gpio_set(index, !pc8736x_gpio_current(index)); } static struct nsc_gpio_ops pc8736x_access = { @@ -238,6 +243,18 @@ static struct file_operations pc8736x_gpio_fops = { .read = nsc_gpio_read, }; +static void __init pc8736x_init_shadow(void) +{ + int port; + + /* read the current values driven on the GPIO signals */ + for (port = 0; port < 4; ++port) + pc8736x_gpio_shadow[port] + = inb_p(pc8736x_gpio_base + port_offset[port] + + PORT_OUT); + +} + static int __init pc8736x_gpio_init(void) { int rc = 0; @@ -317,5 +334,7 @@ static void __exit pc8736x_gpio_cleanup(void) unregister_chrdev(major, DEVNAME); } +EXPORT_SYMBOL(pc8736x_access); + module_init(pc8736x_gpio_init); module_exit(pc8736x_gpio_cleanup); -- cgit v1.2.3-70-g09d2 From 8bcf6135c3e8cdfab375f4041a48721483519eee Mon Sep 17 00:00:00 2001 From: Jim Cromie Date: Tue, 27 Jun 2006 02:54:25 -0700 Subject: [PATCH] chardev: GPIO for SCx200 & PC-8736x: replace spinlocks w mutexes Replace spinlocks guarding gpio config ops with mutexes. This is a me-too patch, and is justifiable insofar as mutexes have stricter semantics and better debugging support, so are preferred where they are applicable. Signed-off-by: Jim Cromie Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/i386/kernel/scx200.c | 8 ++++---- drivers/char/pc8736x_gpio.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'drivers/char') diff --git a/arch/i386/kernel/scx200.c b/arch/i386/kernel/scx200.c index edead73ebef..9bf590cefc7 100644 --- a/arch/i386/kernel/scx200.c +++ b/arch/i386/kernel/scx200.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -45,7 +46,7 @@ static struct pci_driver scx200_pci_driver = { .probe = scx200_probe, }; -static DEFINE_SPINLOCK(scx200_gpio_config_lock); +static DEFINE_MUTEX(scx200_gpio_config_lock); static void __devinit scx200_init_shadow(void) { @@ -95,9 +96,8 @@ static int __devinit scx200_probe(struct pci_dev *pdev, const struct pci_device_ u32 scx200_gpio_configure(unsigned index, u32 mask, u32 bits) { u32 config, new_config; - unsigned long flags; - spin_lock_irqsave(&scx200_gpio_config_lock, flags); + mutex_lock(&scx200_gpio_config_lock); outl(index, scx200_gpio_base + 0x20); config = inl(scx200_gpio_base + 0x24); @@ -105,7 +105,7 @@ u32 scx200_gpio_configure(unsigned index, u32 mask, u32 bits) new_config = (config & mask) | bits; outl(new_config, scx200_gpio_base + 0x24); - spin_unlock_irqrestore(&scx200_gpio_config_lock, flags); + mutex_unlock(&scx200_gpio_config_lock); return config; } diff --git a/drivers/char/pc8736x_gpio.c b/drivers/char/pc8736x_gpio.c index b8183d50833..72dcf222f14 100644 --- a/drivers/char/pc8736x_gpio.c +++ b/drivers/char/pc8736x_gpio.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -31,7 +32,7 @@ static int major; /* default to dynamic major */ module_param(major, int, 0); MODULE_PARM_DESC(major, "Major device number"); -static DEFINE_SPINLOCK(pc8736x_gpio_config_lock); +static DEFINE_MUTEX(pc8736x_gpio_config_lock); static unsigned pc8736x_gpio_base; static u8 pc8736x_gpio_shadow[4]; @@ -119,9 +120,8 @@ static inline u32 pc8736x_gpio_configure_fn(unsigned index, u32 mask, u32 bits, u32 func_slct) { u32 config, new_config; - unsigned long flags; - spin_lock_irqsave(&pc8736x_gpio_config_lock, flags); + mutex_lock(&pc8736x_gpio_config_lock); device_select(SIO_GPIO_UNIT); select_pin(index); @@ -133,7 +133,7 @@ static inline u32 pc8736x_gpio_configure_fn(unsigned index, u32 mask, u32 bits, new_config = (config & mask) | bits; superio_outb(func_slct, new_config); - spin_unlock_irqrestore(&pc8736x_gpio_config_lock, flags); + mutex_unlock(&pc8736x_gpio_config_lock); return config; } -- cgit v1.2.3-70-g09d2 From ec312310e43acd5bb8b49314c6d472bb60d2d30c Mon Sep 17 00:00:00 2001 From: Jim Cromie Date: Tue, 27 Jun 2006 02:54:25 -0700 Subject: [PATCH] gpio-patchset-fixups: include linux/io.h Hmm. Im somewhat ambivalent about this patch, since with it, driver wont build for vanilla 17 or older. Its also only 1/2 of your suggestion - when I tried it, I was building against vanilla 17, and asm/uaccess.h cause compilation failure. Looking back, Im perplexed as to why linux/io.h didnt cause same failure ?!? use linux/io.h rather than asm/io.h Signed-off-by: Jim Cromie Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/pc8736x_gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/char') diff --git a/drivers/char/pc8736x_gpio.c b/drivers/char/pc8736x_gpio.c index 72dcf222f14..1c706ccfdbb 100644 --- a/drivers/char/pc8736x_gpio.c +++ b/drivers/char/pc8736x_gpio.c @@ -15,12 +15,12 @@ #include #include #include +#include #include #include #include #include #include -#include #define DEVNAME "pc8736x_gpio" -- cgit v1.2.3-70-g09d2 From 23916a8e3d8f41aa91474e834ac99808b197c39e Mon Sep 17 00:00:00 2001 From: Jim Cromie Date: Tue, 27 Jun 2006 02:54:26 -0700 Subject: [PATCH] chardev: GPIO for SCx200 & PC-8736x: display pin values in/out in gpio_dump Add current pin settings to gpio_dump() output. This adds the last 'word' to the syslog lines, which displays the input and output values that the pin is set to. pc8736x_gpio.0: io00: 0x0044 TS OD PUE EDGE LO DEBOUNCE io:1/1 The 2 values may differ for a number of reasons: 1- the pin output circuitry is diaabled, (as the above 'TS' indicates) 2- it needs a pullup resistor to drive the attached circuit, 3- the external circuit needs a pullup so the open-drain has something to pull-down 4- the pin is wired to Vcc or Ground It might be appropriate to add a WARN for 2,3,4, since they could damage the chip and/or circuit, esp if misconfig goes unnoticed. Signed-off-by: Jim Cromie Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/nsc_gpio.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/nsc_gpio.c b/drivers/char/nsc_gpio.c index d0b5d65a73f..5b91e4e2564 100644 --- a/drivers/char/nsc_gpio.c +++ b/drivers/char/nsc_gpio.c @@ -26,7 +26,7 @@ void nsc_gpio_dump(struct nsc_gpio_ops *amp, unsigned index) u32 config = amp->gpio_config(index, ~0, 0); /* user requested via 'v' command, so its INFO */ - dev_info(amp->dev, "io%02u: 0x%04x %s %s %s %s %s %s %s\n", + dev_info(amp->dev, "io%02u: 0x%04x %s %s %s %s %s %s %s\tio:%d/%d\n", index, config, (config & 1) ? "OE" : "TS", /* output-enabled/tristate */ (config & 2) ? "PP" : "OD", /* push pull / open drain */ @@ -34,7 +34,9 @@ void nsc_gpio_dump(struct nsc_gpio_ops *amp, unsigned index) (config & 8) ? "LOCKED" : "", /* locked / unlocked */ (config & 16) ? "LEVEL" : "EDGE",/* level/edge input */ (config & 32) ? "HI" : "LO", /* trigger on rise/fall edge */ - (config & 64) ? "DEBOUNCE" : ""); /* debounce */ + (config & 64) ? "DEBOUNCE" : "", /* debounce */ + + amp->gpio_get(index), amp->gpio_current(index)); } ssize_t nsc_gpio_write(struct file *file, const char __user *data, -- cgit v1.2.3-70-g09d2 From 7a8e2a5ea4cf43c0edd6db56a156549edb0eee98 Mon Sep 17 00:00:00 2001 From: Jim Cromie Date: Tue, 27 Jun 2006 02:54:27 -0700 Subject: [PATCH] chardev: GPIO for SCx200 & PC-8736x: add proper Kconfig, Makefile entries Replace the temp makefile hacks with proper CONFIG entries, which are also added to Kconfig. Signed-off-by: Jim Cromie Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/Kconfig | 23 +++++++++++++++++++++++ drivers/char/Makefile | 4 +++- 2 files changed, 26 insertions(+), 1 deletion(-) (limited to 'drivers/char') diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index 3610c572955..410d70cb76f 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -939,12 +939,35 @@ config MWAVE config SCx200_GPIO tristate "NatSemi SCx200 GPIO Support" depends on SCx200 + select NSC_GPIO help Give userspace access to the GPIO pins on the National Semiconductor SCx200 processors. If compiled as a module, it will be called scx200_gpio. +config PC8736x_GPIO + tristate "NatSemi PC8736x GPIO Support" + depends on X86 + default SCx200_GPIO # mostly N + select NSC_GPIO # needed for support routines + help + Give userspace access to the GPIO pins on the National + Semiconductor PC-8736x (x=[03456]) SuperIO chip. The chip + has multiple functional units, inc several managed by + hwmon/pc87360 driver. Tested with PC-87366 + + If compiled as a module, it will be called pc8736x_gpio. + +config NSC_GPIO + tristate "NatSemi Base GPIO Support" + # selected by SCx200_GPIO and PC8736x_GPIO + # what about 2 selectors differing: m != y + help + Common support used (and needed) by scx200_gpio and + pc8736x_gpio drivers. If those drivers are built as + modules, this one will be too, named nsc_gpio + config CS5535_GPIO tristate "AMD CS5535/CS5536 GPIO (Geode Companion Device)" depends on X86_32 diff --git a/drivers/char/Makefile b/drivers/char/Makefile index a6c528aa35a..6e0f4469d8b 100644 --- a/drivers/char/Makefile +++ b/drivers/char/Makefile @@ -81,7 +81,9 @@ obj-$(CONFIG_COBALT_LCD) += lcd.o obj-$(CONFIG_PPDEV) += ppdev.o obj-$(CONFIG_NWBUTTON) += nwbutton.o obj-$(CONFIG_NWFLASH) += nwflash.o -obj-$(CONFIG_SCx200_GPIO) += scx200_gpio.o nsc_gpio.o pc8736x_gpio.o +obj-$(CONFIG_SCx200_GPIO) += scx200_gpio.o +obj-$(CONFIG_PC8736x_GPIO) += pc8736x_gpio.o +obj-$(CONFIG_NSC_GPIO) += nsc_gpio.o obj-$(CONFIG_CS5535_GPIO) += cs5535_gpio.o obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o obj-$(CONFIG_TANBAC_TB0219) += tb0219.o -- cgit v1.2.3-70-g09d2 From 8f7607803717e9d045965b210cd16a25d80cd04b Mon Sep 17 00:00:00 2001 From: Jesper Juhl Date: Tue, 27 Jun 2006 02:55:06 -0700 Subject: [PATCH] Remove redundant NULL checks before [kv]free - in drivers/ Remove redundant NULL chck before kfree + tiny CodingStyle cleanup for drivers/ Signed-off-by: Jesper Juhl Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/agp/sgi-agp.c | 5 ++--- drivers/char/hvcs.c | 11 +++++------ drivers/message/fusion/mptfc.c | 6 ++---- drivers/message/fusion/mptsas.c | 3 +-- drivers/net/fs_enet/fs_enet-mii.c | 3 +-- drivers/net/wireless/ipw2200.c | 22 ++++++---------------- drivers/scsi/libata-scsi.c | 4 +--- drivers/video/au1100fb.c | 3 +-- 8 files changed, 19 insertions(+), 38 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/agp/sgi-agp.c b/drivers/char/agp/sgi-agp.c index cfa7922cb43..d73be4c2db8 100644 --- a/drivers/char/agp/sgi-agp.c +++ b/drivers/char/agp/sgi-agp.c @@ -329,9 +329,8 @@ static int __devinit agp_sgi_init(void) static void __devexit agp_sgi_cleanup(void) { - if (sgi_tioca_agp_bridges) - kfree(sgi_tioca_agp_bridges); - sgi_tioca_agp_bridges=NULL; + kfree(sgi_tioca_agp_bridges); + sgi_tioca_agp_bridges = NULL; } module_init(agp_sgi_init); diff --git a/drivers/char/hvcs.c b/drivers/char/hvcs.c index 8d97b391129..afa26b65dac 100644 --- a/drivers/char/hvcs.c +++ b/drivers/char/hvcs.c @@ -1320,11 +1320,12 @@ static struct tty_operations hvcs_ops = { static int hvcs_alloc_index_list(int n) { int i; + hvcs_index_list = kmalloc(n * sizeof(hvcs_index_count),GFP_KERNEL); if (!hvcs_index_list) return -ENOMEM; hvcs_index_count = n; - for(i = 0; i < hvcs_index_count; i++) + for (i = 0; i < hvcs_index_count; i++) hvcs_index_list[i] = -1; return 0; } @@ -1332,11 +1333,9 @@ static int hvcs_alloc_index_list(int n) static void hvcs_free_index_list(void) { /* Paranoia check to be thorough. */ - if (hvcs_index_list) { - kfree(hvcs_index_list); - hvcs_index_list = NULL; - hvcs_index_count = 0; - } + kfree(hvcs_index_list); + hvcs_index_list = NULL; + hvcs_index_count = 0; } static int __init hvcs_module_init(void) diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c index 74714e5bcf0..3ff8378ea66 100644 --- a/drivers/message/fusion/mptfc.c +++ b/drivers/message/fusion/mptfc.c @@ -305,10 +305,8 @@ mptfc_GetFcDevPage0(MPT_ADAPTER *ioc, int ioc_port, } out: - if (pp0_array) - kfree(pp0_array); - if (p0_array) - kfree(p0_array); + kfree(pp0_array); + kfree(p0_array); return rc; } diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c index af6ec553ff7..85689ab46cb 100644 --- a/drivers/message/fusion/mptsas.c +++ b/drivers/message/fusion/mptsas.c @@ -1378,8 +1378,7 @@ mptsas_probe_hba_phys(MPT_ADAPTER *ioc) return 0; out_free_port_info: - if (hba) - kfree(hba); + kfree(hba); out: return error; } diff --git a/drivers/net/fs_enet/fs_enet-mii.c b/drivers/net/fs_enet/fs_enet-mii.c index c6770377ef8..0cd07150bf4 100644 --- a/drivers/net/fs_enet/fs_enet-mii.c +++ b/drivers/net/fs_enet/fs_enet-mii.c @@ -431,8 +431,7 @@ static struct fs_enet_mii_bus *create_bus(const struct fs_mii_bus_info *bi) return bus; err: - if (bus) - kfree(bus); + kfree(bus); return ERR_PTR(ret); } diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c index 081a8999666..a8a8f975432 100644 --- a/drivers/net/wireless/ipw2200.c +++ b/drivers/net/wireless/ipw2200.c @@ -1229,12 +1229,6 @@ static struct ipw_fw_error *ipw_alloc_error_log(struct ipw_priv *priv) return error; } -static void ipw_free_error_log(struct ipw_fw_error *error) -{ - if (error) - kfree(error); -} - static ssize_t show_event_log(struct device *d, struct device_attribute *attr, char *buf) { @@ -1296,10 +1290,9 @@ static ssize_t clear_error(struct device *d, const char *buf, size_t count) { struct ipw_priv *priv = dev_get_drvdata(d); - if (priv->error) { - ipw_free_error_log(priv->error); - priv->error = NULL; - } + + kfree(priv->error); + priv->error = NULL; return count; } @@ -1970,8 +1963,7 @@ static void ipw_irq_tasklet(struct ipw_priv *priv) struct ipw_fw_error *error = ipw_alloc_error_log(priv); ipw_dump_error_log(priv, error); - if (error) - ipw_free_error_log(error); + kfree(error); } #endif } else { @@ -11693,10 +11685,8 @@ static void ipw_pci_remove(struct pci_dev *pdev) } } - if (priv->error) { - ipw_free_error_log(priv->error); - priv->error = NULL; - } + kfree(priv->error); + priv->error = NULL; #ifdef CONFIG_IPW2200_PROMISCUOUS ipw_prom_free(priv); diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c index 93d18a74c40..2915bca691e 100644 --- a/drivers/scsi/libata-scsi.c +++ b/drivers/scsi/libata-scsi.c @@ -222,9 +222,7 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg) && copy_to_user(arg + sizeof(args), argbuf, argsize)) rc = -EFAULT; error: - if (argbuf) - kfree(argbuf); - + kfree(argbuf); return rc; } diff --git a/drivers/video/au1100fb.c b/drivers/video/au1100fb.c index d63c3f48585..9ef68cd83bb 100644 --- a/drivers/video/au1100fb.c +++ b/drivers/video/au1100fb.c @@ -743,8 +743,7 @@ void __exit au1100fb_cleanup(void) { driver_unregister(&au1100fb_driver); - if (drv_info.opt_mode) - kfree(drv_info.opt_mode); + kfree(drv_info.opt_mode); } module_init(au1100fb_init); -- cgit v1.2.3-70-g09d2 From 456229a91d2bdf884f0c01b33f1ecee762abba7d Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Tue, 27 Jun 2006 02:55:07 -0700 Subject: [PATCH] drivers/char/ipmi/ipmi_msghandler.c: make proc_ipmi_root static Make struct proc_ipmi_root static. Besides this, tremove removes an unused #ifdef CONFIG_PROC_FS from include/linux/ipmi.h. Acked-by: Corey Minyard Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/ipmi/ipmi_msghandler.c | 3 +-- include/linux/ipmi.h | 4 ---- 2 files changed, 1 insertion(+), 6 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c index b03ddab1bef..83ed6ae466a 100644 --- a/drivers/char/ipmi/ipmi_msghandler.c +++ b/drivers/char/ipmi/ipmi_msghandler.c @@ -57,8 +57,7 @@ static int ipmi_init_msghandler(void); static int initialized = 0; #ifdef CONFIG_PROC_FS -struct proc_dir_entry *proc_ipmi_root = NULL; -EXPORT_SYMBOL(proc_ipmi_root); +static struct proc_dir_entry *proc_ipmi_root = NULL; #endif /* CONFIG_PROC_FS */ #define MAX_EVENTS_IN_QUEUE 25 diff --git a/include/linux/ipmi.h b/include/linux/ipmi.h index 5653b2f23b6..d09fbeabf1d 100644 --- a/include/linux/ipmi.h +++ b/include/linux/ipmi.h @@ -210,11 +210,7 @@ struct kernel_ipmi_msg #include #include #include - -#ifdef CONFIG_PROC_FS #include -extern struct proc_dir_entry *proc_ipmi_root; -#endif /* CONFIG_PROC_FS */ /* Opaque type for a IPMI message user. One of these is needed to send and receive messages. */ -- cgit v1.2.3-70-g09d2 From 817d6d3bceaf34c99f5343820f9b9e6021f0655c Mon Sep 17 00:00:00 2001 From: Paul Fulghum Date: Wed, 28 Jun 2006 04:26:47 -0700 Subject: [PATCH] remove TTY_DONT_FLIP Remove TTY_DONT_FLIP tty flag. This flag was introduced in 2.1.X kernels to prevent the N_TTY line discipline functions read_chan() and n_tty_receive_buf() from running at the same time. 2.2.15 introduced tty->read_lock to protect access to the N_TTY read buffer, which is the only state requiring protection between these two functions. The current TTY_DONT_FLIP implementation is broken for SMP, and is not universally honored by drivers that send data directly to the line discipline receive_buf function. Because TTY_DONT_FLIP is not necessary, is broken in implementation, and is not universally honored, it is removed. Signed-off-by: Paul Fulghum Cc: Alan Cox Cc: Theodore Ts'o Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/mxser.c | 1 - drivers/char/n_tty.c | 6 +----- drivers/char/pty.c | 2 +- drivers/char/tty_io.c | 15 ++------------- drivers/serial/crisv10.c | 6 ------ drivers/serial/jsm/jsm_tty.c | 7 ------- drivers/usb/serial/ir-usb.c | 3 +-- include/linux/tty.h | 1 - net/bluetooth/rfcomm/tty.c | 8 ++------ 9 files changed, 7 insertions(+), 42 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c index 645d9d713ae..72cfd09091e 100644 --- a/drivers/char/mxser.c +++ b/drivers/char/mxser.c @@ -996,7 +996,6 @@ static int mxser_open(struct tty_struct *tty, struct file *filp) info->session = current->signal->session; info->pgrp = process_group(current); - clear_bit(TTY_DONT_FLIP, &tty->flags); /* status = mxser_get_msr(info->base, 0, info->port); diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c index b9371d5bf79..603b9ade5eb 100644 --- a/drivers/char/n_tty.c +++ b/drivers/char/n_tty.c @@ -1132,7 +1132,7 @@ static inline int input_available_p(struct tty_struct *tty, int amt) * buffer, and once to drain the space from the (physical) beginning of * the buffer to head pointer. * - * Called under the tty->atomic_read_lock sem and with TTY_DONT_FLIP set + * Called under the tty->atomic_read_lock sem * */ @@ -1271,7 +1271,6 @@ do_it_again: } add_wait_queue(&tty->read_wait, &wait); - set_bit(TTY_DONT_FLIP, &tty->flags); while (nr) { /* First test for status change. */ if (tty->packet && tty->link->ctrl_status) { @@ -1315,9 +1314,7 @@ do_it_again: break; } n_tty_set_room(tty); - clear_bit(TTY_DONT_FLIP, &tty->flags); timeout = schedule_timeout(timeout); - set_bit(TTY_DONT_FLIP, &tty->flags); continue; } __set_current_state(TASK_RUNNING); @@ -1394,7 +1391,6 @@ do_it_again: if (time) timeout = time; } - clear_bit(TTY_DONT_FLIP, &tty->flags); mutex_unlock(&tty->atomic_read_lock); remove_wait_queue(&tty->read_wait, &wait); diff --git a/drivers/char/pty.c b/drivers/char/pty.c index 9b5a2c0e700..0c17f61549b 100644 --- a/drivers/char/pty.c +++ b/drivers/char/pty.c @@ -101,7 +101,7 @@ static void pty_unthrottle(struct tty_struct * tty) * * FIXME: Our pty_write method is called with our ldisc lock held but * not our partners. We can't just take the other one blindly without - * risking deadlocks. There is also the small matter of TTY_DONT_FLIP + * risking deadlocks. */ static int pty_write(struct tty_struct * tty, const unsigned char *buf, int count) { diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index bd74e82d8a7..b846d87f2b5 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c @@ -784,11 +784,8 @@ restart: } clear_bit(TTY_LDISC, &tty->flags); - clear_bit(TTY_DONT_FLIP, &tty->flags); - if (o_tty) { + if (o_tty) clear_bit(TTY_LDISC, &o_tty->flags); - clear_bit(TTY_DONT_FLIP, &o_tty->flags); - } spin_unlock_irqrestore(&tty_ldisc_lock, flags); /* @@ -1955,7 +1952,6 @@ static void release_dev(struct file * filp) * race with the set_ldisc code path. */ clear_bit(TTY_LDISC, &tty->flags); - clear_bit(TTY_DONT_FLIP, &tty->flags); cancel_delayed_work(&tty->buf.work); /* @@ -2784,13 +2780,6 @@ static void flush_to_ldisc(void *private_) if (disc == NULL) /* !TTY_LDISC */ return; - if (test_bit(TTY_DONT_FLIP, &tty->flags)) { - /* - * Do it after the next timer tick: - */ - schedule_delayed_work(&tty->buf.work, 1); - goto out; - } spin_lock_irqsave(&tty->buf.lock, flags); while((tbuf = tty->buf.head) != NULL) { while ((count = tbuf->commit - tbuf->read) != 0) { @@ -2809,7 +2798,7 @@ static void flush_to_ldisc(void *private_) tty_buffer_free(tty, tbuf); } spin_unlock_irqrestore(&tty->buf.lock, flags); -out: + tty_ldisc_deref(disc); } diff --git a/drivers/serial/crisv10.c b/drivers/serial/crisv10.c index 89700141f87..5cacc5e74a9 100644 --- a/drivers/serial/crisv10.c +++ b/drivers/serial/crisv10.c @@ -2573,12 +2573,6 @@ static void flush_to_flip_buffer(struct e100_serial *info) DFLIP( if (1) { - - if (test_bit(TTY_DONT_FLIP, &tty->flags)) { - DEBUG_LOG(info->line, "*** TTY_DONT_FLIP set flip.count %i ***\n", tty->flip.count); - DEBUG_LOG(info->line, "*** recv_cnt %i\n", info->recv_cnt); - } else { - } DEBUG_LOG(info->line, "*** rxtot %i\n", info->icount.rx); DEBUG_LOG(info->line, "ldisc %lu\n", tty->ldisc.chars_in_buffer(tty)); DEBUG_LOG(info->line, "room %lu\n", tty->ldisc.receive_room(tty)); diff --git a/drivers/serial/jsm/jsm_tty.c b/drivers/serial/jsm/jsm_tty.c index 7d823705193..f8262e6ad8d 100644 --- a/drivers/serial/jsm/jsm_tty.c +++ b/drivers/serial/jsm/jsm_tty.c @@ -588,13 +588,6 @@ void jsm_input(struct jsm_channel *ch) len = min(len, (N_TTY_BUF_SIZE - 1) - tp->read_cnt); ld = tty_ldisc_ref(tp); - /* - * If the DONT_FLIP flag is on, don't flush our buffer, and act - * like the ld doesn't have any space to put the data right now. - */ - if (test_bit(TTY_DONT_FLIP, &tp->flags)) - len = 0; - /* * If we were unable to get a reference to the ld, * don't flush our buffer, and act like the ld doesn't diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c index 9432c730227..d7f3f736a69 100644 --- a/drivers/usb/serial/ir-usb.c +++ b/drivers/usb/serial/ir-usb.c @@ -453,8 +453,7 @@ static void ir_read_bulk_callback (struct urb *urb, struct pt_regs *regs) tty = port->tty; /* - * FIXME: must not do this in IRQ context, - * must honour TTY_DONT_FLIP + * FIXME: must not do this in IRQ context */ tty->ldisc.receive_buf( tty, diff --git a/include/linux/tty.h b/include/linux/tty.h index cb35ca50a0a..341cc4552c0 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h @@ -259,7 +259,6 @@ struct tty_struct { #define TTY_DO_WRITE_WAKEUP 5 /* Call write_wakeup after queuing new */ #define TTY_PUSH 6 /* n_tty private */ #define TTY_CLOSING 7 /* ->close() in progress */ -#define TTY_DONT_FLIP 8 /* Defer buffer flip */ #define TTY_LDISC 9 /* Line discipline attached */ #define TTY_HW_COOK_OUT 14 /* Hardware can do output cooking */ #define TTY_HW_COOK_IN 15 /* Hardware can do input cooking */ diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c index 74368f79ee5..b81fad89332 100644 --- a/net/bluetooth/rfcomm/tty.c +++ b/net/bluetooth/rfcomm/tty.c @@ -480,12 +480,8 @@ static void rfcomm_dev_data_ready(struct rfcomm_dlc *dlc, struct sk_buff *skb) BT_DBG("dlc %p tty %p len %d", dlc, tty, skb->len); - if (test_bit(TTY_DONT_FLIP, &tty->flags)) { - tty_buffer_request_room(tty, skb->len); - tty_insert_flip_string(tty, skb->data, skb->len); - tty_flip_buffer_push(tty); - } else - tty->ldisc.receive_buf(tty, skb->data, NULL, skb->len); + tty_insert_flip_string(tty, skb->data, skb->len); + tty_flip_buffer_push(tty); kfree_skb(skb); } -- cgit v1.2.3-70-g09d2 From 2c3bb20f46709a0adfa7ea408013edbcab945d5a Mon Sep 17 00:00:00 2001 From: Paul Fulghum Date: Wed, 28 Jun 2006 04:26:48 -0700 Subject: [PATCH] add receive_room flow control to flush_to_ldisc Flush data serially to line discipline in blocks no larger than tty->receive_room to avoid losing data if line discipline is busy (such as N_TTY operating at high speed on heavily loaded system) or does not accept data in large blocks (such as N_MOUSE). Signed-off-by: Paul Fulghum Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/tty_io.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index b846d87f2b5..1f03ebf165d 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c @@ -2771,8 +2771,7 @@ static void flush_to_ldisc(void *private_) struct tty_struct *tty = (struct tty_struct *) private_; unsigned long flags; struct tty_ldisc *disc; - struct tty_buffer *tbuf; - int count; + struct tty_buffer *tbuf, *head; char *char_buf; unsigned char *flag_buf; @@ -2781,21 +2780,33 @@ static void flush_to_ldisc(void *private_) return; spin_lock_irqsave(&tty->buf.lock, flags); - while((tbuf = tty->buf.head) != NULL) { - while ((count = tbuf->commit - tbuf->read) != 0) { - char_buf = tbuf->char_buf_ptr + tbuf->read; - flag_buf = tbuf->flag_buf_ptr + tbuf->read; - tbuf->read += count; + head = tty->buf.head; + if (head != NULL) { + tty->buf.head = NULL; + for (;;) { + int count = head->commit - head->read; + if (!count) { + if (head->next == NULL) + break; + tbuf = head; + head = head->next; + tty_buffer_free(tty, tbuf); + continue; + } + if (!tty->receive_room) { + schedule_delayed_work(&tty->buf.work, 1); + break; + } + if (count > tty->receive_room) + count = tty->receive_room; + char_buf = head->char_buf_ptr + head->read; + flag_buf = head->flag_buf_ptr + head->read; + head->read += count; spin_unlock_irqrestore(&tty->buf.lock, flags); disc->receive_buf(tty, char_buf, flag_buf, count); spin_lock_irqsave(&tty->buf.lock, flags); } - if (tbuf->active) - break; - tty->buf.head = tbuf->next; - if (tty->buf.head == NULL) - tty->buf.tail = NULL; - tty_buffer_free(tty, tbuf); + tty->buf.head = head; } spin_unlock_irqrestore(&tty->buf.lock, flags); -- cgit v1.2.3-70-g09d2 From 33b37a33c242542fac2980b8ccd90977388b7a8d Mon Sep 17 00:00:00 2001 From: Paul Fulghum Date: Wed, 28 Jun 2006 04:26:49 -0700 Subject: [PATCH] remove active field from tty buffer structure Remove 'active' field from tty buffer structure. This was added in 2.6.16 as part of a patch to make the new tty buffering SMP safe. This field is unnecessary with the more intelligently written flush_to_ldisc that adds receive_room handling. Removing this field reverts to simpler logic where the tail buffer is always the 'active' buffer, which should not be freed by flush_to_ldisc. (active == buffer being filled with new data) The result is simpler, smaller, and faster tty buffer code. Signed-off-by: Paul Fulghum Cc: Alan Cox Cc: Theodore Ts'o Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/tty_io.c | 16 ++++------------ include/linux/kbd_kern.h | 4 +--- include/linux/tty.h | 1 - include/linux/tty_flip.h | 2 +- 4 files changed, 6 insertions(+), 17 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 1f03ebf165d..8d19f7281f0 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c @@ -267,7 +267,6 @@ static struct tty_buffer *tty_buffer_alloc(size_t size) p->used = 0; p->size = size; p->next = NULL; - p->active = 0; p->commit = 0; p->read = 0; p->char_buf_ptr = (char *)(p->data); @@ -327,10 +326,9 @@ int tty_buffer_request_room(struct tty_struct *tty, size_t size) /* OPTIMISATION: We could keep a per tty "zero" sized buffer to remove this conditional if its worth it. This would be invisible to the callers */ - if ((b = tty->buf.tail) != NULL) { + if ((b = tty->buf.tail) != NULL) left = b->size - b->used; - b->active = 1; - } else + else left = 0; if (left < size) { @@ -338,12 +336,10 @@ int tty_buffer_request_room(struct tty_struct *tty, size_t size) if ((n = tty_buffer_find(tty, size)) != NULL) { if (b != NULL) { b->next = n; - b->active = 0; b->commit = b->used; } else tty->buf.head = n; tty->buf.tail = n; - n->active = 1; } else size = left; } @@ -404,10 +400,8 @@ void tty_schedule_flip(struct tty_struct *tty) { unsigned long flags; spin_lock_irqsave(&tty->buf.lock, flags); - if (tty->buf.tail != NULL) { - tty->buf.tail->active = 0; + if (tty->buf.tail != NULL) tty->buf.tail->commit = tty->buf.tail->used; - } spin_unlock_irqrestore(&tty->buf.lock, flags); schedule_delayed_work(&tty->buf.work, 1); } @@ -2902,10 +2896,8 @@ void tty_flip_buffer_push(struct tty_struct *tty) { unsigned long flags; spin_lock_irqsave(&tty->buf.lock, flags); - if (tty->buf.tail != NULL) { - tty->buf.tail->active = 0; + if (tty->buf.tail != NULL) tty->buf.tail->commit = tty->buf.tail->used; - } spin_unlock_irqrestore(&tty->buf.lock, flags); if (tty->low_latency) diff --git a/include/linux/kbd_kern.h b/include/linux/kbd_kern.h index 4eb851ece08..efe0ee4cc80 100644 --- a/include/linux/kbd_kern.h +++ b/include/linux/kbd_kern.h @@ -155,10 +155,8 @@ static inline void con_schedule_flip(struct tty_struct *t) { unsigned long flags; spin_lock_irqsave(&t->buf.lock, flags); - if (t->buf.tail != NULL) { - t->buf.tail->active = 0; + if (t->buf.tail != NULL) t->buf.tail->commit = t->buf.tail->used; - } spin_unlock_irqrestore(&t->buf.lock, flags); schedule_work(&t->buf.work); } diff --git a/include/linux/tty.h b/include/linux/tty.h index 341cc4552c0..b3b807e4b05 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h @@ -57,7 +57,6 @@ struct tty_buffer { unsigned char *flag_buf_ptr; int used; int size; - int active; int commit; int read; /* Data points here */ diff --git a/include/linux/tty_flip.h b/include/linux/tty_flip.h index 31548303ee3..eb677cf5610 100644 --- a/include/linux/tty_flip.h +++ b/include/linux/tty_flip.h @@ -12,7 +12,7 @@ static inline int tty_insert_flip_char(struct tty_struct *tty, unsigned char ch, char flag) { struct tty_buffer *tb = tty->buf.tail; - if (tb && tb->active && tb->used < tb->size) { + if (tb && tb->used < tb->size) { tb->flag_buf_ptr[tb->used] = flag; tb->char_buf_ptr[tb->used++] = ch; return 1; -- cgit v1.2.3-70-g09d2 From effc8b704b48c3c727715abf49592a57547b6818 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Wed, 28 Jun 2006 04:26:51 -0700 Subject: [PATCH] stallion: fix recent SMP locking cleanup Works better on SMP if... Signed-off-by: Alan Cox Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/stallion.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/char') diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c index bf361a5ba70..00b4a218716 100644 --- a/drivers/char/stallion.c +++ b/drivers/char/stallion.c @@ -3029,6 +3029,9 @@ static int __init stl_init(void) int i; printk(KERN_INFO "%s: version %s\n", stl_drvtitle, stl_drvversion); + spin_lock_init(&stallion_lock); + spin_lock_init(&brd_lock); + stl_initbrds(); stl_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS); -- cgit v1.2.3-70-g09d2 From 4ac4360b95496f4137ee19b54e9f7dfa3946984d Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Wed, 28 Jun 2006 04:26:52 -0700 Subject: [PATCH] istallion: cleanups Turned out to be rather a monster Signed-off-by: Alan Cox Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/istallion.c | 1819 +++++++++++++++++----------------------------- 1 file changed, 667 insertions(+), 1152 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c index ef20c1fc9c4..216c79256de 100644 --- a/drivers/char/istallion.c +++ b/drivers/char/istallion.c @@ -42,13 +42,12 @@ #include #include #include +#include #include #include -#ifdef CONFIG_PCI #include -#endif /*****************************************************************************/ @@ -137,6 +136,10 @@ static stlconf_t stli_brdconf[] = { static int stli_nrbrds = ARRAY_SIZE(stli_brdconf); +/* stli_lock must NOT be taken holding brd_lock */ +static spinlock_t stli_lock; /* TTY logic lock */ +static spinlock_t brd_lock; /* Board logic lock */ + /* * There is some experimental EISA board detection code in this driver. * By default it is disabled, but for those that want to try it out, @@ -173,14 +176,6 @@ static char *stli_serialname = "ttyE"; static struct tty_driver *stli_serial; -/* - * We will need to allocate a temporary write buffer for chars that - * come direct from user space. The problem is that a copy from user - * space might cause a page fault (typically on a system that is - * swapping!). All ports will share one buffer - since if the system - * is already swapping a shared buffer won't make things any worse. - */ -static char *stli_tmpwritebuf; #define STLI_TXBUFSIZE 4096 @@ -419,7 +414,7 @@ static int stli_eisamempsize = ARRAY_SIZE(stli_eisamemprobeaddrs); #endif static struct pci_device_id istallion_pci_tbl[] = { - { PCI_VENDOR_ID_STALLION, PCI_DEVICE_ID_ECRA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, + { PCI_DEVICE(PCI_VENDOR_ID_STALLION, PCI_DEVICE_ID_ECRA), }, { 0 } }; MODULE_DEVICE_TABLE(pci, istallion_pci_tbl); @@ -682,7 +677,7 @@ static int stli_startbrd(stlibrd_t *brdp); static ssize_t stli_memread(struct file *fp, char __user *buf, size_t count, loff_t *offp); static ssize_t stli_memwrite(struct file *fp, const char __user *buf, size_t count, loff_t *offp); static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, unsigned long arg); -static void stli_brdpoll(stlibrd_t *brdp, volatile cdkhdr_t *hdrp); +static void stli_brdpoll(stlibrd_t *brdp, cdkhdr_t __iomem *hdrp); static void stli_poll(unsigned long arg); static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp); static int stli_initopen(stlibrd_t *brdp, stliport_t *portp); @@ -693,7 +688,8 @@ static void stli_dohangup(void *arg); static int stli_setport(stliport_t *portp); static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback); static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback); -static void stli_dodelaycmd(stliport_t *portp, volatile cdkctrl_t *cp); +static void __stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback); +static void stli_dodelaycmd(stliport_t *portp, cdkctrl_t __iomem *cp); static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tiosp); static void stli_mkasysigs(asysigs_t *sp, int dtr, int rts); static long stli_mktiocm(unsigned long sigvalue); @@ -799,18 +795,8 @@ static struct class *istallion_class; static int __init istallion_module_init(void) { - unsigned long flags; - -#ifdef DEBUG - printk("init_module()\n"); -#endif - - save_flags(flags); - cli(); stli_init(); - restore_flags(flags); - - return(0); + return 0; } /*****************************************************************************/ @@ -819,33 +805,24 @@ static void __exit istallion_module_exit(void) { stlibrd_t *brdp; stliport_t *portp; - unsigned long flags; int i, j; -#ifdef DEBUG - printk("cleanup_module()\n"); -#endif - printk(KERN_INFO "Unloading %s: version %s\n", stli_drvtitle, stli_drvversion); - save_flags(flags); - cli(); - -/* - * Free up all allocated resources used by the ports. This includes - * memory and interrupts. - */ + /* + * Free up all allocated resources used by the ports. This includes + * memory and interrupts. + */ if (stli_timeron) { stli_timeron = 0; - del_timer(&stli_timerlist); + del_timer_sync(&stli_timerlist); } i = tty_unregister_driver(stli_serial); if (i) { printk("STALLION: failed to un-register tty driver, " "errno=%d\n", -i); - restore_flags(flags); return; } put_tty_driver(stli_serial); @@ -859,16 +836,15 @@ static void __exit istallion_module_exit(void) printk("STALLION: failed to un-register serial memory device, " "errno=%d\n", -i); - kfree(stli_tmpwritebuf); kfree(stli_txcookbuf); for (i = 0; (i < stli_nrbrds); i++) { - if ((brdp = stli_brds[i]) == (stlibrd_t *) NULL) + if ((brdp = stli_brds[i]) == NULL) continue; for (j = 0; (j < STL_MAXPORTS); j++) { portp = brdp->ports[j]; - if (portp != (stliport_t *) NULL) { - if (portp->tty != (struct tty_struct *) NULL) + if (portp != NULL) { + if (portp->tty != NULL) tty_hangup(portp->tty); kfree(portp); } @@ -878,10 +854,8 @@ static void __exit istallion_module_exit(void) if (brdp->iosize > 0) release_region(brdp->iobase, brdp->iosize); kfree(brdp); - stli_brds[i] = (stlibrd_t *) NULL; + stli_brds[i] = NULL; } - - restore_flags(flags); } module_init(istallion_module_init); @@ -895,19 +869,15 @@ module_exit(istallion_module_exit); static void stli_argbrds(void) { - stlconf_t conf; - stlibrd_t *brdp; - int i; - -#ifdef DEBUG - printk("stli_argbrds()\n"); -#endif + stlconf_t conf; + stlibrd_t *brdp; + int i; for (i = stli_nrbrds; i < ARRAY_SIZE(stli_brdsp); i++) { memset(&conf, 0, sizeof(conf)); if (stli_parsebrd(&conf, stli_brdsp[i]) == 0) continue; - if ((brdp = stli_allocbrd()) == (stlibrd_t *) NULL) + if ((brdp = stli_allocbrd()) == NULL) continue; stli_nrbrds = i + 1; brdp->brdnr = i; @@ -926,9 +896,9 @@ static void stli_argbrds(void) static unsigned long stli_atol(char *str) { - unsigned long val; - int base, c; - char *sp; + unsigned long val; + int base, c; + char *sp; val = 0; sp = str; @@ -962,15 +932,11 @@ static unsigned long stli_atol(char *str) static int stli_parsebrd(stlconf_t *confp, char **argp) { - char *sp; - int i; - -#ifdef DEBUG - printk("stli_parsebrd(confp=%x,argp=%x)\n", (int) confp, (int) argp); -#endif + char *sp; + int i; - if ((argp[0] == (char *) NULL) || (*argp[0] == 0)) - return(0); + if (argp[0] == NULL || *argp[0] == 0) + return 0; for (sp = argp[0], i = 0; ((*sp != 0) && (i < 25)); sp++, i++) *sp = TOLOWER(*sp); @@ -985,9 +951,9 @@ static int stli_parsebrd(stlconf_t *confp, char **argp) } confp->brdtype = stli_brdstr[i].type; - if ((argp[1] != (char *) NULL) && (*argp[1] != 0)) + if (argp[1] != NULL && *argp[1] != 0) confp->ioaddr1 = stli_atol(argp[1]); - if ((argp[2] != (char *) NULL) && (*argp[2] != 0)) + if (argp[2] != NULL && *argp[2] != 0) confp->memaddr = stli_atol(argp[2]); return(1); } @@ -998,34 +964,29 @@ static int stli_parsebrd(stlconf_t *confp, char **argp) static int stli_open(struct tty_struct *tty, struct file *filp) { - stlibrd_t *brdp; - stliport_t *portp; - unsigned int minordev; - int brdnr, portnr, rc; - -#ifdef DEBUG - printk("stli_open(tty=%x,filp=%x): device=%s\n", (int) tty, - (int) filp, tty->name); -#endif + stlibrd_t *brdp; + stliport_t *portp; + unsigned int minordev; + int brdnr, portnr, rc; minordev = tty->index; brdnr = MINOR2BRD(minordev); if (brdnr >= stli_nrbrds) - return(-ENODEV); + return -ENODEV; brdp = stli_brds[brdnr]; - if (brdp == (stlibrd_t *) NULL) - return(-ENODEV); + if (brdp == NULL) + return -ENODEV; if ((brdp->state & BST_STARTED) == 0) - return(-ENODEV); + return -ENODEV; portnr = MINOR2PORT(minordev); if ((portnr < 0) || (portnr > brdp->nrports)) - return(-ENODEV); + return -ENODEV; portp = brdp->ports[portnr]; - if (portp == (stliport_t *) NULL) - return(-ENODEV); + if (portp == NULL) + return -ENODEV; if (portp->devnr < 1) - return(-ENODEV); + return -ENODEV; /* @@ -1037,8 +998,8 @@ static int stli_open(struct tty_struct *tty, struct file *filp) if (portp->flags & ASYNC_CLOSING) { interruptible_sleep_on(&portp->close_wait); if (portp->flags & ASYNC_HUP_NOTIFY) - return(-EAGAIN); - return(-ERESTARTSYS); + return -EAGAIN; + return -ERESTARTSYS; } /* @@ -1054,7 +1015,7 @@ static int stli_open(struct tty_struct *tty, struct file *filp) wait_event_interruptible(portp->raw_wait, !test_bit(ST_INITIALIZING, &portp->state)); if (signal_pending(current)) - return(-ERESTARTSYS); + return -ERESTARTSYS; if ((portp->flags & ASYNC_INITIALIZED) == 0) { set_bit(ST_INITIALIZING, &portp->state); @@ -1065,7 +1026,7 @@ static int stli_open(struct tty_struct *tty, struct file *filp) clear_bit(ST_INITIALIZING, &portp->state); wake_up_interruptible(&portp->raw_wait); if (rc < 0) - return(rc); + return rc; } /* @@ -1077,8 +1038,8 @@ static int stli_open(struct tty_struct *tty, struct file *filp) if (portp->flags & ASYNC_CLOSING) { interruptible_sleep_on(&portp->close_wait); if (portp->flags & ASYNC_HUP_NOTIFY) - return(-EAGAIN); - return(-ERESTARTSYS); + return -EAGAIN; + return -ERESTARTSYS; } /* @@ -1088,38 +1049,33 @@ static int stli_open(struct tty_struct *tty, struct file *filp) */ if (!(filp->f_flags & O_NONBLOCK)) { if ((rc = stli_waitcarrier(brdp, portp, filp)) != 0) - return(rc); + return rc; } portp->flags |= ASYNC_NORMAL_ACTIVE; - return(0); + return 0; } /*****************************************************************************/ static void stli_close(struct tty_struct *tty, struct file *filp) { - stlibrd_t *brdp; - stliport_t *portp; - unsigned long flags; - -#ifdef DEBUG - printk("stli_close(tty=%x,filp=%x)\n", (int) tty, (int) filp); -#endif + stlibrd_t *brdp; + stliport_t *portp; + unsigned long flags; portp = tty->driver_data; - if (portp == (stliport_t *) NULL) + if (portp == NULL) return; - save_flags(flags); - cli(); + spin_lock_irqsave(&stli_lock, flags); if (tty_hung_up_p(filp)) { - restore_flags(flags); + spin_unlock_irqrestore(&stli_lock, flags); return; } if ((tty->count == 1) && (portp->refcount != 1)) portp->refcount = 1; if (portp->refcount-- > 1) { - restore_flags(flags); + spin_unlock_irqrestore(&stli_lock, flags); return; } @@ -1134,6 +1090,8 @@ static void stli_close(struct tty_struct *tty, struct file *filp) if (tty == stli_txcooktty) stli_flushchars(tty); tty->closing = 1; + spin_unlock_irqrestore(&stli_lock, flags); + if (portp->closing_wait != ASYNC_CLOSING_WAIT_NONE) tty_wait_until_sent(tty, portp->closing_wait); @@ -1157,7 +1115,7 @@ static void stli_close(struct tty_struct *tty, struct file *filp) stli_flushbuffer(tty); tty->closing = 0; - portp->tty = (struct tty_struct *) NULL; + portp->tty = NULL; if (portp->openwaitcnt) { if (portp->close_delay) @@ -1167,7 +1125,6 @@ static void stli_close(struct tty_struct *tty, struct file *filp) portp->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); wake_up_interruptible(&portp->close_wait); - restore_flags(flags); } /*****************************************************************************/ @@ -1182,45 +1139,41 @@ static void stli_close(struct tty_struct *tty, struct file *filp) static int stli_initopen(stlibrd_t *brdp, stliport_t *portp) { - struct tty_struct *tty; - asynotify_t nt; - asyport_t aport; - int rc; - -#ifdef DEBUG - printk("stli_initopen(brdp=%x,portp=%x)\n", (int) brdp, (int) portp); -#endif + struct tty_struct *tty; + asynotify_t nt; + asyport_t aport; + int rc; if ((rc = stli_rawopen(brdp, portp, 0, 1)) < 0) - return(rc); + return rc; memset(&nt, 0, sizeof(asynotify_t)); nt.data = (DT_TXLOW | DT_TXEMPTY | DT_RXBUSY | DT_RXBREAK); nt.signal = SG_DCD; if ((rc = stli_cmdwait(brdp, portp, A_SETNOTIFY, &nt, sizeof(asynotify_t), 0)) < 0) - return(rc); + return rc; tty = portp->tty; - if (tty == (struct tty_struct *) NULL) - return(-ENODEV); + if (tty == NULL) + return -ENODEV; stli_mkasyport(portp, &aport, tty->termios); if ((rc = stli_cmdwait(brdp, portp, A_SETPORT, &aport, sizeof(asyport_t), 0)) < 0) - return(rc); + return rc; set_bit(ST_GETSIGS, &portp->state); if ((rc = stli_cmdwait(brdp, portp, A_GETSIGNALS, &portp->asig, sizeof(asysigs_t), 1)) < 0) - return(rc); + return rc; if (test_and_clear_bit(ST_GETSIGS, &portp->state)) portp->sigs = stli_mktiocm(portp->asig.sigvalue); stli_mkasysigs(&portp->asig, 1, 1); if ((rc = stli_cmdwait(brdp, portp, A_SETSIGNALS, &portp->asig, sizeof(asysigs_t), 0)) < 0) - return(rc); + return rc; - return(0); + return 0; } /*****************************************************************************/ @@ -1234,22 +1187,15 @@ static int stli_initopen(stlibrd_t *brdp, stliport_t *portp) static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait) { - volatile cdkhdr_t *hdrp; - volatile cdkctrl_t *cp; - volatile unsigned char *bits; - unsigned long flags; - int rc; - -#ifdef DEBUG - printk("stli_rawopen(brdp=%x,portp=%x,arg=%x,wait=%d)\n", - (int) brdp, (int) portp, (int) arg, wait); -#endif + cdkhdr_t __iomem *hdrp; + cdkctrl_t __iomem *cp; + unsigned char __iomem *bits; + unsigned long flags; + int rc; /* * Send a message to the slave to open this port. */ - save_flags(flags); - cli(); /* * Slave is already closing this port. This can happen if a hangup @@ -1260,7 +1206,6 @@ static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, i wait_event_interruptible(portp->raw_wait, !test_bit(ST_CLOSING, &portp->state)); if (signal_pending(current)) { - restore_flags(flags); return -ERESTARTSYS; } @@ -1269,19 +1214,20 @@ static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, i * memory. Once the message is in set the service bits to say that * this port wants service. */ + spin_lock_irqsave(&brd_lock, flags); EBRDENABLE(brdp); - cp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->ctrl; - cp->openarg = arg; - cp->open = 1; - hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); - bits = ((volatile unsigned char *) hdrp) + brdp->slaveoffset + + cp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->ctrl; + writel(arg, &cp->openarg); + writeb(1, &cp->open); + hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); + bits = ((unsigned char __iomem *) hdrp) + brdp->slaveoffset + portp->portidx; - *bits |= portp->portbit; + writeb(readb(bits) | portp->portbit, bits); EBRDDISABLE(brdp); if (wait == 0) { - restore_flags(flags); - return(0); + spin_unlock_irqrestore(&brd_lock, flags); + return 0; } /* @@ -1290,15 +1236,16 @@ static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, i */ rc = 0; set_bit(ST_OPENING, &portp->state); + spin_unlock_irqrestore(&brd_lock, flags); + wait_event_interruptible(portp->raw_wait, !test_bit(ST_OPENING, &portp->state)); if (signal_pending(current)) rc = -ERESTARTSYS; - restore_flags(flags); if ((rc == 0) && (portp->rc != 0)) rc = -EIO; - return(rc); + return rc; } /*****************************************************************************/ @@ -1311,19 +1258,11 @@ static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, i static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait) { - volatile cdkhdr_t *hdrp; - volatile cdkctrl_t *cp; - volatile unsigned char *bits; - unsigned long flags; - int rc; - -#ifdef DEBUG - printk("stli_rawclose(brdp=%x,portp=%x,arg=%x,wait=%d)\n", - (int) brdp, (int) portp, (int) arg, wait); -#endif - - save_flags(flags); - cli(); + cdkhdr_t __iomem *hdrp; + cdkctrl_t __iomem *cp; + unsigned char __iomem *bits; + unsigned long flags; + int rc; /* * Slave is already closing this port. This can happen if a hangup @@ -1333,7 +1272,6 @@ static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, wait_event_interruptible(portp->raw_wait, !test_bit(ST_CLOSING, &portp->state)); if (signal_pending(current)) { - restore_flags(flags); return -ERESTARTSYS; } } @@ -1341,21 +1279,22 @@ static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, /* * Write the close command into shared memory. */ + spin_lock_irqsave(&brd_lock, flags); EBRDENABLE(brdp); - cp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->ctrl; - cp->closearg = arg; - cp->close = 1; - hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); - bits = ((volatile unsigned char *) hdrp) + brdp->slaveoffset + + cp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->ctrl; + writel(arg, &cp->closearg); + writeb(1, &cp->close); + hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); + bits = ((unsigned char __iomem *) hdrp) + brdp->slaveoffset + portp->portidx; - *bits |= portp->portbit; + writeb(readb(bits) |portp->portbit, bits); EBRDDISABLE(brdp); set_bit(ST_CLOSING, &portp->state); - if (wait == 0) { - restore_flags(flags); - return(0); - } + spin_unlock_irqrestore(&brd_lock, flags); + + if (wait == 0) + return 0; /* * Slave is in action, so now we must wait for the open acknowledgment @@ -1366,11 +1305,10 @@ static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, !test_bit(ST_CLOSING, &portp->state)); if (signal_pending(current)) rc = -ERESTARTSYS; - restore_flags(flags); if ((rc == 0) && (portp->rc != 0)) rc = -EIO; - return(rc); + return rc; } /*****************************************************************************/ @@ -1384,36 +1322,21 @@ static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback) { - unsigned long flags; - -#ifdef DEBUG - printk("stli_cmdwait(brdp=%x,portp=%x,cmd=%x,arg=%x,size=%d," - "copyback=%d)\n", (int) brdp, (int) portp, (int) cmd, - (int) arg, size, copyback); -#endif - - save_flags(flags); - cli(); wait_event_interruptible(portp->raw_wait, !test_bit(ST_CMDING, &portp->state)); - if (signal_pending(current)) { - restore_flags(flags); + if (signal_pending(current)) return -ERESTARTSYS; - } stli_sendcmd(brdp, portp, cmd, arg, size, copyback); wait_event_interruptible(portp->raw_wait, !test_bit(ST_CMDING, &portp->state)); - if (signal_pending(current)) { - restore_flags(flags); + if (signal_pending(current)) return -ERESTARTSYS; - } - restore_flags(flags); if (portp->rc != 0) - return(-EIO); - return(0); + return -EIO; + return 0; } /*****************************************************************************/ @@ -1425,22 +1348,18 @@ static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, v static int stli_setport(stliport_t *portp) { - stlibrd_t *brdp; - asyport_t aport; - -#ifdef DEBUG - printk("stli_setport(portp=%x)\n", (int) portp); -#endif + stlibrd_t *brdp; + asyport_t aport; - if (portp == (stliport_t *) NULL) - return(-ENODEV); - if (portp->tty == (struct tty_struct *) NULL) - return(-ENODEV); - if ((portp->brdnr < 0) && (portp->brdnr >= stli_nrbrds)) - return(-ENODEV); + if (portp == NULL) + return -ENODEV; + if (portp->tty == NULL) + return -ENODEV; + if (portp->brdnr < 0 && portp->brdnr >= stli_nrbrds) + return -ENODEV; brdp = stli_brds[portp->brdnr]; - if (brdp == (stlibrd_t *) NULL) - return(-ENODEV); + if (brdp == NULL) + return -ENODEV; stli_mkasyport(portp, &aport, portp->tty->termios); return(stli_cmdwait(brdp, portp, A_SETPORT, &aport, sizeof(asyport_t), 0)); @@ -1455,13 +1374,8 @@ static int stli_setport(stliport_t *portp) static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *filp) { - unsigned long flags; - int rc, doclocal; - -#ifdef DEBUG - printk("stli_waitcarrier(brdp=%x,portp=%x,filp=%x)\n", - (int) brdp, (int) portp, (int) filp); -#endif + unsigned long flags; + int rc, doclocal; rc = 0; doclocal = 0; @@ -1469,11 +1383,11 @@ static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *fil if (portp->tty->termios->c_cflag & CLOCAL) doclocal++; - save_flags(flags); - cli(); + spin_lock_irqsave(&stli_lock, flags); portp->openwaitcnt++; if (! tty_hung_up_p(filp)) portp->refcount--; + spin_unlock_irqrestore(&stli_lock, flags); for (;;) { stli_mkasysigs(&portp->asig, 1, 1); @@ -1499,12 +1413,13 @@ static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *fil interruptible_sleep_on(&portp->open_wait); } + spin_lock_irqsave(&stli_lock, flags); if (! tty_hung_up_p(filp)) portp->refcount++; portp->openwaitcnt--; - restore_flags(flags); + spin_unlock_irqrestore(&stli_lock, flags); - return(rc); + return rc; } /*****************************************************************************/ @@ -1517,46 +1432,38 @@ static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *fil static int stli_write(struct tty_struct *tty, const unsigned char *buf, int count) { - volatile cdkasy_t *ap; - volatile cdkhdr_t *hdrp; - volatile unsigned char *bits; - unsigned char *shbuf, *chbuf; - stliport_t *portp; - stlibrd_t *brdp; - unsigned int len, stlen, head, tail, size; - unsigned long flags; - -#ifdef DEBUG - printk("stli_write(tty=%x,buf=%x,count=%d)\n", - (int) tty, (int) buf, count); -#endif + cdkasy_t __iomem *ap; + cdkhdr_t __iomem *hdrp; + unsigned char __iomem *bits; + unsigned char __iomem *shbuf; + unsigned char *chbuf; + stliport_t *portp; + stlibrd_t *brdp; + unsigned int len, stlen, head, tail, size; + unsigned long flags; - if ((tty == (struct tty_struct *) NULL) || - (stli_tmpwritebuf == (char *) NULL)) - return(0); if (tty == stli_txcooktty) stli_flushchars(tty); portp = tty->driver_data; - if (portp == (stliport_t *) NULL) - return(0); + if (portp == NULL) + return 0; if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) - return(0); + return 0; brdp = stli_brds[portp->brdnr]; - if (brdp == (stlibrd_t *) NULL) - return(0); + if (brdp == NULL) + return 0; chbuf = (unsigned char *) buf; /* * All data is now local, shove as much as possible into shared memory. */ - save_flags(flags); - cli(); + spin_lock_irqsave(&brd_lock, flags); EBRDENABLE(brdp); - ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr); - head = (unsigned int) ap->txq.head; - tail = (unsigned int) ap->txq.tail; - if (tail != ((unsigned int) ap->txq.tail)) - tail = (unsigned int) ap->txq.tail; + ap = (cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr); + head = (unsigned int) readw(&ap->txq.head); + tail = (unsigned int) readw(&ap->txq.tail); + if (tail != ((unsigned int) readw(&ap->txq.tail))) + tail = (unsigned int) readw(&ap->txq.tail); size = portp->txsize; if (head >= tail) { len = size - (head - tail) - 1; @@ -1568,11 +1475,11 @@ static int stli_write(struct tty_struct *tty, const unsigned char *buf, int coun len = MIN(len, count); count = 0; - shbuf = (char *) EBRDGETMEMPTR(brdp, portp->txoffset); + shbuf = (char __iomem *) EBRDGETMEMPTR(brdp, portp->txoffset); while (len > 0) { stlen = MIN(len, stlen); - memcpy((shbuf + head), chbuf, stlen); + memcpy_toio(shbuf + head, chbuf, stlen); chbuf += stlen; len -= stlen; count += stlen; @@ -1583,20 +1490,19 @@ static int stli_write(struct tty_struct *tty, const unsigned char *buf, int coun } } - ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr); - ap->txq.head = head; + ap = (cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr); + writew(head, &ap->txq.head); if (test_bit(ST_TXBUSY, &portp->state)) { - if (ap->changed.data & DT_TXEMPTY) - ap->changed.data &= ~DT_TXEMPTY; + if (readl(&ap->changed.data) & DT_TXEMPTY) + writel(readl(&ap->changed.data) & ~DT_TXEMPTY, &ap->changed.data); } - hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); - bits = ((volatile unsigned char *) hdrp) + brdp->slaveoffset + + hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); + bits = ((unsigned char __iomem *) hdrp) + brdp->slaveoffset + portp->portidx; - *bits |= portp->portbit; + writeb(readb(bits) | portp->portbit, bits); set_bit(ST_TXBUSY, &portp->state); EBRDDISABLE(brdp); - - restore_flags(flags); + spin_unlock_irqrestore(&brd_lock, flags); return(count); } @@ -1613,14 +1519,8 @@ static int stli_write(struct tty_struct *tty, const unsigned char *buf, int coun static void stli_putchar(struct tty_struct *tty, unsigned char ch) { -#ifdef DEBUG - printk("stli_putchar(tty=%x,ch=%x)\n", (int) tty, (int) ch); -#endif - - if (tty == (struct tty_struct *) NULL) - return; if (tty != stli_txcooktty) { - if (stli_txcooktty != (struct tty_struct *) NULL) + if (stli_txcooktty != NULL) stli_flushchars(stli_txcooktty); stli_txcooktty = tty; } @@ -1640,29 +1540,26 @@ static void stli_putchar(struct tty_struct *tty, unsigned char ch) static void stli_flushchars(struct tty_struct *tty) { - volatile cdkhdr_t *hdrp; - volatile unsigned char *bits; - volatile cdkasy_t *ap; - struct tty_struct *cooktty; - stliport_t *portp; - stlibrd_t *brdp; - unsigned int len, stlen, head, tail, size, count, cooksize; - unsigned char *buf, *shbuf; - unsigned long flags; - -#ifdef DEBUG - printk("stli_flushchars(tty=%x)\n", (int) tty); -#endif + cdkhdr_t __iomem *hdrp; + unsigned char __iomem *bits; + cdkasy_t __iomem *ap; + struct tty_struct *cooktty; + stliport_t *portp; + stlibrd_t *brdp; + unsigned int len, stlen, head, tail, size, count, cooksize; + unsigned char *buf; + unsigned char __iomem *shbuf; + unsigned long flags; cooksize = stli_txcooksize; cooktty = stli_txcooktty; stli_txcooksize = 0; stli_txcookrealsize = 0; - stli_txcooktty = (struct tty_struct *) NULL; + stli_txcooktty = NULL; - if (tty == (struct tty_struct *) NULL) + if (tty == NULL) return; - if (cooktty == (struct tty_struct *) NULL) + if (cooktty == NULL) return; if (tty != cooktty) tty = cooktty; @@ -1670,23 +1567,22 @@ static void stli_flushchars(struct tty_struct *tty) return; portp = tty->driver_data; - if (portp == (stliport_t *) NULL) + if (portp == NULL) return; if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) return; brdp = stli_brds[portp->brdnr]; - if (brdp == (stlibrd_t *) NULL) + if (brdp == NULL) return; - save_flags(flags); - cli(); + spin_lock_irqsave(&brd_lock, flags); EBRDENABLE(brdp); - ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr); - head = (unsigned int) ap->txq.head; - tail = (unsigned int) ap->txq.tail; - if (tail != ((unsigned int) ap->txq.tail)) - tail = (unsigned int) ap->txq.tail; + ap = (cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr); + head = (unsigned int) readw(&ap->txq.head); + tail = (unsigned int) readw(&ap->txq.tail); + if (tail != ((unsigned int) readw(&ap->txq.tail))) + tail = (unsigned int) readw(&ap->txq.tail); size = portp->txsize; if (head >= tail) { len = size - (head - tail) - 1; @@ -1703,7 +1599,7 @@ static void stli_flushchars(struct tty_struct *tty) while (len > 0) { stlen = MIN(len, stlen); - memcpy((shbuf + head), buf, stlen); + memcpy_toio(shbuf + head, buf, stlen); buf += stlen; len -= stlen; count += stlen; @@ -1714,73 +1610,66 @@ static void stli_flushchars(struct tty_struct *tty) } } - ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr); - ap->txq.head = head; + ap = (cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr); + writew(head, &ap->txq.head); if (test_bit(ST_TXBUSY, &portp->state)) { - if (ap->changed.data & DT_TXEMPTY) - ap->changed.data &= ~DT_TXEMPTY; + if (readl(&ap->changed.data) & DT_TXEMPTY) + writel(readl(&ap->changed.data) & ~DT_TXEMPTY, &ap->changed.data); } - hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); - bits = ((volatile unsigned char *) hdrp) + brdp->slaveoffset + + hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); + bits = ((unsigned char __iomem *) hdrp) + brdp->slaveoffset + portp->portidx; - *bits |= portp->portbit; + writeb(readb(bits) | portp->portbit, bits); set_bit(ST_TXBUSY, &portp->state); EBRDDISABLE(brdp); - restore_flags(flags); + spin_unlock_irqrestore(&brd_lock, flags); } /*****************************************************************************/ static int stli_writeroom(struct tty_struct *tty) { - volatile cdkasyrq_t *rp; - stliport_t *portp; - stlibrd_t *brdp; - unsigned int head, tail, len; - unsigned long flags; - -#ifdef DEBUG - printk("stli_writeroom(tty=%x)\n", (int) tty); -#endif + cdkasyrq_t __iomem *rp; + stliport_t *portp; + stlibrd_t *brdp; + unsigned int head, tail, len; + unsigned long flags; - if (tty == (struct tty_struct *) NULL) - return(0); if (tty == stli_txcooktty) { if (stli_txcookrealsize != 0) { len = stli_txcookrealsize - stli_txcooksize; - return(len); + return len; } } portp = tty->driver_data; - if (portp == (stliport_t *) NULL) - return(0); + if (portp == NULL) + return 0; if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) - return(0); + return 0; brdp = stli_brds[portp->brdnr]; - if (brdp == (stlibrd_t *) NULL) - return(0); + if (brdp == NULL) + return 0; - save_flags(flags); - cli(); + spin_lock_irqsave(&brd_lock, flags); EBRDENABLE(brdp); - rp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->txq; - head = (unsigned int) rp->head; - tail = (unsigned int) rp->tail; - if (tail != ((unsigned int) rp->tail)) - tail = (unsigned int) rp->tail; + rp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->txq; + head = (unsigned int) readw(&rp->head); + tail = (unsigned int) readw(&rp->tail); + if (tail != ((unsigned int) readw(&rp->tail))) + tail = (unsigned int) readw(&rp->tail); len = (head >= tail) ? (portp->txsize - (head - tail)) : (tail - head); len--; EBRDDISABLE(brdp); - restore_flags(flags); + spin_unlock_irqrestore(&brd_lock, flags); if (tty == stli_txcooktty) { stli_txcookrealsize = len; len -= stli_txcooksize; } - return(len); + return len; } /*****************************************************************************/ @@ -1795,44 +1684,37 @@ static int stli_writeroom(struct tty_struct *tty) static int stli_charsinbuffer(struct tty_struct *tty) { - volatile cdkasyrq_t *rp; - stliport_t *portp; - stlibrd_t *brdp; - unsigned int head, tail, len; - unsigned long flags; - -#ifdef DEBUG - printk("stli_charsinbuffer(tty=%x)\n", (int) tty); -#endif + cdkasyrq_t __iomem *rp; + stliport_t *portp; + stlibrd_t *brdp; + unsigned int head, tail, len; + unsigned long flags; - if (tty == (struct tty_struct *) NULL) - return(0); if (tty == stli_txcooktty) stli_flushchars(tty); portp = tty->driver_data; - if (portp == (stliport_t *) NULL) - return(0); + if (portp == NULL) + return 0; if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) - return(0); + return 0; brdp = stli_brds[portp->brdnr]; - if (brdp == (stlibrd_t *) NULL) - return(0); + if (brdp == NULL) + return 0; - save_flags(flags); - cli(); + spin_lock_irqsave(&brd_lock, flags); EBRDENABLE(brdp); - rp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->txq; - head = (unsigned int) rp->head; - tail = (unsigned int) rp->tail; - if (tail != ((unsigned int) rp->tail)) - tail = (unsigned int) rp->tail; + rp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->txq; + head = (unsigned int) readw(&rp->head); + tail = (unsigned int) readw(&rp->tail); + if (tail != ((unsigned int) readw(&rp->tail))) + tail = (unsigned int) readw(&rp->tail); len = (head >= tail) ? (head - tail) : (portp->txsize - (tail - head)); if ((len == 0) && test_bit(ST_TXBUSY, &portp->state)) len = 1; EBRDDISABLE(brdp); - restore_flags(flags); + spin_unlock_irqrestore(&brd_lock, flags); - return(len); + return len; } /*****************************************************************************/ @@ -1843,12 +1725,8 @@ static int stli_charsinbuffer(struct tty_struct *tty) static int stli_getserial(stliport_t *portp, struct serial_struct __user *sp) { - struct serial_struct sio; - stlibrd_t *brdp; - -#ifdef DEBUG - printk("stli_getserial(portp=%x,sp=%x)\n", (int) portp, (int) sp); -#endif + struct serial_struct sio; + stlibrd_t *brdp; memset(&sio, 0, sizeof(struct serial_struct)); sio.type = PORT_UNKNOWN; @@ -1863,7 +1741,7 @@ static int stli_getserial(stliport_t *portp, struct serial_struct __user *sp) sio.hub6 = 0; brdp = stli_brds[portp->brdnr]; - if (brdp != (stlibrd_t *) NULL) + if (brdp != NULL) sio.port = brdp->iobase; return copy_to_user(sp, &sio, sizeof(struct serial_struct)) ? @@ -1880,12 +1758,8 @@ static int stli_getserial(stliport_t *portp, struct serial_struct __user *sp) static int stli_setserial(stliport_t *portp, struct serial_struct __user *sp) { - struct serial_struct sio; - int rc; - -#ifdef DEBUG - printk("stli_setserial(portp=%p,sp=%p)\n", portp, sp); -#endif + struct serial_struct sio; + int rc; if (copy_from_user(&sio, sp, sizeof(struct serial_struct))) return -EFAULT; @@ -1894,7 +1768,7 @@ static int stli_setserial(stliport_t *portp, struct serial_struct __user *sp) (sio.close_delay != portp->close_delay) || ((sio.flags & ~ASYNC_USR_MASK) != (portp->flags & ~ASYNC_USR_MASK))) - return(-EPERM); + return -EPERM; } portp->flags = (portp->flags & ~ASYNC_USR_MASK) | @@ -1905,8 +1779,8 @@ static int stli_setserial(stliport_t *portp, struct serial_struct __user *sp) portp->custom_divisor = sio.custom_divisor; if ((rc = stli_setport(portp)) < 0) - return(rc); - return(0); + return rc; + return 0; } /*****************************************************************************/ @@ -1917,19 +1791,19 @@ static int stli_tiocmget(struct tty_struct *tty, struct file *file) stlibrd_t *brdp; int rc; - if (portp == (stliport_t *) NULL) - return(-ENODEV); - if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) - return(0); + if (portp == NULL) + return -ENODEV; + if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds) + return 0; brdp = stli_brds[portp->brdnr]; - if (brdp == (stlibrd_t *) NULL) - return(0); + if (brdp == NULL) + return 0; if (tty->flags & (1 << TTY_IO_ERROR)) - return(-EIO); + return -EIO; if ((rc = stli_cmdwait(brdp, portp, A_GETSIGNALS, &portp->asig, sizeof(asysigs_t), 1)) < 0) - return(rc); + return rc; return stli_mktiocm(portp->asig.sigvalue); } @@ -1941,15 +1815,15 @@ static int stli_tiocmset(struct tty_struct *tty, struct file *file, stlibrd_t *brdp; int rts = -1, dtr = -1; - if (portp == (stliport_t *) NULL) - return(-ENODEV); - if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) - return(0); + if (portp == NULL) + return -ENODEV; + if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds) + return 0; brdp = stli_brds[portp->brdnr]; - if (brdp == (stlibrd_t *) NULL) - return(0); + if (brdp == NULL) + return 0; if (tty->flags & (1 << TTY_IO_ERROR)) - return(-EIO); + return -EIO; if (set & TIOCM_RTS) rts = 1; @@ -1968,32 +1842,25 @@ static int stli_tiocmset(struct tty_struct *tty, struct file *file, static int stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) { - stliport_t *portp; - stlibrd_t *brdp; - unsigned int ival; - int rc; + stliport_t *portp; + stlibrd_t *brdp; + unsigned int ival; + int rc; void __user *argp = (void __user *)arg; -#ifdef DEBUG - printk("stli_ioctl(tty=%x,file=%x,cmd=%x,arg=%x)\n", - (int) tty, (int) file, cmd, (int) arg); -#endif - - if (tty == (struct tty_struct *) NULL) - return(-ENODEV); portp = tty->driver_data; - if (portp == (stliport_t *) NULL) - return(-ENODEV); - if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) - return(0); + if (portp == NULL) + return -ENODEV; + if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds) + return 0; brdp = stli_brds[portp->brdnr]; - if (brdp == (stlibrd_t *) NULL) - return(0); + if (brdp == NULL) + return 0; if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) && (cmd != COM_GETPORTSTATS) && (cmd != COM_CLRPORTSTATS)) { if (tty->flags & (1 << TTY_IO_ERROR)) - return(-EIO); + return -EIO; } rc = 0; @@ -2040,7 +1907,7 @@ static int stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm break; } - return(rc); + return rc; } /*****************************************************************************/ @@ -2052,24 +1919,20 @@ static int stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm static void stli_settermios(struct tty_struct *tty, struct termios *old) { - stliport_t *portp; - stlibrd_t *brdp; - struct termios *tiosp; - asyport_t aport; - -#ifdef DEBUG - printk("stli_settermios(tty=%x,old=%x)\n", (int) tty, (int) old); -#endif + stliport_t *portp; + stlibrd_t *brdp; + struct termios *tiosp; + asyport_t aport; - if (tty == (struct tty_struct *) NULL) + if (tty == NULL) return; portp = tty->driver_data; - if (portp == (stliport_t *) NULL) + if (portp == NULL) return; - if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) + if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds) return; brdp = stli_brds[portp->brdnr]; - if (brdp == (stlibrd_t *) NULL) + if (brdp == NULL) return; tiosp = tty->termios; @@ -2102,18 +1965,9 @@ static void stli_settermios(struct tty_struct *tty, struct termios *old) static void stli_throttle(struct tty_struct *tty) { - stliport_t *portp; - -#ifdef DEBUG - printk("stli_throttle(tty=%x)\n", (int) tty); -#endif - - if (tty == (struct tty_struct *) NULL) - return; - portp = tty->driver_data; - if (portp == (stliport_t *) NULL) + stliport_t *portp = tty->driver_data; + if (portp == NULL) return; - set_bit(ST_RXSTOP, &portp->state); } @@ -2127,88 +1981,30 @@ static void stli_throttle(struct tty_struct *tty) static void stli_unthrottle(struct tty_struct *tty) { - stliport_t *portp; - -#ifdef DEBUG - printk("stli_unthrottle(tty=%x)\n", (int) tty); -#endif - - if (tty == (struct tty_struct *) NULL) + stliport_t *portp = tty->driver_data; + if (portp == NULL) return; - portp = tty->driver_data; - if (portp == (stliport_t *) NULL) - return; - clear_bit(ST_RXSTOP, &portp->state); } /*****************************************************************************/ /* - * Stop the transmitter. Basically to do this we will just turn TX - * interrupts off. + * Stop the transmitter. */ static void stli_stop(struct tty_struct *tty) { - stlibrd_t *brdp; - stliport_t *portp; - asyctrl_t actrl; - -#ifdef DEBUG - printk("stli_stop(tty=%x)\n", (int) tty); -#endif - - if (tty == (struct tty_struct *) NULL) - return; - portp = tty->driver_data; - if (portp == (stliport_t *) NULL) - return; - if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) - return; - brdp = stli_brds[portp->brdnr]; - if (brdp == (stlibrd_t *) NULL) - return; - - memset(&actrl, 0, sizeof(asyctrl_t)); - actrl.txctrl = CT_STOPFLOW; -#if 0 - stli_cmdwait(brdp, portp, A_PORTCTRL, &actrl, sizeof(asyctrl_t), 0); -#endif } /*****************************************************************************/ /* - * Start the transmitter again. Just turn TX interrupts back on. + * Start the transmitter again. */ static void stli_start(struct tty_struct *tty) { - stliport_t *portp; - stlibrd_t *brdp; - asyctrl_t actrl; - -#ifdef DEBUG - printk("stli_start(tty=%x)\n", (int) tty); -#endif - - if (tty == (struct tty_struct *) NULL) - return; - portp = tty->driver_data; - if (portp == (stliport_t *) NULL) - return; - if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) - return; - brdp = stli_brds[portp->brdnr]; - if (brdp == (stlibrd_t *) NULL) - return; - - memset(&actrl, 0, sizeof(asyctrl_t)); - actrl.txctrl = CT_STARTFLOW; -#if 0 - stli_cmdwait(brdp, portp, A_PORTCTRL, &actrl, sizeof(asyctrl_t), 0); -#endif } /*****************************************************************************/ @@ -2224,22 +2020,9 @@ static void stli_start(struct tty_struct *tty) static void stli_dohangup(void *arg) { - stliport_t *portp; - -#ifdef DEBUG - printk(KERN_DEBUG "stli_dohangup(portp=%x)\n", (int) arg); -#endif - - /* - * FIXME: There's a module removal race here: tty_hangup - * calls schedule_work which will call into this - * driver later. - */ - portp = (stliport_t *) arg; - if (portp != (stliport_t *) NULL) { - if (portp->tty != (struct tty_struct *) NULL) { - tty_hangup(portp->tty); - } + stliport_t *portp = (stliport_t *) arg; + if (portp->tty != NULL) { + tty_hangup(portp->tty); } } @@ -2254,31 +2037,25 @@ static void stli_dohangup(void *arg) static void stli_hangup(struct tty_struct *tty) { - stliport_t *portp; - stlibrd_t *brdp; - unsigned long flags; - -#ifdef DEBUG - printk(KERN_DEBUG "stli_hangup(tty=%x)\n", (int) tty); -#endif + stliport_t *portp; + stlibrd_t *brdp; + unsigned long flags; - if (tty == (struct tty_struct *) NULL) - return; portp = tty->driver_data; - if (portp == (stliport_t *) NULL) + if (portp == NULL) return; - if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) + if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds) return; brdp = stli_brds[portp->brdnr]; - if (brdp == (stlibrd_t *) NULL) + if (brdp == NULL) return; portp->flags &= ~ASYNC_INITIALIZED; - save_flags(flags); - cli(); - if (! test_bit(ST_CLOSING, &portp->state)) + if (!test_bit(ST_CLOSING, &portp->state)) stli_rawclose(brdp, portp, 0, 0); + + spin_lock_irqsave(&stli_lock, flags); if (tty->termios->c_cflag & HUPCL) { stli_mkasysigs(&portp->asig, 0, 0); if (test_bit(ST_CMDING, &portp->state)) { @@ -2290,14 +2067,15 @@ static void stli_hangup(struct tty_struct *tty) &portp->asig, sizeof(asysigs_t), 0); } } - restore_flags(flags); clear_bit(ST_TXBUSY, &portp->state); clear_bit(ST_RXSTOP, &portp->state); set_bit(TTY_IO_ERROR, &tty->flags); - portp->tty = (struct tty_struct *) NULL; + portp->tty = NULL; portp->flags &= ~ASYNC_NORMAL_ACTIVE; portp->refcount = 0; + spin_unlock_irqrestore(&stli_lock, flags); + wake_up_interruptible(&portp->open_wait); } @@ -2312,29 +2090,22 @@ static void stli_hangup(struct tty_struct *tty) static void stli_flushbuffer(struct tty_struct *tty) { - stliport_t *portp; - stlibrd_t *brdp; - unsigned long ftype, flags; - -#ifdef DEBUG - printk(KERN_DEBUG "stli_flushbuffer(tty=%x)\n", (int) tty); -#endif + stliport_t *portp; + stlibrd_t *brdp; + unsigned long ftype, flags; - if (tty == (struct tty_struct *) NULL) - return; portp = tty->driver_data; - if (portp == (stliport_t *) NULL) + if (portp == NULL) return; - if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) + if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds) return; brdp = stli_brds[portp->brdnr]; - if (brdp == (stlibrd_t *) NULL) + if (brdp == NULL) return; - save_flags(flags); - cli(); + spin_lock_irqsave(&brd_lock, flags); if (tty == stli_txcooktty) { - stli_txcooktty = (struct tty_struct *) NULL; + stli_txcooktty = NULL; stli_txcooksize = 0; stli_txcookrealsize = 0; } @@ -2346,15 +2117,10 @@ static void stli_flushbuffer(struct tty_struct *tty) ftype |= FLUSHRX; clear_bit(ST_DOFLUSHRX, &portp->state); } - stli_sendcmd(brdp, portp, A_FLUSH, &ftype, - sizeof(unsigned long), 0); + __stli_sendcmd(brdp, portp, A_FLUSH, &ftype, sizeof(u32), 0); } - restore_flags(flags); - - wake_up_interruptible(&tty->write_wait); - if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && - tty->ldisc.write_wakeup) - (tty->ldisc.write_wakeup)(tty); + spin_unlock_irqrestore(&brd_lock, flags); + tty_wakeup(tty); } /*****************************************************************************/ @@ -2364,55 +2130,31 @@ static void stli_breakctl(struct tty_struct *tty, int state) stlibrd_t *brdp; stliport_t *portp; long arg; - /* long savestate, savetime; */ -#ifdef DEBUG - printk(KERN_DEBUG "stli_breakctl(tty=%x,state=%d)\n", (int) tty, state); -#endif - - if (tty == (struct tty_struct *) NULL) - return; portp = tty->driver_data; - if (portp == (stliport_t *) NULL) + if (portp == NULL) return; - if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) + if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds) return; brdp = stli_brds[portp->brdnr]; - if (brdp == (stlibrd_t *) NULL) + if (brdp == NULL) return; -/* - * Due to a bug in the tty send_break() code we need to preserve - * the current process state and timeout... - savetime = current->timeout; - savestate = current->state; - */ - arg = (state == -1) ? BREAKON : BREAKOFF; stli_cmdwait(brdp, portp, A_BREAK, &arg, sizeof(long), 0); - -/* - * - current->timeout = savetime; - current->state = savestate; - */ } /*****************************************************************************/ static void stli_waituntilsent(struct tty_struct *tty, int timeout) { - stliport_t *portp; - unsigned long tend; - -#ifdef DEBUG - printk(KERN_DEBUG "stli_waituntilsent(tty=%x,timeout=%x)\n", (int) tty, timeout); -#endif + stliport_t *portp; + unsigned long tend; - if (tty == (struct tty_struct *) NULL) + if (tty == NULL) return; portp = tty->driver_data; - if (portp == (stliport_t *) NULL) + if (portp == NULL) return; if (timeout == 0) @@ -2436,19 +2178,13 @@ static void stli_sendxchar(struct tty_struct *tty, char ch) stliport_t *portp; asyctrl_t actrl; -#ifdef DEBUG - printk(KERN_DEBUG "stli_sendxchar(tty=%x,ch=%x)\n", (int) tty, ch); -#endif - - if (tty == (struct tty_struct *) NULL) - return; portp = tty->driver_data; - if (portp == (stliport_t *) NULL) + if (portp == NULL) return; - if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) + if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds) return; brdp = stli_brds[portp->brdnr]; - if (brdp == (stlibrd_t *) NULL) + if (brdp == NULL) return; memset(&actrl, 0, sizeof(asyctrl_t)); @@ -2460,7 +2196,6 @@ static void stli_sendxchar(struct tty_struct *tty, char ch) actrl.txctrl = CT_SENDCHR; actrl.tximdch = ch; } - stli_cmdwait(brdp, portp, A_PORTCTRL, &actrl, sizeof(asyctrl_t), 0); } @@ -2476,17 +2211,17 @@ static void stli_sendxchar(struct tty_struct *tty, char ch) static int stli_portinfo(stlibrd_t *brdp, stliport_t *portp, int portnr, char *pos) { - char *sp, *uart; - int rc, cnt; + char *sp, *uart; + int rc, cnt; rc = stli_portcmdstats(portp); uart = "UNKNOWN"; if (brdp->state & BST_STARTED) { switch (stli_comstats.hwid) { - case 0: uart = "2681"; break; - case 1: uart = "SC26198"; break; - default: uart = "CD1400"; break; + case 0: uart = "2681"; break; + case 1: uart = "SC26198"; break; + default:uart = "CD1400"; break; } } @@ -2537,17 +2272,11 @@ static int stli_portinfo(stlibrd_t *brdp, stliport_t *portp, int portnr, char *p static int stli_readproc(char *page, char **start, off_t off, int count, int *eof, void *data) { - stlibrd_t *brdp; - stliport_t *portp; - int brdnr, portnr, totalport; - int curoff, maxoff; - char *pos; - -#ifdef DEBUG - printk(KERN_DEBUG "stli_readproc(page=%x,start=%x,off=%x,count=%d,eof=%x," - "data=%x\n", (int) page, (int) start, (int) off, count, - (int) eof, (int) data); -#endif + stlibrd_t *brdp; + stliport_t *portp; + int brdnr, portnr, totalport; + int curoff, maxoff; + char *pos; pos = page; totalport = 0; @@ -2568,7 +2297,7 @@ static int stli_readproc(char *page, char **start, off_t off, int count, int *eo */ for (brdnr = 0; (brdnr < stli_nrbrds); brdnr++) { brdp = stli_brds[brdnr]; - if (brdp == (stlibrd_t *) NULL) + if (brdp == NULL) continue; if (brdp->state == 0) continue; @@ -2583,7 +2312,7 @@ static int stli_readproc(char *page, char **start, off_t off, int count, int *eo for (portnr = 0; (portnr < brdp->nrports); portnr++, totalport++) { portp = brdp->ports[portnr]; - if (portp == (stliport_t *) NULL) + if (portp == NULL) continue; if (off >= (curoff += MAXLINE)) continue; @@ -2610,49 +2339,54 @@ stli_readdone: * a poll routine that does not have user context. Therefore you cannot * copy back directly into user space, or to the kernel stack of a * process. This routine does not sleep, so can be called from anywhere. + * + * The caller must hold the brd_lock (see also stli_sendcmd the usual + * entry point) */ -static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback) +static void __stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback) { - volatile cdkhdr_t *hdrp; - volatile cdkctrl_t *cp; - volatile unsigned char *bits; - unsigned long flags; + cdkhdr_t __iomem *hdrp; + cdkctrl_t __iomem *cp; + unsigned char __iomem *bits; + unsigned long flags; -#ifdef DEBUG - printk(KERN_DEBUG "stli_sendcmd(brdp=%x,portp=%x,cmd=%x,arg=%x,size=%d," - "copyback=%d)\n", (int) brdp, (int) portp, (int) cmd, - (int) arg, size, copyback); -#endif - - save_flags(flags); - cli(); + spin_lock_irqsave(&brd_lock, flags); if (test_bit(ST_CMDING, &portp->state)) { printk(KERN_ERR "STALLION: command already busy, cmd=%x!\n", (int) cmd); - restore_flags(flags); + spin_unlock_irqrestore(&brd_lock, flags); return; } EBRDENABLE(brdp); - cp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->ctrl; + cp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->ctrl; if (size > 0) { - memcpy((void *) &(cp->args[0]), arg, size); + memcpy_toio((void __iomem *) &(cp->args[0]), arg, size); if (copyback) { portp->argp = arg; portp->argsize = size; } } - cp->status = 0; - cp->cmd = cmd; - hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); - bits = ((volatile unsigned char *) hdrp) + brdp->slaveoffset + + writel(0, &cp->status); + writel(cmd, &cp->cmd); + hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); + bits = ((unsigned char __iomem *) hdrp) + brdp->slaveoffset + portp->portidx; - *bits |= portp->portbit; + writeb(readb(bits) | portp->portbit, bits); set_bit(ST_CMDING, &portp->state); EBRDDISABLE(brdp); - restore_flags(flags); + spin_unlock_irqrestore(&brd_lock, flags); +} + +static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback) +{ + unsigned long flags; + + spin_lock_irqsave(&brd_lock, flags); + __stli_sendcmd(brdp, portp, cmd, arg, size, copyback); + spin_unlock_irqrestore(&brd_lock, flags); } /*****************************************************************************/ @@ -2667,28 +2401,23 @@ static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, static void stli_read(stlibrd_t *brdp, stliport_t *portp) { - volatile cdkasyrq_t *rp; - volatile char *shbuf; + cdkasyrq_t __iomem *rp; + char __iomem *shbuf; struct tty_struct *tty; - unsigned int head, tail, size; - unsigned int len, stlen; - -#ifdef DEBUG - printk(KERN_DEBUG "stli_read(brdp=%x,portp=%d)\n", - (int) brdp, (int) portp); -#endif + unsigned int head, tail, size; + unsigned int len, stlen; if (test_bit(ST_RXSTOP, &portp->state)) return; tty = portp->tty; - if (tty == (struct tty_struct *) NULL) + if (tty == NULL) return; - rp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->rxq; - head = (unsigned int) rp->head; - if (head != ((unsigned int) rp->head)) - head = (unsigned int) rp->head; - tail = (unsigned int) rp->tail; + rp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->rxq; + head = (unsigned int) readw(&rp->head); + if (head != ((unsigned int) readw(&rp->head))) + head = (unsigned int) readw(&rp->head); + tail = (unsigned int) readw(&rp->tail); size = portp->rxsize; if (head >= tail) { len = head - tail; @@ -2699,12 +2428,15 @@ static void stli_read(stlibrd_t *brdp, stliport_t *portp) } len = tty_buffer_request_room(tty, len); - /* FIXME : iomap ? */ - shbuf = (volatile char *) EBRDGETMEMPTR(brdp, portp->rxoffset); + + shbuf = (char __iomem *) EBRDGETMEMPTR(brdp, portp->rxoffset); while (len > 0) { + unsigned char *cptr; + stlen = MIN(len, stlen); - tty_insert_flip_string(tty, (char *)(shbuf + tail), stlen); + tty_prepare_flip_string(tty, &cptr, stlen); + memcpy_fromio(cptr, shbuf + tail, stlen); len -= stlen; tail += stlen; if (tail >= size) { @@ -2712,8 +2444,8 @@ static void stli_read(stlibrd_t *brdp, stliport_t *portp) stlen = head; } } - rp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->rxq; - rp->tail = tail; + rp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->rxq; + writew(tail, &rp->tail); if (head != tail) set_bit(ST_RXING, &portp->state); @@ -2729,9 +2461,9 @@ static void stli_read(stlibrd_t *brdp, stliport_t *portp) * difficult to deal with them here. */ -static void stli_dodelaycmd(stliport_t *portp, volatile cdkctrl_t *cp) +static void stli_dodelaycmd(stliport_t *portp, cdkctrl_t __iomem *cp) { - int cmd; + int cmd; if (test_bit(ST_DOSIGS, &portp->state)) { if (test_bit(ST_DOFLUSHTX, &portp->state) && @@ -2746,10 +2478,10 @@ static void stli_dodelaycmd(stliport_t *portp, volatile cdkctrl_t *cp) clear_bit(ST_DOFLUSHTX, &portp->state); clear_bit(ST_DOFLUSHRX, &portp->state); clear_bit(ST_DOSIGS, &portp->state); - memcpy((void *) &(cp->args[0]), (void *) &portp->asig, + memcpy_toio((void __iomem *) &(cp->args[0]), (void *) &portp->asig, sizeof(asysigs_t)); - cp->status = 0; - cp->cmd = cmd; + writel(0, &cp->status); + writel(cmd, &cp->cmd); set_bit(ST_CMDING, &portp->state); } else if (test_bit(ST_DOFLUSHTX, &portp->state) || test_bit(ST_DOFLUSHRX, &portp->state)) { @@ -2757,9 +2489,9 @@ static void stli_dodelaycmd(stliport_t *portp, volatile cdkctrl_t *cp) cmd |= ((test_bit(ST_DOFLUSHRX, &portp->state)) ? FLUSHRX : 0); clear_bit(ST_DOFLUSHTX, &portp->state); clear_bit(ST_DOFLUSHRX, &portp->state); - memcpy((void *) &(cp->args[0]), (void *) &cmd, sizeof(int)); - cp->status = 0; - cp->cmd = A_FLUSH; + memcpy_toio((void __iomem *) &(cp->args[0]), (void *) &cmd, sizeof(int)); + writel(0, &cp->status); + writel(A_FLUSH, &cp->cmd); set_bit(ST_CMDING, &portp->state); } } @@ -2779,30 +2511,25 @@ static void stli_dodelaycmd(stliport_t *portp, volatile cdkctrl_t *cp) static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp) { - volatile cdkasy_t *ap; - volatile cdkctrl_t *cp; - struct tty_struct *tty; - asynotify_t nt; - unsigned long oldsigs; - int rc, donerx; - -#ifdef DEBUG - printk(KERN_DEBUG "stli_hostcmd(brdp=%x,channr=%d)\n", - (int) brdp, channr); -#endif - - ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr); + cdkasy_t __iomem *ap; + cdkctrl_t __iomem *cp; + struct tty_struct *tty; + asynotify_t nt; + unsigned long oldsigs; + int rc, donerx; + + ap = (cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr); cp = &ap->ctrl; /* * Check if we are waiting for an open completion message. */ if (test_bit(ST_OPENING, &portp->state)) { - rc = (int) cp->openarg; - if ((cp->open == 0) && (rc != 0)) { + rc = readl(&cp->openarg); + if (readb(&cp->open) == 0 && rc != 0) { if (rc > 0) rc--; - cp->openarg = 0; + writel(0, &cp->openarg); portp->rc = rc; clear_bit(ST_OPENING, &portp->state); wake_up_interruptible(&portp->raw_wait); @@ -2813,11 +2540,11 @@ static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp) * Check if we are waiting for a close completion message. */ if (test_bit(ST_CLOSING, &portp->state)) { - rc = (int) cp->closearg; - if ((cp->close == 0) && (rc != 0)) { + rc = (int) readl(&cp->closearg); + if (readb(&cp->close) == 0 && rc != 0) { if (rc > 0) rc--; - cp->closearg = 0; + writel(0, &cp->closearg); portp->rc = rc; clear_bit(ST_CLOSING, &portp->state); wake_up_interruptible(&portp->raw_wait); @@ -2829,16 +2556,16 @@ static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp) * need to copy out the command results associated with this command. */ if (test_bit(ST_CMDING, &portp->state)) { - rc = cp->status; - if ((cp->cmd == 0) && (rc != 0)) { + rc = readl(&cp->status); + if (readl(&cp->cmd) == 0 && rc != 0) { if (rc > 0) rc--; - if (portp->argp != (void *) NULL) { - memcpy(portp->argp, (void *) &(cp->args[0]), + if (portp->argp != NULL) { + memcpy_fromio(portp->argp, (void __iomem *) &(cp->args[0]), portp->argsize); - portp->argp = (void *) NULL; + portp->argp = NULL; } - cp->status = 0; + writel(0, &cp->status); portp->rc = rc; clear_bit(ST_CMDING, &portp->state); stli_dodelaycmd(portp, cp); @@ -2877,18 +2604,15 @@ static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp) if (nt.data & DT_TXEMPTY) clear_bit(ST_TXBUSY, &portp->state); if (nt.data & (DT_TXEMPTY | DT_TXLOW)) { - if (tty != (struct tty_struct *) NULL) { - if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && - tty->ldisc.write_wakeup) { - (tty->ldisc.write_wakeup)(tty); - EBRDENABLE(brdp); - } + if (tty != NULL) { + tty_wakeup(tty); + EBRDENABLE(brdp); wake_up_interruptible(&tty->write_wait); } } if ((nt.data & DT_RXBREAK) && (portp->rxmarkmsk & BRKINT)) { - if (tty != (struct tty_struct *) NULL) { + if (tty != NULL) { tty_insert_flip_char(tty, 0, TTY_BREAK); if (portp->flags & ASYNC_SAK) { do_SAK(tty); @@ -2932,14 +2656,14 @@ static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp) * at the cdk header structure. */ -static void stli_brdpoll(stlibrd_t *brdp, volatile cdkhdr_t *hdrp) +static void stli_brdpoll(stlibrd_t *brdp, cdkhdr_t __iomem *hdrp) { - stliport_t *portp; - unsigned char hostbits[(STL_MAXCHANS / 8) + 1]; - unsigned char slavebits[(STL_MAXCHANS / 8) + 1]; - unsigned char *slavep; - int bitpos, bitat, bitsize; - int channr, nrdevs, slavebitchange; + stliport_t *portp; + unsigned char hostbits[(STL_MAXCHANS / 8) + 1]; + unsigned char slavebits[(STL_MAXCHANS / 8) + 1]; + unsigned char __iomem *slavep; + int bitpos, bitat, bitsize; + int channr, nrdevs, slavebitchange; bitsize = brdp->bitsize; nrdevs = brdp->nrdevs; @@ -2951,7 +2675,7 @@ static void stli_brdpoll(stlibrd_t *brdp, volatile cdkhdr_t *hdrp) * 8 service bits at a time in the inner loop, so we can bypass * the lot if none of them want service. */ - memcpy(&hostbits[0], (((unsigned char *) hdrp) + brdp->hostoffset), + memcpy_fromio(&hostbits[0], (((unsigned char __iomem *) hdrp) + brdp->hostoffset), bitsize); memset(&slavebits[0], 0, bitsize); @@ -2978,11 +2702,11 @@ static void stli_brdpoll(stlibrd_t *brdp, volatile cdkhdr_t *hdrp) * service may initiate more slave requests. */ if (slavebitchange) { - hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); - slavep = ((unsigned char *) hdrp) + brdp->slaveoffset; + hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); + slavep = ((unsigned char __iomem *) hdrp) + brdp->slaveoffset; for (bitpos = 0; (bitpos < bitsize); bitpos++) { - if (slavebits[bitpos]) - slavep[bitpos] &= ~slavebits[bitpos]; + if (readb(slavebits + bitpos)) + writeb(readb(slavep + bitpos) & ~slavebits[bitpos], slavebits + bitpos); } } } @@ -3000,9 +2724,9 @@ static void stli_brdpoll(stlibrd_t *brdp, volatile cdkhdr_t *hdrp) static void stli_poll(unsigned long arg) { - volatile cdkhdr_t *hdrp; - stlibrd_t *brdp; - int brdnr; + cdkhdr_t __iomem *hdrp; + stlibrd_t *brdp; + int brdnr; stli_timerlist.expires = STLI_TIMEOUT; add_timer(&stli_timerlist); @@ -3012,16 +2736,18 @@ static void stli_poll(unsigned long arg) */ for (brdnr = 0; (brdnr < stli_nrbrds); brdnr++) { brdp = stli_brds[brdnr]; - if (brdp == (stlibrd_t *) NULL) + if (brdp == NULL) continue; if ((brdp->state & BST_STARTED) == 0) continue; + spin_lock(&brd_lock); EBRDENABLE(brdp); - hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); - if (hdrp->hostreq) + hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); + if (readb(&hdrp->hostreq)) stli_brdpoll(brdp, hdrp); EBRDDISABLE(brdp); + spin_unlock(&brd_lock); } } @@ -3034,11 +2760,6 @@ static void stli_poll(unsigned long arg) static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tiosp) { -#ifdef DEBUG - printk(KERN_DEBUG "stli_mkasyport(portp=%x,pp=%x,tiosp=%d)\n", - (int) portp, (int) pp, (int) tiosp); -#endif - memset(pp, 0, sizeof(asyport_t)); /* @@ -3157,11 +2878,6 @@ static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tio static void stli_mkasysigs(asysigs_t *sp, int dtr, int rts) { -#ifdef DEBUG - printk(KERN_DEBUG "stli_mkasysigs(sp=%x,dtr=%d,rts=%d)\n", - (int) sp, dtr, rts); -#endif - memset(sp, 0, sizeof(asysigs_t)); if (dtr >= 0) { sp->signal |= SG_DTR; @@ -3182,13 +2898,7 @@ static void stli_mkasysigs(asysigs_t *sp, int dtr, int rts) static long stli_mktiocm(unsigned long sigvalue) { - long tiocm; - -#ifdef DEBUG - printk(KERN_DEBUG "stli_mktiocm(sigvalue=%x)\n", (int) sigvalue); -#endif - - tiocm = 0; + long tiocm = 0; tiocm |= ((sigvalue & SG_DCD) ? TIOCM_CD : 0); tiocm |= ((sigvalue & SG_CTS) ? TIOCM_CTS : 0); tiocm |= ((sigvalue & SG_RI) ? TIOCM_RI : 0); @@ -3210,10 +2920,6 @@ static int stli_initports(stlibrd_t *brdp) stliport_t *portp; int i, panelnr, panelport; -#ifdef DEBUG - printk(KERN_DEBUG "stli_initports(brdp=%x)\n", (int) brdp); -#endif - for (i = 0, panelnr = 0, panelport = 0; (i < brdp->nrports); i++) { portp = kzalloc(sizeof(stliport_t), GFP_KERNEL); if (!portp) { @@ -3240,7 +2946,7 @@ static int stli_initports(stlibrd_t *brdp) brdp->ports[i] = portp; } - return(0); + return 0; } /*****************************************************************************/ @@ -3253,10 +2959,6 @@ static void stli_ecpinit(stlibrd_t *brdp) { unsigned long memconf; -#ifdef DEBUG - printk(KERN_DEBUG "stli_ecpinit(brdp=%d)\n", (int) brdp); -#endif - outb(ECP_ATSTOP, (brdp->iobase + ECP_ATCONFR)); udelay(10); outb(ECP_ATDISABLE, (brdp->iobase + ECP_ATCONFR)); @@ -3270,9 +2972,6 @@ static void stli_ecpinit(stlibrd_t *brdp) static void stli_ecpenable(stlibrd_t *brdp) { -#ifdef DEBUG - printk(KERN_DEBUG "stli_ecpenable(brdp=%x)\n", (int) brdp); -#endif outb(ECP_ATENABLE, (brdp->iobase + ECP_ATCONFR)); } @@ -3280,9 +2979,6 @@ static void stli_ecpenable(stlibrd_t *brdp) static void stli_ecpdisable(stlibrd_t *brdp) { -#ifdef DEBUG - printk(KERN_DEBUG "stli_ecpdisable(brdp=%x)\n", (int) brdp); -#endif outb(ECP_ATDISABLE, (brdp->iobase + ECP_ATCONFR)); } @@ -3290,13 +2986,8 @@ static void stli_ecpdisable(stlibrd_t *brdp) static char *stli_ecpgetmemptr(stlibrd_t *brdp, unsigned long offset, int line) { - void *ptr; - unsigned char val; - -#ifdef DEBUG - printk(KERN_DEBUG "stli_ecpgetmemptr(brdp=%x,offset=%x)\n", (int) brdp, - (int) offset); -#endif + void *ptr; + unsigned char val; if (offset > brdp->memsize) { printk(KERN_ERR "STALLION: shared memory pointer=%x out of " @@ -3316,10 +3007,6 @@ static char *stli_ecpgetmemptr(stlibrd_t *brdp, unsigned long offset, int line) static void stli_ecpreset(stlibrd_t *brdp) { -#ifdef DEBUG - printk(KERN_DEBUG "stli_ecpreset(brdp=%x)\n", (int) brdp); -#endif - outb(ECP_ATSTOP, (brdp->iobase + ECP_ATCONFR)); udelay(10); outb(ECP_ATDISABLE, (brdp->iobase + ECP_ATCONFR)); @@ -3330,9 +3017,6 @@ static void stli_ecpreset(stlibrd_t *brdp) static void stli_ecpintr(stlibrd_t *brdp) { -#ifdef DEBUG - printk(KERN_DEBUG "stli_ecpintr(brdp=%x)\n", (int) brdp); -#endif outb(0x1, brdp->iobase); } @@ -3346,10 +3030,6 @@ static void stli_ecpeiinit(stlibrd_t *brdp) { unsigned long memconf; -#ifdef DEBUG - printk(KERN_DEBUG "stli_ecpeiinit(brdp=%x)\n", (int) brdp); -#endif - outb(0x1, (brdp->iobase + ECP_EIBRDENAB)); outb(ECP_EISTOP, (brdp->iobase + ECP_EICONFR)); udelay(10); @@ -3383,11 +3063,6 @@ static char *stli_ecpeigetmemptr(stlibrd_t *brdp, unsigned long offset, int line void *ptr; unsigned char val; -#ifdef DEBUG - printk(KERN_DEBUG "stli_ecpeigetmemptr(brdp=%x,offset=%x,line=%d)\n", - (int) brdp, (int) offset, line); -#endif - if (offset > brdp->memsize) { printk(KERN_ERR "STALLION: shared memory pointer=%x out of " "range at line=%d(%d), brd=%d\n", @@ -3437,8 +3112,8 @@ static void stli_ecpmcdisable(stlibrd_t *brdp) static char *stli_ecpmcgetmemptr(stlibrd_t *brdp, unsigned long offset, int line) { - void *ptr; - unsigned char val; + void *ptr; + unsigned char val; if (offset > brdp->memsize) { printk(KERN_ERR "STALLION: shared memory pointer=%x out of " @@ -3472,10 +3147,6 @@ static void stli_ecpmcreset(stlibrd_t *brdp) static void stli_ecppciinit(stlibrd_t *brdp) { -#ifdef DEBUG - printk(KERN_DEBUG "stli_ecppciinit(brdp=%x)\n", (int) brdp); -#endif - outb(ECP_PCISTOP, (brdp->iobase + ECP_PCICONFR)); udelay(10); outb(0, (brdp->iobase + ECP_PCICONFR)); @@ -3489,11 +3160,6 @@ static char *stli_ecppcigetmemptr(stlibrd_t *brdp, unsigned long offset, int lin void *ptr; unsigned char val; -#ifdef DEBUG - printk(KERN_DEBUG "stli_ecppcigetmemptr(brdp=%x,offset=%x,line=%d)\n", - (int) brdp, (int) offset, line); -#endif - if (offset > brdp->memsize) { printk(KERN_ERR "STALLION: shared memory pointer=%x out of " "range at line=%d(%d), board=%d\n", @@ -3528,10 +3194,6 @@ static void stli_onbinit(stlibrd_t *brdp) { unsigned long memconf; -#ifdef DEBUG - printk(KERN_DEBUG "stli_onbinit(brdp=%d)\n", (int) brdp); -#endif - outb(ONB_ATSTOP, (brdp->iobase + ONB_ATCONFR)); udelay(10); outb(ONB_ATDISABLE, (brdp->iobase + ONB_ATCONFR)); @@ -3547,9 +3209,6 @@ static void stli_onbinit(stlibrd_t *brdp) static void stli_onbenable(stlibrd_t *brdp) { -#ifdef DEBUG - printk(KERN_DEBUG "stli_onbenable(brdp=%x)\n", (int) brdp); -#endif outb((brdp->enabval | ONB_ATENABLE), (brdp->iobase + ONB_ATCONFR)); } @@ -3557,9 +3216,6 @@ static void stli_onbenable(stlibrd_t *brdp) static void stli_onbdisable(stlibrd_t *brdp) { -#ifdef DEBUG - printk(KERN_DEBUG "stli_onbdisable(brdp=%x)\n", (int) brdp); -#endif outb((brdp->enabval | ONB_ATDISABLE), (brdp->iobase + ONB_ATCONFR)); } @@ -3569,11 +3225,6 @@ static char *stli_onbgetmemptr(stlibrd_t *brdp, unsigned long offset, int line) { void *ptr; -#ifdef DEBUG - printk(KERN_DEBUG "stli_onbgetmemptr(brdp=%x,offset=%x)\n", (int) brdp, - (int) offset); -#endif - if (offset > brdp->memsize) { printk(KERN_ERR "STALLION: shared memory pointer=%x out of " "range at line=%d(%d), brd=%d\n", @@ -3589,11 +3240,6 @@ static char *stli_onbgetmemptr(stlibrd_t *brdp, unsigned long offset, int line) static void stli_onbreset(stlibrd_t *brdp) { - -#ifdef DEBUG - printk(KERN_DEBUG "stli_onbreset(brdp=%x)\n", (int) brdp); -#endif - outb(ONB_ATSTOP, (brdp->iobase + ONB_ATCONFR)); udelay(10); outb(ONB_ATDISABLE, (brdp->iobase + ONB_ATCONFR)); @@ -3610,10 +3256,6 @@ static void stli_onbeinit(stlibrd_t *brdp) { unsigned long memconf; -#ifdef DEBUG - printk(KERN_DEBUG "stli_onbeinit(brdp=%d)\n", (int) brdp); -#endif - outb(0x1, (brdp->iobase + ONB_EIBRDENAB)); outb(ONB_EISTOP, (brdp->iobase + ONB_EICONFR)); udelay(10); @@ -3632,9 +3274,6 @@ static void stli_onbeinit(stlibrd_t *brdp) static void stli_onbeenable(stlibrd_t *brdp) { -#ifdef DEBUG - printk(KERN_DEBUG "stli_onbeenable(brdp=%x)\n", (int) brdp); -#endif outb(ONB_EIENABLE, (brdp->iobase + ONB_EICONFR)); } @@ -3642,9 +3281,6 @@ static void stli_onbeenable(stlibrd_t *brdp) static void stli_onbedisable(stlibrd_t *brdp) { -#ifdef DEBUG - printk(KERN_DEBUG "stli_onbedisable(brdp=%x)\n", (int) brdp); -#endif outb(ONB_EIDISABLE, (brdp->iobase + ONB_EICONFR)); } @@ -3652,13 +3288,8 @@ static void stli_onbedisable(stlibrd_t *brdp) static char *stli_onbegetmemptr(stlibrd_t *brdp, unsigned long offset, int line) { - void *ptr; - unsigned char val; - -#ifdef DEBUG - printk(KERN_DEBUG "stli_onbegetmemptr(brdp=%x,offset=%x,line=%d)\n", - (int) brdp, (int) offset, line); -#endif + void *ptr; + unsigned char val; if (offset > brdp->memsize) { printk(KERN_ERR "STALLION: shared memory pointer=%x out of " @@ -3681,11 +3312,6 @@ static char *stli_onbegetmemptr(stlibrd_t *brdp, unsigned long offset, int line) static void stli_onbereset(stlibrd_t *brdp) { - -#ifdef DEBUG - printk(KERN_ERR "stli_onbereset(brdp=%x)\n", (int) brdp); -#endif - outb(ONB_EISTOP, (brdp->iobase + ONB_EICONFR)); udelay(10); outb(ONB_EIDISABLE, (brdp->iobase + ONB_EICONFR)); @@ -3700,11 +3326,6 @@ static void stli_onbereset(stlibrd_t *brdp) static void stli_bbyinit(stlibrd_t *brdp) { - -#ifdef DEBUG - printk(KERN_ERR "stli_bbyinit(brdp=%d)\n", (int) brdp); -#endif - outb(BBY_ATSTOP, (brdp->iobase + BBY_ATCONFR)); udelay(10); outb(0, (brdp->iobase + BBY_ATCONFR)); @@ -3717,24 +3338,13 @@ static void stli_bbyinit(stlibrd_t *brdp) static char *stli_bbygetmemptr(stlibrd_t *brdp, unsigned long offset, int line) { - void *ptr; - unsigned char val; + void *ptr; + unsigned char val; -#ifdef DEBUG - printk(KERN_ERR "stli_bbygetmemptr(brdp=%x,offset=%x)\n", (int) brdp, - (int) offset); -#endif + BUG_ON(offset > brdp->memsize); - if (offset > brdp->memsize) { - printk(KERN_ERR "STALLION: shared memory pointer=%x out of " - "range at line=%d(%d), brd=%d\n", - (int) offset, line, __LINE__, brdp->brdnr); - ptr = NULL; - val = 0; - } else { - ptr = brdp->membase + (offset % BBY_PAGESIZE); - val = (unsigned char) (offset / BBY_PAGESIZE); - } + ptr = brdp->membase + (offset % BBY_PAGESIZE); + val = (unsigned char) (offset / BBY_PAGESIZE); outb(val, (brdp->iobase + BBY_ATCONFR)); return(ptr); } @@ -3743,11 +3353,6 @@ static char *stli_bbygetmemptr(stlibrd_t *brdp, unsigned long offset, int line) static void stli_bbyreset(stlibrd_t *brdp) { - -#ifdef DEBUG - printk(KERN_DEBUG "stli_bbyreset(brdp=%x)\n", (int) brdp); -#endif - outb(BBY_ATSTOP, (brdp->iobase + BBY_ATCONFR)); udelay(10); outb(0, (brdp->iobase + BBY_ATCONFR)); @@ -3762,11 +3367,6 @@ static void stli_bbyreset(stlibrd_t *brdp) static void stli_stalinit(stlibrd_t *brdp) { - -#ifdef DEBUG - printk(KERN_DEBUG "stli_stalinit(brdp=%d)\n", (int) brdp); -#endif - outb(0x1, brdp->iobase); mdelay(1000); } @@ -3775,36 +3375,18 @@ static void stli_stalinit(stlibrd_t *brdp) static char *stli_stalgetmemptr(stlibrd_t *brdp, unsigned long offset, int line) { - void *ptr; - -#ifdef DEBUG - printk(KERN_DEBUG "stli_stalgetmemptr(brdp=%x,offset=%x)\n", (int) brdp, - (int) offset); -#endif - - if (offset > brdp->memsize) { - printk(KERN_ERR "STALLION: shared memory pointer=%x out of " - "range at line=%d(%d), brd=%d\n", - (int) offset, line, __LINE__, brdp->brdnr); - ptr = NULL; - } else { - ptr = brdp->membase + (offset % STAL_PAGESIZE); - } - return(ptr); + BUG_ON(offset > brdp->memsize); + return brdp->membase + (offset % STAL_PAGESIZE); } /*****************************************************************************/ static void stli_stalreset(stlibrd_t *brdp) { - volatile unsigned long *vecp; + u32 __iomem *vecp; -#ifdef DEBUG - printk(KERN_DEBUG "stli_stalreset(brdp=%x)\n", (int) brdp); -#endif - - vecp = (volatile unsigned long *) (brdp->membase + 0x30); - *vecp = 0xffff0000; + vecp = (u32 __iomem *) (brdp->membase + 0x30); + writel(0xffff0000, vecp); outb(0, brdp->iobase); mdelay(1000); } @@ -3818,15 +3400,11 @@ static void stli_stalreset(stlibrd_t *brdp) static int stli_initecp(stlibrd_t *brdp) { - cdkecpsig_t sig; - cdkecpsig_t *sigsp; - unsigned int status, nxtid; - char *name; - int panelnr, nrports; - -#ifdef DEBUG - printk(KERN_DEBUG "stli_initecp(brdp=%x)\n", (int) brdp); -#endif + cdkecpsig_t sig; + cdkecpsig_t __iomem *sigsp; + unsigned int status, nxtid; + char *name; + int panelnr, nrports; if (!request_region(brdp->iobase, brdp->iosize, "istallion")) return -EIO; @@ -3834,7 +3412,7 @@ static int stli_initecp(stlibrd_t *brdp) if ((brdp->iobase == 0) || (brdp->memaddr == 0)) { release_region(brdp->iobase, brdp->iosize); - return(-ENODEV); + return -ENODEV; } brdp->iosize = ECP_IOSIZE; @@ -3903,7 +3481,7 @@ static int stli_initecp(stlibrd_t *brdp) default: release_region(brdp->iobase, brdp->iosize); - return(-EINVAL); + return -EINVAL; } /* @@ -3915,10 +3493,10 @@ static int stli_initecp(stlibrd_t *brdp) EBRDINIT(brdp); brdp->membase = ioremap(brdp->memaddr, brdp->memsize); - if (brdp->membase == (void *) NULL) + if (brdp->membase == NULL) { release_region(brdp->iobase, brdp->iosize); - return(-ENOMEM); + return -ENOMEM; } /* @@ -3927,23 +3505,14 @@ static int stli_initecp(stlibrd_t *brdp) * this is, and what it is connected to it. */ EBRDENABLE(brdp); - sigsp = (cdkecpsig_t *) EBRDGETMEMPTR(brdp, CDK_SIGADDR); + sigsp = (cdkecpsig_t __iomem *) EBRDGETMEMPTR(brdp, CDK_SIGADDR); memcpy(&sig, sigsp, sizeof(cdkecpsig_t)); EBRDDISABLE(brdp); -#if 0 - printk("%s(%d): sig-> magic=%x rom=%x panel=%x,%x,%x,%x,%x,%x,%x,%x\n", - __FILE__, __LINE__, (int) sig.magic, sig.romver, sig.panelid[0], - (int) sig.panelid[1], (int) sig.panelid[2], - (int) sig.panelid[3], (int) sig.panelid[4], - (int) sig.panelid[5], (int) sig.panelid[6], - (int) sig.panelid[7]); -#endif - - if (sig.magic != ECP_MAGIC) + if (sig.magic != cpu_to_le32(ECP_MAGIC)) { release_region(brdp->iobase, brdp->iosize); - return(-ENODEV); + return -ENODEV; } /* @@ -3967,7 +3536,7 @@ static int stli_initecp(stlibrd_t *brdp) brdp->state |= BST_FOUND; - return(0); + return 0; } /*****************************************************************************/ @@ -3979,20 +3548,16 @@ static int stli_initecp(stlibrd_t *brdp) static int stli_initonb(stlibrd_t *brdp) { - cdkonbsig_t sig; - cdkonbsig_t *sigsp; - char *name; - int i; - -#ifdef DEBUG - printk(KERN_DEBUG "stli_initonb(brdp=%x)\n", (int) brdp); -#endif + cdkonbsig_t sig; + cdkonbsig_t __iomem *sigsp; + char *name; + int i; /* * Do a basic sanity check on the IO and memory addresses. */ - if ((brdp->iobase == 0) || (brdp->memaddr == 0)) - return(-ENODEV); + if (brdp->iobase == 0 || brdp->memaddr == 0) + return -ENODEV; brdp->iosize = ONB_IOSIZE; @@ -4010,7 +3575,6 @@ static int stli_initonb(stlibrd_t *brdp) case BRD_ONBOARD2: case BRD_ONBOARD2_32: case BRD_ONBOARDRS: - brdp->membase = (void *) brdp->memaddr; brdp->memsize = ONB_MEMSIZE; brdp->pagesize = ONB_ATPAGESIZE; brdp->init = stli_onbinit; @@ -4028,7 +3592,6 @@ static int stli_initonb(stlibrd_t *brdp) break; case BRD_ONBOARDE: - brdp->membase = (void *) brdp->memaddr; brdp->memsize = ONB_EIMEMSIZE; brdp->pagesize = ONB_EIPAGESIZE; brdp->init = stli_onbeinit; @@ -4044,7 +3607,6 @@ static int stli_initonb(stlibrd_t *brdp) case BRD_BRUMBY4: case BRD_BRUMBY8: case BRD_BRUMBY16: - brdp->membase = (void *) brdp->memaddr; brdp->memsize = BBY_MEMSIZE; brdp->pagesize = BBY_PAGESIZE; brdp->init = stli_bbyinit; @@ -4058,7 +3620,6 @@ static int stli_initonb(stlibrd_t *brdp) break; case BRD_STALLION: - brdp->membase = (void *) brdp->memaddr; brdp->memsize = STAL_MEMSIZE; brdp->pagesize = STAL_PAGESIZE; brdp->init = stli_stalinit; @@ -4073,7 +3634,7 @@ static int stli_initonb(stlibrd_t *brdp) default: release_region(brdp->iobase, brdp->iosize); - return(-EINVAL); + return -EINVAL; } /* @@ -4085,10 +3646,10 @@ static int stli_initonb(stlibrd_t *brdp) EBRDINIT(brdp); brdp->membase = ioremap(brdp->memaddr, brdp->memsize); - if (brdp->membase == (void *) NULL) + if (brdp->membase == NULL) { release_region(brdp->iobase, brdp->iosize); - return(-ENOMEM); + return -ENOMEM; } /* @@ -4097,21 +3658,17 @@ static int stli_initonb(stlibrd_t *brdp) * this is, and how many ports. */ EBRDENABLE(brdp); - sigsp = (cdkonbsig_t *) EBRDGETMEMPTR(brdp, CDK_SIGADDR); - memcpy(&sig, sigsp, sizeof(cdkonbsig_t)); + sigsp = (cdkonbsig_t __iomem *) EBRDGETMEMPTR(brdp, CDK_SIGADDR); + memcpy_fromio(&sig, sigsp, sizeof(cdkonbsig_t)); EBRDDISABLE(brdp); -#if 0 - printk("%s(%d): sig-> magic=%x:%x:%x:%x romver=%x amask=%x:%x:%x\n", - __FILE__, __LINE__, sig.magic0, sig.magic1, sig.magic2, - sig.magic3, sig.romver, sig.amask0, sig.amask1, sig.amask2); -#endif - - if ((sig.magic0 != ONB_MAGIC0) || (sig.magic1 != ONB_MAGIC1) || - (sig.magic2 != ONB_MAGIC2) || (sig.magic3 != ONB_MAGIC3)) + if (sig.magic0 != cpu_to_le16(ONB_MAGIC0) || + sig.magic1 != cpu_to_le16(ONB_MAGIC1) || + sig.magic2 != cpu_to_le16(ONB_MAGIC2) || + sig.magic3 != cpu_to_le16(ONB_MAGIC3)) { release_region(brdp->iobase, brdp->iosize); - return(-ENODEV); + return -ENODEV; } /* @@ -4132,7 +3689,7 @@ static int stli_initonb(stlibrd_t *brdp) brdp->state |= BST_FOUND; - return(0); + return 0; } /*****************************************************************************/ @@ -4145,31 +3702,25 @@ static int stli_initonb(stlibrd_t *brdp) static int stli_startbrd(stlibrd_t *brdp) { - volatile cdkhdr_t *hdrp; - volatile cdkmem_t *memp; - volatile cdkasy_t *ap; - unsigned long flags; - stliport_t *portp; - int portnr, nrdevs, i, rc; - -#ifdef DEBUG - printk(KERN_DEBUG "stli_startbrd(brdp=%x)\n", (int) brdp); -#endif - - rc = 0; - - save_flags(flags); - cli(); + cdkhdr_t __iomem *hdrp; + cdkmem_t __iomem *memp; + cdkasy_t __iomem *ap; + unsigned long flags; + stliport_t *portp; + int portnr, nrdevs, i, rc = 0; + u32 memoff; + + spin_lock_irqsave(&brd_lock, flags); EBRDENABLE(brdp); - hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); + hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); nrdevs = hdrp->nrdevs; #if 0 printk("%s(%d): CDK version %d.%d.%d --> " "nrdevs=%d memp=%x hostp=%x slavep=%x\n", - __FILE__, __LINE__, hdrp->ver_release, hdrp->ver_modification, - hdrp->ver_fix, nrdevs, (int) hdrp->memp, (int) hdrp->hostp, - (int) hdrp->slavep); + __FILE__, __LINE__, readb(&hdrp->ver_release), readb(&hdrp->ver_modification), + readb(&hdrp->ver_fix), nrdevs, (int) readl(&hdrp->memp), readl(&hdrp->hostp), + readl(&hdrp->slavep)); #endif if (nrdevs < (brdp->nrports + 1)) { @@ -4181,14 +3732,14 @@ static int stli_startbrd(stlibrd_t *brdp) brdp->hostoffset = hdrp->hostp - CDK_CDKADDR; brdp->slaveoffset = hdrp->slavep - CDK_CDKADDR; brdp->bitsize = (nrdevs + 7) / 8; - memp = (volatile cdkmem_t *) hdrp->memp; - if (((unsigned long) memp) > brdp->memsize) { + memoff = readl(&hdrp->memp); + if (memoff > brdp->memsize) { printk(KERN_ERR "STALLION: corrupted shared memory region?\n"); rc = -EIO; goto stli_donestartup; } - memp = (volatile cdkmem_t *) EBRDGETMEMPTR(brdp, (unsigned long) memp); - if (memp->dtype != TYP_ASYNCTRL) { + memp = (cdkmem_t __iomem *) EBRDGETMEMPTR(brdp, memoff); + if (readw(&memp->dtype) != TYP_ASYNCTRL) { printk(KERN_ERR "STALLION: no slave control device found\n"); goto stli_donestartup; } @@ -4200,19 +3751,19 @@ static int stli_startbrd(stlibrd_t *brdp) * change pages while reading memory map. */ for (i = 1, portnr = 0; (i < nrdevs); i++, portnr++, memp++) { - if (memp->dtype != TYP_ASYNC) + if (readw(&memp->dtype) != TYP_ASYNC) break; portp = brdp->ports[portnr]; - if (portp == (stliport_t *) NULL) + if (portp == NULL) break; portp->devnr = i; - portp->addr = memp->offset; + portp->addr = readl(&memp->offset); portp->reqbit = (unsigned char) (0x1 << (i * 8 / nrdevs)); portp->portidx = (unsigned char) (i / 8); portp->portbit = (unsigned char) (0x1 << (i % 8)); } - hdrp->slavereq = 0xff; + writeb(0xff, &hdrp->slavereq); /* * For each port setup a local copy of the RX and TX buffer offsets @@ -4221,22 +3772,22 @@ static int stli_startbrd(stlibrd_t *brdp) */ for (i = 1, portnr = 0; (i < nrdevs); i++, portnr++) { portp = brdp->ports[portnr]; - if (portp == (stliport_t *) NULL) + if (portp == NULL) break; if (portp->addr == 0) break; - ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr); - if (ap != (volatile cdkasy_t *) NULL) { - portp->rxsize = ap->rxq.size; - portp->txsize = ap->txq.size; - portp->rxoffset = ap->rxq.offset; - portp->txoffset = ap->txq.offset; + ap = (cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr); + if (ap != NULL) { + portp->rxsize = readw(&ap->rxq.size); + portp->txsize = readw(&ap->txq.size); + portp->rxoffset = readl(&ap->rxq.offset); + portp->txoffset = readl(&ap->txq.offset); } } stli_donestartup: EBRDDISABLE(brdp); - restore_flags(flags); + spin_unlock_irqrestore(&brd_lock, flags); if (rc == 0) brdp->state |= BST_STARTED; @@ -4247,7 +3798,7 @@ stli_donestartup: add_timer(&stli_timerlist); } - return(rc); + return rc; } /*****************************************************************************/ @@ -4258,10 +3809,6 @@ stli_donestartup: static int __init stli_brdinit(stlibrd_t *brdp) { -#ifdef DEBUG - printk(KERN_DEBUG "stli_brdinit(brdp=%x)\n", (int) brdp); -#endif - stli_brds[brdp->brdnr] = brdp; switch (brdp->brdtype) { @@ -4289,11 +3836,11 @@ static int __init stli_brdinit(stlibrd_t *brdp) case BRD_ECHPCI: printk(KERN_ERR "STALLION: %s board type not supported in " "this driver\n", stli_brdnames[brdp->brdtype]); - return(ENODEV); + return -ENODEV; default: printk(KERN_ERR "STALLION: board=%d is unknown board " "type=%d\n", brdp->brdnr, brdp->brdtype); - return(ENODEV); + return -ENODEV; } if ((brdp->state & BST_FOUND) == 0) { @@ -4301,7 +3848,7 @@ static int __init stli_brdinit(stlibrd_t *brdp) "io=%x mem=%x\n", stli_brdnames[brdp->brdtype], brdp->brdnr, brdp->iobase, (int) brdp->memaddr); - return(ENODEV); + return -ENODEV; } stli_initports(brdp); @@ -4309,7 +3856,7 @@ static int __init stli_brdinit(stlibrd_t *brdp) "nrpanels=%d nrports=%d\n", stli_brdnames[brdp->brdtype], brdp->brdnr, brdp->iobase, (int) brdp->memaddr, brdp->nrpanels, brdp->nrports); - return(0); + return 0; } /*****************************************************************************/ @@ -4321,14 +3868,10 @@ static int __init stli_brdinit(stlibrd_t *brdp) static int stli_eisamemprobe(stlibrd_t *brdp) { - cdkecpsig_t ecpsig, *ecpsigp; - cdkonbsig_t onbsig, *onbsigp; + cdkecpsig_t ecpsig, __iomem *ecpsigp; + cdkonbsig_t onbsig, __iomem *onbsigp; int i, foundit; -#ifdef DEBUG - printk(KERN_DEBUG "stli_eisamemprobe(brdp=%x)\n", (int) brdp); -#endif - /* * First up we reset the board, to get it into a known state. There * is only 2 board types here we need to worry about. Don;t use the @@ -4352,7 +3895,7 @@ static int stli_eisamemprobe(stlibrd_t *brdp) mdelay(1); stli_onbeenable(brdp); } else { - return(-ENODEV); + return -ENODEV; } foundit = 0; @@ -4364,25 +3907,24 @@ static int stli_eisamemprobe(stlibrd_t *brdp) */ for (i = 0; (i < stli_eisamempsize); i++) { brdp->memaddr = stli_eisamemprobeaddrs[i]; - brdp->membase = (void *) brdp->memaddr; brdp->membase = ioremap(brdp->memaddr, brdp->memsize); - if (brdp->membase == (void *) NULL) + if (brdp->membase == NULL) continue; if (brdp->brdtype == BRD_ECPE) { - ecpsigp = (cdkecpsig_t *) stli_ecpeigetmemptr(brdp, + ecpsigp = (cdkecpsig_t __iomem *) stli_ecpeigetmemptr(brdp, CDK_SIGADDR, __LINE__); - memcpy(&ecpsig, ecpsigp, sizeof(cdkecpsig_t)); - if (ecpsig.magic == ECP_MAGIC) + memcpy_fromio(&ecpsig, ecpsigp, sizeof(cdkecpsig_t)); + if (ecpsig.magic == cpu_to_le32(ECP_MAGIC)) foundit = 1; } else { - onbsigp = (cdkonbsig_t *) stli_onbegetmemptr(brdp, + onbsigp = (cdkonbsig_t __iomem *) stli_onbegetmemptr(brdp, CDK_SIGADDR, __LINE__); - memcpy(&onbsig, onbsigp, sizeof(cdkonbsig_t)); - if ((onbsig.magic0 == ONB_MAGIC0) && - (onbsig.magic1 == ONB_MAGIC1) && - (onbsig.magic2 == ONB_MAGIC2) && - (onbsig.magic3 == ONB_MAGIC3)) + memcpy_fromio(&onbsig, onbsigp, sizeof(cdkonbsig_t)); + if ((onbsig.magic0 == cpu_to_le16(ONB_MAGIC0)) && + (onbsig.magic1 == cpu_to_le16(ONB_MAGIC1)) && + (onbsig.magic2 == cpu_to_le16(ONB_MAGIC2)) && + (onbsig.magic3 == cpu_to_le16(ONB_MAGIC3))) foundit = 1; } @@ -4406,9 +3948,9 @@ static int stli_eisamemprobe(stlibrd_t *brdp) printk(KERN_ERR "STALLION: failed to probe shared memory " "region for %s in EISA slot=%d\n", stli_brdnames[brdp->brdtype], (brdp->iobase >> 12)); - return(-ENODEV); + return -ENODEV; } - return(0); + return 0; } static int stli_getbrdnr(void) @@ -4439,22 +3981,16 @@ static int stli_getbrdnr(void) static int stli_findeisabrds(void) { - stlibrd_t *brdp; - unsigned int iobase, eid; - int i; - -#ifdef DEBUG - printk(KERN_DEBUG "stli_findeisabrds()\n"); -#endif + stlibrd_t *brdp; + unsigned int iobase, eid; + int i; /* - * Firstly check if this is an EISA system. Do this by probing for - * the system board EISA ID. If this is not an EISA system then + * Firstly check if this is an EISA system. If this is not an EISA system then * don't bother going any further! */ - outb(0xff, 0xc80); - if (inb(0xc80) == 0xff) - return(0); + if (EISA_bus) + return 0; /* * Looks like an EISA system, so go searching for EISA boards. @@ -4472,7 +4008,7 @@ static int stli_findeisabrds(void) */ for (i = 0; (i < STL_MAXBRDS); i++) { brdp = stli_brds[i]; - if (brdp == (stlibrd_t *) NULL) + if (brdp == NULL) continue; if (brdp->iobase == iobase) break; @@ -4484,10 +4020,10 @@ static int stli_findeisabrds(void) * We have found a Stallion board and it is not configured already. * Allocate a board structure and initialize it. */ - if ((brdp = stli_allocbrd()) == (stlibrd_t *) NULL) - return(-ENOMEM); + if ((brdp = stli_allocbrd()) == NULL) + return -ENOMEM; if ((brdp->brdnr = stli_getbrdnr()) < 0) - return(-ENOMEM); + return -ENOMEM; eid = inb(iobase + 0xc82); if (eid == ECP_EISAID) brdp->brdtype = BRD_ECPE; @@ -4502,7 +4038,7 @@ static int stli_findeisabrds(void) stli_brdinit(brdp); } - return(0); + return 0; } /*****************************************************************************/ @@ -4523,32 +4059,18 @@ static int stli_findeisabrds(void) static int stli_initpcibrd(int brdtype, struct pci_dev *devp) { - stlibrd_t *brdp; - -#ifdef DEBUG - printk(KERN_DEBUG "stli_initpcibrd(brdtype=%d,busnr=%x,devnr=%x)\n", - brdtype, dev->bus->number, dev->devfn); -#endif + stlibrd_t *brdp; if (pci_enable_device(devp)) - return(-EIO); - if ((brdp = stli_allocbrd()) == (stlibrd_t *) NULL) - return(-ENOMEM); + return -EIO; + if ((brdp = stli_allocbrd()) == NULL) + return -ENOMEM; if ((brdp->brdnr = stli_getbrdnr()) < 0) { printk(KERN_INFO "STALLION: too many boards found, " "maximum supported %d\n", STL_MAXBRDS); - return(0); + return 0; } brdp->brdtype = brdtype; - -#ifdef DEBUG - printk(KERN_DEBUG "%s(%d): BAR[]=%lx,%lx,%lx,%lx\n", __FILE__, __LINE__, - pci_resource_start(devp, 0), - pci_resource_start(devp, 1), - pci_resource_start(devp, 2), - pci_resource_start(devp, 3)); -#endif - /* * We have all resources from the board, so lets setup the actual * board structure now. @@ -4557,7 +4079,7 @@ static int stli_initpcibrd(int brdtype, struct pci_dev *devp) brdp->memaddr = pci_resource_start(devp, 2); stli_brdinit(brdp); - return(0); + return 0; } /*****************************************************************************/ @@ -4569,20 +4091,12 @@ static int stli_initpcibrd(int brdtype, struct pci_dev *devp) static int stli_findpcibrds(void) { - struct pci_dev *dev = NULL; - int rc; - -#ifdef DEBUG - printk("stli_findpcibrds()\n"); -#endif + struct pci_dev *dev = NULL; - while ((dev = pci_find_device(PCI_VENDOR_ID_STALLION, - PCI_DEVICE_ID_ECRA, dev))) { - if ((rc = stli_initpcibrd(BRD_ECPPCI, dev))) - return(rc); + while ((dev = pci_get_device(PCI_VENDOR_ID_STALLION, PCI_DEVICE_ID_ECRA, dev))) { + stli_initpcibrd(BRD_ECPPCI, dev); } - - return(0); + return 0; } #endif @@ -4595,17 +4109,16 @@ static int stli_findpcibrds(void) static stlibrd_t *stli_allocbrd(void) { - stlibrd_t *brdp; + stlibrd_t *brdp; brdp = kzalloc(sizeof(stlibrd_t), GFP_KERNEL); if (!brdp) { printk(KERN_ERR "STALLION: failed to allocate memory " - "(size=%d)\n", sizeof(stlibrd_t)); + "(size=%Zd)\n", sizeof(stlibrd_t)); return NULL; } - brdp->magic = STLI_BOARDMAGIC; - return(brdp); + return brdp; } /*****************************************************************************/ @@ -4617,13 +4130,9 @@ static stlibrd_t *stli_allocbrd(void) static int stli_initbrds(void) { - stlibrd_t *brdp, *nxtbrdp; - stlconf_t *confp; - int i, j; - -#ifdef DEBUG - printk(KERN_DEBUG "stli_initbrds()\n"); -#endif + stlibrd_t *brdp, *nxtbrdp; + stlconf_t *confp; + int i, j; if (stli_nrbrds > STL_MAXBRDS) { printk(KERN_INFO "STALLION: too many boards in configuration " @@ -4638,11 +4147,9 @@ static int stli_initbrds(void) */ for (i = 0; (i < stli_nrbrds); i++) { confp = &stli_brdconf[i]; -#ifdef MODULE stli_parsebrd(confp, stli_brdsp[i]); -#endif - if ((brdp = stli_allocbrd()) == (stlibrd_t *) NULL) - return(-ENOMEM); + if ((brdp = stli_allocbrd()) == NULL) + return -ENOMEM; brdp->brdnr = i; brdp->brdtype = confp->brdtype; brdp->iobase = confp->ioaddr1; @@ -4654,9 +4161,7 @@ static int stli_initbrds(void) * Static configuration table done, so now use dynamic methods to * see if any more boards should be configured. */ -#ifdef MODULE stli_argbrds(); -#endif if (STLI_EISAPROBE) stli_findeisabrds(); #ifdef CONFIG_PCI @@ -4672,11 +4177,11 @@ static int stli_initbrds(void) if (stli_nrbrds > 1) { for (i = 0; (i < stli_nrbrds); i++) { brdp = stli_brds[i]; - if (brdp == (stlibrd_t *) NULL) + if (brdp == NULL) continue; for (j = i + 1; (j < stli_nrbrds); j++) { nxtbrdp = stli_brds[j]; - if (nxtbrdp == (stlibrd_t *) NULL) + if (nxtbrdp == NULL) continue; if ((brdp->membase >= nxtbrdp->membase) && (brdp->membase <= (nxtbrdp->membase + @@ -4691,7 +4196,7 @@ static int stli_initbrds(void) if (stli_shared == 0) { for (i = 0; (i < stli_nrbrds); i++) { brdp = stli_brds[i]; - if (brdp == (stlibrd_t *) NULL) + if (brdp == NULL) continue; if (brdp->state & BST_FOUND) { EBRDENABLE(brdp); @@ -4701,7 +4206,7 @@ static int stli_initbrds(void) } } - return(0); + return 0; } /*****************************************************************************/ @@ -4714,48 +4219,55 @@ static int stli_initbrds(void) static ssize_t stli_memread(struct file *fp, char __user *buf, size_t count, loff_t *offp) { - unsigned long flags; - void *memptr; - stlibrd_t *brdp; - int brdnr, size, n; - -#ifdef DEBUG - printk(KERN_DEBUG "stli_memread(fp=%x,buf=%x,count=%x,offp=%x)\n", - (int) fp, (int) buf, count, (int) offp); -#endif + unsigned long flags; + void *memptr; + stlibrd_t *brdp; + int brdnr, size, n; + void *p; + loff_t off = *offp; brdnr = iminor(fp->f_dentry->d_inode); if (brdnr >= stli_nrbrds) - return(-ENODEV); + return -ENODEV; brdp = stli_brds[brdnr]; - if (brdp == (stlibrd_t *) NULL) - return(-ENODEV); + if (brdp == NULL) + return -ENODEV; if (brdp->state == 0) - return(-ENODEV); - if (fp->f_pos >= brdp->memsize) - return(0); + return -ENODEV; + if (off >= brdp->memsize || off + count < off) + return 0; - size = MIN(count, (brdp->memsize - fp->f_pos)); + size = MIN(count, (brdp->memsize - off)); + + /* + * Copy the data a page at a time + */ + + p = (void *)__get_free_page(GFP_KERNEL); + if(p == NULL) + return -ENOMEM; - save_flags(flags); - cli(); - EBRDENABLE(brdp); while (size > 0) { - memptr = (void *) EBRDGETMEMPTR(brdp, fp->f_pos); - n = MIN(size, (brdp->pagesize - (((unsigned long) fp->f_pos) % brdp->pagesize))); - if (copy_to_user(buf, memptr, n)) { + spin_lock_irqsave(&brd_lock, flags); + EBRDENABLE(brdp); + memptr = (void *) EBRDGETMEMPTR(brdp, off); + n = MIN(size, (brdp->pagesize - (((unsigned long) off) % brdp->pagesize))); + n = MIN(n, PAGE_SIZE); + memcpy_fromio(p, memptr, n); + EBRDDISABLE(brdp); + spin_unlock_irqrestore(&brd_lock, flags); + if (copy_to_user(buf, p, n)) { count = -EFAULT; goto out; } - fp->f_pos += n; + off += n; buf += n; size -= n; } out: - EBRDDISABLE(brdp); - restore_flags(flags); - - return(count); + *offp = off; + free_page((unsigned long)p); + return count; } /*****************************************************************************/ @@ -4764,54 +4276,65 @@ out: * Code to handle an "staliomem" write operation. This device is the * contents of the board shared memory. It is used for down loading * the slave image (and debugging :-) + * + * FIXME: copy under lock */ static ssize_t stli_memwrite(struct file *fp, const char __user *buf, size_t count, loff_t *offp) { - unsigned long flags; - void *memptr; - stlibrd_t *brdp; - char __user *chbuf; - int brdnr, size, n; - -#ifdef DEBUG - printk(KERN_DEBUG "stli_memwrite(fp=%x,buf=%x,count=%x,offp=%x)\n", - (int) fp, (int) buf, count, (int) offp); -#endif + unsigned long flags; + void *memptr; + stlibrd_t *brdp; + char __user *chbuf; + int brdnr, size, n; + void *p; + loff_t off = *offp; brdnr = iminor(fp->f_dentry->d_inode); + if (brdnr >= stli_nrbrds) - return(-ENODEV); + return -ENODEV; brdp = stli_brds[brdnr]; - if (brdp == (stlibrd_t *) NULL) - return(-ENODEV); + if (brdp == NULL) + return -ENODEV; if (brdp->state == 0) - return(-ENODEV); - if (fp->f_pos >= brdp->memsize) - return(0); + return -ENODEV; + if (off >= brdp->memsize || off + count < off) + return 0; chbuf = (char __user *) buf; - size = MIN(count, (brdp->memsize - fp->f_pos)); + size = MIN(count, (brdp->memsize - off)); + + /* + * Copy the data a page at a time + */ + + p = (void *)__get_free_page(GFP_KERNEL); + if(p == NULL) + return -ENOMEM; - save_flags(flags); - cli(); - EBRDENABLE(brdp); while (size > 0) { - memptr = (void *) EBRDGETMEMPTR(brdp, fp->f_pos); - n = MIN(size, (brdp->pagesize - (((unsigned long) fp->f_pos) % brdp->pagesize))); - if (copy_from_user(memptr, chbuf, n)) { - count = -EFAULT; + n = MIN(size, (brdp->pagesize - (((unsigned long) off) % brdp->pagesize))); + n = MIN(n, PAGE_SIZE); + if (copy_from_user(p, chbuf, n)) { + if (count == 0) + count = -EFAULT; goto out; } - fp->f_pos += n; + spin_lock_irqsave(&brd_lock, flags); + EBRDENABLE(brdp); + memptr = (void *) EBRDGETMEMPTR(brdp, off); + memcpy_toio(memptr, p, n); + EBRDDISABLE(brdp); + spin_unlock_irqrestore(&brd_lock, flags); + off += n; chbuf += n; size -= n; } out: - EBRDDISABLE(brdp); - restore_flags(flags); - - return(count); + free_page((unsigned long) p); + *offp = off; + return count; } /*****************************************************************************/ @@ -4822,16 +4345,16 @@ out: static int stli_getbrdstats(combrd_t __user *bp) { - stlibrd_t *brdp; - int i; + stlibrd_t *brdp; + int i; if (copy_from_user(&stli_brdstats, bp, sizeof(combrd_t))) return -EFAULT; if (stli_brdstats.brd >= STL_MAXBRDS) - return(-ENODEV); + return -ENODEV; brdp = stli_brds[stli_brdstats.brd]; - if (brdp == (stlibrd_t *) NULL) - return(-ENODEV); + if (brdp == NULL) + return -ENODEV; memset(&stli_brdstats, 0, sizeof(combrd_t)); stli_brdstats.brd = brdp->brdnr; @@ -4850,7 +4373,7 @@ static int stli_getbrdstats(combrd_t __user *bp) if (copy_to_user(bp, &stli_brdstats, sizeof(combrd_t))) return -EFAULT; - return(0); + return 0; } /*****************************************************************************/ @@ -4861,19 +4384,19 @@ static int stli_getbrdstats(combrd_t __user *bp) static stliport_t *stli_getport(int brdnr, int panelnr, int portnr) { - stlibrd_t *brdp; - int i; + stlibrd_t *brdp; + int i; - if ((brdnr < 0) || (brdnr >= STL_MAXBRDS)) - return((stliport_t *) NULL); + if (brdnr < 0 || brdnr >= STL_MAXBRDS) + return NULL; brdp = stli_brds[brdnr]; - if (brdp == (stlibrd_t *) NULL) - return((stliport_t *) NULL); + if (brdp == NULL) + return NULL; for (i = 0; (i < panelnr); i++) portnr += brdp->panels[i]; if ((portnr < 0) || (portnr >= brdp->nrports)) - return((stliport_t *) NULL); - return(brdp->ports[portnr]); + return NULL; + return brdp->ports[portnr]; } /*****************************************************************************/ @@ -4892,16 +4415,16 @@ static int stli_portcmdstats(stliport_t *portp) memset(&stli_comstats, 0, sizeof(comstats_t)); - if (portp == (stliport_t *) NULL) - return(-ENODEV); + if (portp == NULL) + return -ENODEV; brdp = stli_brds[portp->brdnr]; - if (brdp == (stlibrd_t *) NULL) - return(-ENODEV); + if (brdp == NULL) + return -ENODEV; if (brdp->state & BST_STARTED) { if ((rc = stli_cmdwait(brdp, portp, A_GETSTATS, &stli_cdkstats, sizeof(asystats_t), 1)) < 0) - return(rc); + return rc; } else { memset(&stli_cdkstats, 0, sizeof(asystats_t)); } @@ -4912,13 +4435,12 @@ static int stli_portcmdstats(stliport_t *portp) stli_comstats.state = portp->state; stli_comstats.flags = portp->flags; - save_flags(flags); - cli(); - if (portp->tty != (struct tty_struct *) NULL) { + spin_lock_irqsave(&brd_lock, flags); + if (portp->tty != NULL) { if (portp->tty->driver_data == portp) { stli_comstats.ttystate = portp->tty->flags; - stli_comstats.rxbuffered = -1 /*portp->tty->flip.count*/; - if (portp->tty->termios != (struct termios *) NULL) { + stli_comstats.rxbuffered = -1; + if (portp->tty->termios != NULL) { stli_comstats.cflags = portp->tty->termios->c_cflag; stli_comstats.iflags = portp->tty->termios->c_iflag; stli_comstats.oflags = portp->tty->termios->c_oflag; @@ -4926,7 +4448,7 @@ static int stli_portcmdstats(stliport_t *portp) } } } - restore_flags(flags); + spin_unlock_irqrestore(&brd_lock, flags); stli_comstats.txtotal = stli_cdkstats.txchars; stli_comstats.rxtotal = stli_cdkstats.rxchars + stli_cdkstats.ringover; @@ -4948,7 +4470,7 @@ static int stli_portcmdstats(stliport_t *portp) stli_comstats.hwid = stli_cdkstats.hwid; stli_comstats.signals = stli_mktiocm(stli_cdkstats.signals); - return(0); + return 0; } /*****************************************************************************/ @@ -4961,8 +4483,8 @@ static int stli_portcmdstats(stliport_t *portp) static int stli_getportstats(stliport_t *portp, comstats_t __user *cp) { - stlibrd_t *brdp; - int rc; + stlibrd_t *brdp; + int rc; if (!portp) { if (copy_from_user(&stli_comstats, cp, sizeof(comstats_t))) @@ -4992,8 +4514,8 @@ static int stli_getportstats(stliport_t *portp, comstats_t __user *cp) static int stli_clrportstats(stliport_t *portp, comstats_t __user *cp) { - stlibrd_t *brdp; - int rc; + stlibrd_t *brdp; + int rc; if (!portp) { if (copy_from_user(&stli_comstats, cp, sizeof(comstats_t))) @@ -5031,7 +4553,7 @@ static int stli_clrportstats(stliport_t *portp, comstats_t __user *cp) static int stli_getportstruct(stliport_t __user *arg) { - stliport_t *portp; + stliport_t *portp; if (copy_from_user(&stli_dummyport, arg, sizeof(stliport_t))) return -EFAULT; @@ -5052,7 +4574,7 @@ static int stli_getportstruct(stliport_t __user *arg) static int stli_getbrdstruct(stlibrd_t __user *arg) { - stlibrd_t *brdp; + stlibrd_t *brdp; if (copy_from_user(&stli_dummybrd, arg, sizeof(stlibrd_t))) return -EFAULT; @@ -5076,15 +4598,10 @@ static int stli_getbrdstruct(stlibrd_t __user *arg) static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, unsigned long arg) { - stlibrd_t *brdp; - int brdnr, rc, done; + stlibrd_t *brdp; + int brdnr, rc, done; void __user *argp = (void __user *)arg; -#ifdef DEBUG - printk(KERN_DEBUG "stli_memioctl(ip=%x,fp=%x,cmd=%x,arg=%x)\n", - (int) ip, (int) fp, cmd, (int) arg); -#endif - /* * First up handle the board independent ioctls. */ @@ -5115,7 +4632,7 @@ static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, un } if (done) - return(rc); + return rc; /* * Now handle the board specific ioctls. These all depend on the @@ -5123,12 +4640,12 @@ static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, un */ brdnr = iminor(ip); if (brdnr >= STL_MAXBRDS) - return(-ENODEV); + return -ENODEV; brdp = stli_brds[brdnr]; if (!brdp) - return(-ENODEV); + return -ENODEV; if (brdp->state == 0) - return(-ENODEV); + return -ENODEV; switch (cmd) { case STL_BINTR: @@ -5152,8 +4669,7 @@ static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, un rc = -ENOIOCTLCMD; break; } - - return(rc); + return rc; } static struct tty_operations stli_ops = { @@ -5187,6 +4703,9 @@ int __init stli_init(void) int i; printk(KERN_INFO "%s: version %s\n", stli_drvtitle, stli_drvversion); + spin_lock_init(&stli_lock); + spin_lock_init(&brd_lock); + stli_initbrds(); stli_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS); @@ -5196,10 +4715,6 @@ int __init stli_init(void) /* * Allocate a temporary write buffer. */ - stli_tmpwritebuf = kmalloc(STLI_TXBUFSIZE, GFP_KERNEL); - if (!stli_tmpwritebuf) - printk(KERN_ERR "STALLION: failed to allocate memory " - "(size=%d)\n", STLI_TXBUFSIZE); stli_txcookbuf = kmalloc(STLI_TXBUFSIZE, GFP_KERNEL); if (!stli_txcookbuf) printk(KERN_ERR "STALLION: failed to allocate memory " @@ -5243,7 +4758,7 @@ int __init stli_init(void) printk(KERN_ERR "STALLION: failed to register serial driver\n"); return -EBUSY; } - return(0); + return 0; } /*****************************************************************************/ -- cgit v1.2.3-70-g09d2 From 409035e088ce15178c5aa157cab493bc22096b6d Mon Sep 17 00:00:00 2001 From: Corey Minyard Date: Wed, 28 Jun 2006 04:26:53 -0700 Subject: [PATCH] IPMI: tidy msghandler timer Tidy up the timer usage in the IPMI driver. Signed-off-by: Corey Minyard Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/ipmi/ipmi_msghandler.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c index 83ed6ae466a..ad26f4b997c 100644 --- a/drivers/char/ipmi/ipmi_msghandler.c +++ b/drivers/char/ipmi/ipmi_msghandler.c @@ -3738,11 +3738,8 @@ static int ipmi_init_msghandler(void) proc_ipmi_root->owner = THIS_MODULE; #endif /* CONFIG_PROC_FS */ - init_timer(&ipmi_timer); - ipmi_timer.data = 0; - ipmi_timer.function = ipmi_timeout; - ipmi_timer.expires = jiffies + IPMI_TIMEOUT_JIFFIES; - add_timer(&ipmi_timer); + setup_timer(&ipmi_timer, ipmi_timeout, 0); + mod_timer(&ipmi_timer, jiffies + IPMI_TIMEOUT_JIFFIES); atomic_notifier_chain_register(&panic_notifier_list, &panic_block); -- cgit v1.2.3-70-g09d2 From 1a245866f8a417250c0f82b16f7a6dcf0b812f58 Mon Sep 17 00:00:00 2001 From: Corey Minyard Date: Wed, 28 Jun 2006 04:26:54 -0700 Subject: [PATCH] IPMI: remove high res timer code There was some old high-res-timer code in the IPMI driver that is dead. Remove it. Signed-off-by: Corey Minyard Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/ipmi/ipmi_si_intf.c | 67 ---------------------------------------- 1 file changed, 67 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index 101c14b9b26..bd4f2248b75 100644 --- a/drivers/char/ipmi/ipmi_si_intf.c +++ b/drivers/char/ipmi/ipmi_si_intf.c @@ -55,23 +55,6 @@ #include #include #include -#ifdef CONFIG_HIGH_RES_TIMERS -#include -# if defined(schedule_next_int) -/* Old high-res timer code, do translations. */ -# define get_arch_cycles(a) quick_update_jiffies_sub(a) -# define arch_cycles_per_jiffy cycles_per_jiffies -# endif -static inline void add_usec_to_timer(struct timer_list *t, long v) -{ - t->arch_cycle_expires += nsec_to_arch_cycle(v * 1000); - while (t->arch_cycle_expires >= arch_cycles_per_jiffy) - { - t->expires++; - t->arch_cycle_expires -= arch_cycles_per_jiffy; - } -} -#endif #include #include #include @@ -243,8 +226,6 @@ static int register_xaction_notifier(struct notifier_block * nb) return atomic_notifier_chain_register(&xaction_notifier_list, nb); } -static void si_restart_short_timer(struct smi_info *smi_info); - static void deliver_recv_msg(struct smi_info *smi_info, struct ipmi_smi_msg *msg) { @@ -768,7 +749,6 @@ static void sender(void *send_info, && (smi_info->curr_msg == NULL)) { start_next_msg(smi_info); - si_restart_short_timer(smi_info); } spin_unlock_irqrestore(&(smi_info->si_lock), flags); } @@ -833,37 +813,6 @@ static void request_events(void *send_info) static int initialized = 0; -/* Must be called with interrupts off and with the si_lock held. */ -static void si_restart_short_timer(struct smi_info *smi_info) -{ -#if defined(CONFIG_HIGH_RES_TIMERS) - unsigned long flags; - unsigned long jiffies_now; - unsigned long seq; - - if (del_timer(&(smi_info->si_timer))) { - /* If we don't delete the timer, then it will go off - immediately, anyway. So we only process if we - actually delete the timer. */ - - do { - seq = read_seqbegin_irqsave(&xtime_lock, flags); - jiffies_now = jiffies; - smi_info->si_timer.expires = jiffies_now; - smi_info->si_timer.arch_cycle_expires - = get_arch_cycles(jiffies_now); - } while (read_seqretry_irqrestore(&xtime_lock, seq, flags)); - - add_usec_to_timer(&smi_info->si_timer, SI_SHORT_TIMEOUT_USEC); - - add_timer(&(smi_info->si_timer)); - spin_lock_irqsave(&smi_info->count_lock, flags); - smi_info->timeout_restarts++; - spin_unlock_irqrestore(&smi_info->count_lock, flags); - } -#endif -} - static void smi_timeout(unsigned long data) { struct smi_info *smi_info = (struct smi_info *) data; @@ -904,31 +853,15 @@ static void smi_timeout(unsigned long data) /* If the state machine asks for a short delay, then shorten the timer timeout. */ if (smi_result == SI_SM_CALL_WITH_DELAY) { -#if defined(CONFIG_HIGH_RES_TIMERS) - unsigned long seq; -#endif spin_lock_irqsave(&smi_info->count_lock, flags); smi_info->short_timeouts++; spin_unlock_irqrestore(&smi_info->count_lock, flags); -#if defined(CONFIG_HIGH_RES_TIMERS) - do { - seq = read_seqbegin_irqsave(&xtime_lock, flags); - smi_info->si_timer.expires = jiffies; - smi_info->si_timer.arch_cycle_expires - = get_arch_cycles(smi_info->si_timer.expires); - } while (read_seqretry_irqrestore(&xtime_lock, seq, flags)); - add_usec_to_timer(&smi_info->si_timer, SI_SHORT_TIMEOUT_USEC); -#else smi_info->si_timer.expires = jiffies + 1; -#endif } else { spin_lock_irqsave(&smi_info->count_lock, flags); smi_info->long_timeouts++; spin_unlock_irqrestore(&smi_info->count_lock, flags); smi_info->si_timer.expires = jiffies + SI_TIMEOUT_JIFFIES; -#if defined(CONFIG_HIGH_RES_TIMERS) - smi_info->si_timer.arch_cycle_expires = 0; -#endif } do_add_timer: -- cgit v1.2.3-70-g09d2 From 96febe9fb7b04f2a078882d08bd6a997dee7cfa3 Mon Sep 17 00:00:00 2001 From: Corey Minyard Date: Wed, 28 Jun 2006 04:26:55 -0700 Subject: [PATCH] IPMI: watchdog handle panic properly Modify the watchdog timeout in IPMI to only do things at panic/reboot time if the watchdog timer was already running. Some BIOSes do not disable the watchdog timer at startup, and this led to a reboot a while later if the new OS running didn't start monitoring the watchdog, even if the watchdog was not running before. Signed-off-by: Corey Minyard Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/ipmi/ipmi_watchdog.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c index 8f886717097..1a0a19c5360 100644 --- a/drivers/char/ipmi/ipmi_watchdog.c +++ b/drivers/char/ipmi/ipmi_watchdog.c @@ -949,9 +949,10 @@ static int wdog_reboot_handler(struct notifier_block *this, /* Disable the WDT if we are shutting down. */ ipmi_watchdog_state = WDOG_TIMEOUT_NONE; panic_halt_ipmi_set_timeout(); - } else { + } else if (ipmi_watchdog_state != WDOG_TIMEOUT_NONE) { /* Set a long timer to let the reboot happens, but - reboot if it hangs. */ + reboot if it hangs, but only if the watchdog + timer was already running. */ timeout = 120; pretimeout = 0; ipmi_watchdog_state = WDOG_TIMEOUT_RESET; @@ -973,16 +974,17 @@ static int wdog_panic_handler(struct notifier_block *this, { static int panic_event_handled = 0; - /* On a panic, if we have a panic timeout, make sure that the thing - reboots, even if it hangs during that panic. */ - if (watchdog_user && !panic_event_handled) { - /* Make sure the panic doesn't hang, and make sure we - do this only once. */ + /* On a panic, if we have a panic timeout, make sure to extend + the watchdog timer to a reasonable value to complete the + panic, if the watchdog timer is running. Plus the + pretimeout is meaningless at panic time. */ + if (watchdog_user && !panic_event_handled && + ipmi_watchdog_state != WDOG_TIMEOUT_NONE) { + /* Make sure we do this only once. */ panic_event_handled = 1; timeout = 255; pretimeout = 0; - ipmi_watchdog_state = WDOG_TIMEOUT_RESET; panic_halt_ipmi_set_timeout(); } -- cgit v1.2.3-70-g09d2 From 699352c30da8525a6224116983dab012689a0a76 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Thu, 29 Jun 2006 02:24:32 -0700 Subject: [PATCH] GPIO for SCx200 & PC-8736x: x86-only AFAICT, this is x86 only, so the patch below is needed to stop this new option showing up on PPC, IA64, etc.. Signed-off-by: Dave Jones Cc: Jim Cromie Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/Kconfig | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/char') diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index 410d70cb76f..c40e487d9f5 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -961,6 +961,7 @@ config PC8736x_GPIO config NSC_GPIO tristate "NatSemi Base GPIO Support" + depends on X86_32 # selected by SCx200_GPIO and PC8736x_GPIO # what about 2 selectors differing: m != y help -- cgit v1.2.3-70-g09d2 From d1bef4ed5faf7d9872337b33c4269e45ae1bf960 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Thu, 29 Jun 2006 02:24:36 -0700 Subject: [PATCH] genirq: rename desc->handler to desc->chip This patch-queue improves the generic IRQ layer to be truly generic, by adding various abstractions and features to it, without impacting existing functionality. While the queue can be best described as "fix and improve everything in the generic IRQ layer that we could think of", and thus it consists of many smaller features and lots of cleanups, the one feature that stands out most is the new 'irq chip' abstraction. The irq-chip abstraction is about describing and coding and IRQ controller driver by mapping its raw hardware capabilities [and quirks, if needed] in a straightforward way, without having to think about "IRQ flow" (level/edge/etc.) type of details. This stands in contrast with the current 'irq-type' model of genirq architectures, which 'mixes' raw hardware capabilities with 'flow' details. The patchset supports both types of irq controller designs at once, and converts i386 and x86_64 to the new irq-chip design. As a bonus side-effect of the irq-chip approach, chained interrupt controllers (master/slave PIC constructs, etc.) are now supported by design as well. The end result of this patchset intends to be simpler architecture-level code and more consolidation between architectures. We reused many bits of code and many concepts from Russell King's ARM IRQ layer, the merging of which was one of the motivations for this patchset. This patch: rename desc->handler to desc->chip. Originally i did not want to do this, because it's a big patch. But having both "desc->handler", "desc->handle_irq" and "action->handler" caused a large degree of confusion and made the code appear alot less clean than it truly is. I have also attempted a dual approach as well by introducing a desc->chip alias - but that just wasnt robust enough and broke frequently. So lets get over with this quickly. The conversion was done automatically via scripts and converts all the code in the kernel. This renaming patch is the first one amongst the patches, so that the remaining patches can stay flexible and can be merged and split up without having some big monolithic patch act as a merge barrier. [akpm@osdl.org: build fix] [akpm@osdl.org: another build fix] Signed-off-by: Ingo Molnar Signed-off-by: Thomas Gleixner Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/alpha/kernel/irq.c | 6 ++--- arch/alpha/kernel/irq_alpha.c | 2 +- arch/alpha/kernel/irq_i8259.c | 2 +- arch/alpha/kernel/irq_pyxis.c | 2 +- arch/alpha/kernel/irq_srm.c | 2 +- arch/alpha/kernel/sys_alcor.c | 2 +- arch/alpha/kernel/sys_cabriolet.c | 2 +- arch/alpha/kernel/sys_dp264.c | 2 +- arch/alpha/kernel/sys_eb64p.c | 2 +- arch/alpha/kernel/sys_eiger.c | 2 +- arch/alpha/kernel/sys_jensen.c | 10 ++++---- arch/alpha/kernel/sys_marvel.c | 6 ++--- arch/alpha/kernel/sys_mikasa.c | 2 +- arch/alpha/kernel/sys_noritake.c | 2 +- arch/alpha/kernel/sys_rawhide.c | 2 +- arch/alpha/kernel/sys_rx164.c | 2 +- arch/alpha/kernel/sys_sable.c | 2 +- arch/alpha/kernel/sys_takara.c | 2 +- arch/alpha/kernel/sys_titan.c | 2 +- arch/alpha/kernel/sys_wildfire.c | 6 ++--- arch/cris/arch-v10/kernel/irq.c | 2 +- arch/cris/arch-v32/kernel/irq.c | 2 +- arch/cris/kernel/irq.c | 2 +- arch/i386/kernel/i8259.c | 6 ++--- arch/i386/kernel/io_apic.c | 16 +++++++------ arch/i386/kernel/irq.c | 6 ++--- arch/i386/mach-visws/visws_apic.c | 12 +++++----- arch/i386/mach-voyager/voyager_smp.c | 2 +- arch/ia64/kernel/iosapic.c | 10 ++++---- arch/ia64/kernel/irq.c | 18 +++++++------- arch/ia64/kernel/irq_ia64.c | 2 +- arch/ia64/kernel/smpboot.c | 6 ++--- arch/ia64/sn/kernel/irq.c | 4 ++-- arch/m32r/kernel/irq.c | 2 +- arch/m32r/kernel/setup_m32104ut.c | 8 +++---- arch/m32r/kernel/setup_m32700ut.c | 28 +++++++++++----------- arch/m32r/kernel/setup_mappi.c | 16 ++++++------- arch/m32r/kernel/setup_mappi2.c | 20 ++++++++-------- arch/m32r/kernel/setup_mappi3.c | 20 ++++++++-------- arch/m32r/kernel/setup_oaks32r.c | 12 +++++----- arch/m32r/kernel/setup_opsput.c | 28 +++++++++++----------- arch/m32r/kernel/setup_usrv.c | 18 +++++++------- arch/mips/au1000/common/irq.c | 20 ++++++++-------- arch/mips/au1000/pb1200/irqmap.c | 2 +- arch/mips/ddb5xxx/ddb5477/irq_5477.c | 2 +- arch/mips/dec/ioasic-irq.c | 4 ++-- arch/mips/dec/kn02-irq.c | 2 +- arch/mips/gt64120/ev64120/irq.c | 2 +- arch/mips/ite-boards/generic/irq.c | 4 ++-- arch/mips/jazz/irq.c | 2 +- arch/mips/jmr3927/rbhma3100/irq.c | 2 +- arch/mips/kernel/i8259.c | 4 ++-- arch/mips/kernel/irq-msc01.c | 4 ++-- arch/mips/kernel/irq-mv6434x.c | 2 +- arch/mips/kernel/irq-rm7000.c | 2 +- arch/mips/kernel/irq-rm9000.c | 4 ++-- arch/mips/kernel/irq.c | 4 ++-- arch/mips/kernel/irq_cpu.c | 4 ++-- arch/mips/lasat/interrupt.c | 2 +- arch/mips/mips-boards/atlas/atlas_int.c | 2 +- arch/mips/momentum/ocelot_c/cpci-irq.c | 2 +- arch/mips/momentum/ocelot_c/uart-irq.c | 4 ++-- arch/mips/philips/pnx8550/common/int.c | 10 ++++---- arch/mips/sgi-ip22/ip22-eisa.c | 4 ++-- arch/mips/sgi-ip22/ip22-int.c | 2 +- arch/mips/sgi-ip27/ip27-irq.c | 2 +- arch/mips/sgi-ip32/ip32-irq.c | 2 +- arch/mips/sibyte/bcm1480/irq.c | 4 ++-- arch/mips/sibyte/sb1250/irq.c | 4 ++-- arch/mips/sni/irq.c | 2 +- arch/mips/tx4927/common/tx4927_irq.c | 4 ++-- .../tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c | 14 +++++------ arch/mips/tx4938/common/irq.c | 4 ++-- arch/mips/tx4938/toshiba_rbtx4938/irq.c | 2 +- arch/mips/vr41xx/common/icu.c | 4 ++-- arch/mips/vr41xx/common/irq.c | 4 ++-- arch/mips/vr41xx/common/vrc4173.c | 2 +- arch/mips/vr41xx/nec-cmbvr4133/irq.c | 2 +- arch/parisc/kernel/irq.c | 10 ++++---- arch/powerpc/kernel/crash.c | 4 ++-- arch/powerpc/kernel/irq.c | 8 +++---- arch/powerpc/platforms/cell/interrupt.c | 4 ++-- arch/powerpc/platforms/cell/spider-pic.c | 4 ++-- arch/powerpc/platforms/iseries/irq.c | 6 ++--- arch/powerpc/platforms/powermac/pic.c | 4 ++-- arch/powerpc/platforms/pseries/xics.c | 8 +++---- arch/powerpc/sysdev/i8259.c | 2 +- arch/powerpc/sysdev/ipic.c | 2 +- arch/powerpc/sysdev/mpic.c | 8 +++---- arch/ppc/8xx_io/commproc.c | 2 +- arch/ppc/platforms/apus_setup.c | 4 ++-- arch/ppc/platforms/sbc82xx.c | 2 +- arch/ppc/syslib/cpc700_pic.c | 4 ++-- arch/ppc/syslib/cpm2_pic.c | 2 +- arch/ppc/syslib/gt64260_pic.c | 2 +- arch/ppc/syslib/m82xx_pci.c | 2 +- arch/ppc/syslib/m8xx_setup.c | 4 ++-- arch/ppc/syslib/mpc52xx_pic.c | 4 ++-- arch/ppc/syslib/mv64360_pic.c | 2 +- arch/ppc/syslib/open_pic.c | 4 ++-- arch/ppc/syslib/open_pic2.c | 2 +- arch/ppc/syslib/ppc403_pic.c | 2 +- arch/ppc/syslib/ppc4xx_pic.c | 2 +- arch/ppc/syslib/xilinx_pic.c | 2 +- arch/sh/boards/adx/irq_maskreg.c | 2 +- arch/sh/boards/bigsur/irq.c | 4 ++-- arch/sh/boards/cqreek/irq.c | 4 ++-- arch/sh/boards/dreamcast/setup.c | 2 +- arch/sh/boards/ec3104/setup.c | 2 +- arch/sh/boards/harp/irq.c | 2 +- arch/sh/boards/mpc1211/setup.c | 2 +- arch/sh/boards/overdrive/irq.c | 2 +- arch/sh/boards/renesas/hs7751rvoip/irq.c | 2 +- arch/sh/boards/renesas/rts7751r2d/irq.c | 2 +- arch/sh/boards/renesas/systemh/irq.c | 2 +- arch/sh/boards/se/73180/irq.c | 2 +- arch/sh/boards/superh/microdev/irq.c | 2 +- arch/sh/cchips/hd6446x/hd64461/setup.c | 2 +- arch/sh/cchips/hd6446x/hd64465/setup.c | 2 +- arch/sh/cchips/voyagergx/irq.c | 2 +- arch/sh/kernel/cpu/irq/imask.c | 2 +- arch/sh/kernel/cpu/irq/intc2.c | 2 +- arch/sh/kernel/cpu/irq/ipr.c | 2 +- arch/sh/kernel/cpu/irq/pint.c | 2 +- arch/sh/kernel/irq.c | 2 +- arch/sh64/kernel/irq.c | 2 +- arch/sh64/kernel/irq_intc.c | 4 ++-- arch/sh64/mach-cayman/irq.c | 2 +- arch/sparc64/kernel/irq.c | 10 ++++---- arch/um/kernel/irq.c | 6 ++--- arch/v850/kernel/irq.c | 6 ++--- arch/x86_64/kernel/i8259.c | 6 ++--- arch/x86_64/kernel/io_apic.c | 16 +++++++------ arch/x86_64/kernel/irq.c | 6 ++--- arch/xtensa/kernel/irq.c | 4 ++-- drivers/char/vr41xx_giu.c | 4 ++-- drivers/parisc/dino.c | 4 ++-- drivers/parisc/eisa.c | 2 +- drivers/parisc/gsc.c | 8 +++---- drivers/parisc/iosapic.c | 2 +- drivers/parisc/superio.c | 2 +- drivers/pci/msi.c | 6 ++--- drivers/pcmcia/hd64465_ss.c | 6 ++--- include/asm-powerpc/hw_irq.h | 12 +++++----- include/linux/irq.h | 4 ++-- kernel/irq/autoprobe.c | 10 ++++---- kernel/irq/handle.c | 14 +++++------ kernel/irq/manage.c | 24 +++++++++---------- kernel/irq/migration.c | 8 +++---- kernel/irq/proc.c | 6 ++--- kernel/irq/spurious.c | 4 ++-- 151 files changed, 384 insertions(+), 380 deletions(-) (limited to 'drivers/char') diff --git a/arch/alpha/kernel/irq.c b/arch/alpha/kernel/irq.c index da677f829f7..ec9d243d42c 100644 --- a/arch/alpha/kernel/irq.c +++ b/arch/alpha/kernel/irq.c @@ -49,7 +49,7 @@ select_smp_affinity(unsigned int irq) static int last_cpu; int cpu = last_cpu + 1; - if (!irq_desc[irq].handler->set_affinity || irq_user_affinity[irq]) + if (!irq_desc[irq].chip->set_affinity || irq_user_affinity[irq]) return 1; while (!cpu_possible(cpu)) @@ -57,7 +57,7 @@ select_smp_affinity(unsigned int irq) last_cpu = cpu; irq_affinity[irq] = cpumask_of_cpu(cpu); - irq_desc[irq].handler->set_affinity(irq, cpumask_of_cpu(cpu)); + irq_desc[irq].chip->set_affinity(irq, cpumask_of_cpu(cpu)); return 0; } #endif /* CONFIG_SMP */ @@ -93,7 +93,7 @@ show_interrupts(struct seq_file *p, void *v) for_each_online_cpu(j) seq_printf(p, "%10u ", kstat_cpu(j).irqs[irq]); #endif - seq_printf(p, " %14s", irq_desc[irq].handler->typename); + seq_printf(p, " %14s", irq_desc[irq].chip->typename); seq_printf(p, " %c%s", (action->flags & SA_INTERRUPT)?'+':' ', action->name); diff --git a/arch/alpha/kernel/irq_alpha.c b/arch/alpha/kernel/irq_alpha.c index 9d34ce26e5e..f20f2dff9c4 100644 --- a/arch/alpha/kernel/irq_alpha.c +++ b/arch/alpha/kernel/irq_alpha.c @@ -233,7 +233,7 @@ void __init init_rtc_irq(void) { irq_desc[RTC_IRQ].status = IRQ_DISABLED; - irq_desc[RTC_IRQ].handler = &rtc_irq_type; + irq_desc[RTC_IRQ].chip = &rtc_irq_type; setup_irq(RTC_IRQ, &timer_irqaction); } diff --git a/arch/alpha/kernel/irq_i8259.c b/arch/alpha/kernel/irq_i8259.c index b188683b83f..ac893bd4803 100644 --- a/arch/alpha/kernel/irq_i8259.c +++ b/arch/alpha/kernel/irq_i8259.c @@ -109,7 +109,7 @@ init_i8259a_irqs(void) for (i = 0; i < 16; i++) { irq_desc[i].status = IRQ_DISABLED; - irq_desc[i].handler = &i8259a_irq_type; + irq_desc[i].chip = &i8259a_irq_type; } setup_irq(2, &cascade); diff --git a/arch/alpha/kernel/irq_pyxis.c b/arch/alpha/kernel/irq_pyxis.c index 146a20b9e3d..3b581415bab 100644 --- a/arch/alpha/kernel/irq_pyxis.c +++ b/arch/alpha/kernel/irq_pyxis.c @@ -120,7 +120,7 @@ init_pyxis_irqs(unsigned long ignore_mask) if ((ignore_mask >> i) & 1) continue; irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL; - irq_desc[i].handler = &pyxis_irq_type; + irq_desc[i].chip = &pyxis_irq_type; } setup_irq(16+7, &isa_cascade_irqaction); diff --git a/arch/alpha/kernel/irq_srm.c b/arch/alpha/kernel/irq_srm.c index 0a87e466918..8e4d121f84c 100644 --- a/arch/alpha/kernel/irq_srm.c +++ b/arch/alpha/kernel/irq_srm.c @@ -67,7 +67,7 @@ init_srm_irqs(long max, unsigned long ignore_mask) if (i < 64 && ((ignore_mask >> i) & 1)) continue; irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL; - irq_desc[i].handler = &srm_irq_type; + irq_desc[i].chip = &srm_irq_type; } } diff --git a/arch/alpha/kernel/sys_alcor.c b/arch/alpha/kernel/sys_alcor.c index d7f0e97fe56..1a1a2c7a3d9 100644 --- a/arch/alpha/kernel/sys_alcor.c +++ b/arch/alpha/kernel/sys_alcor.c @@ -144,7 +144,7 @@ alcor_init_irq(void) if (i >= 16+20 && i <= 16+30) continue; irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL; - irq_desc[i].handler = &alcor_irq_type; + irq_desc[i].chip = &alcor_irq_type; } i8259a_irq_type.ack = alcor_isa_mask_and_ack_irq; diff --git a/arch/alpha/kernel/sys_cabriolet.c b/arch/alpha/kernel/sys_cabriolet.c index 8e3374d34c9..8c9e443d93a 100644 --- a/arch/alpha/kernel/sys_cabriolet.c +++ b/arch/alpha/kernel/sys_cabriolet.c @@ -124,7 +124,7 @@ common_init_irq(void (*srm_dev_int)(unsigned long v, struct pt_regs *r)) for (i = 16; i < 35; ++i) { irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL; - irq_desc[i].handler = &cabriolet_irq_type; + irq_desc[i].chip = &cabriolet_irq_type; } } diff --git a/arch/alpha/kernel/sys_dp264.c b/arch/alpha/kernel/sys_dp264.c index d5da6b1b28e..b28c8f1c6e1 100644 --- a/arch/alpha/kernel/sys_dp264.c +++ b/arch/alpha/kernel/sys_dp264.c @@ -300,7 +300,7 @@ init_tsunami_irqs(struct hw_interrupt_type * ops, int imin, int imax) long i; for (i = imin; i <= imax; ++i) { irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL; - irq_desc[i].handler = ops; + irq_desc[i].chip = ops; } } diff --git a/arch/alpha/kernel/sys_eb64p.c b/arch/alpha/kernel/sys_eb64p.c index 61a79c354f0..aeb8e027790 100644 --- a/arch/alpha/kernel/sys_eb64p.c +++ b/arch/alpha/kernel/sys_eb64p.c @@ -137,7 +137,7 @@ eb64p_init_irq(void) for (i = 16; i < 32; ++i) { irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL; - irq_desc[i].handler = &eb64p_irq_type; + irq_desc[i].chip = &eb64p_irq_type; } common_init_isa_dma(); diff --git a/arch/alpha/kernel/sys_eiger.c b/arch/alpha/kernel/sys_eiger.c index bd6e5f0e43c..64a785baf53 100644 --- a/arch/alpha/kernel/sys_eiger.c +++ b/arch/alpha/kernel/sys_eiger.c @@ -154,7 +154,7 @@ eiger_init_irq(void) for (i = 16; i < 128; ++i) { irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL; - irq_desc[i].handler = &eiger_irq_type; + irq_desc[i].chip = &eiger_irq_type; } } diff --git a/arch/alpha/kernel/sys_jensen.c b/arch/alpha/kernel/sys_jensen.c index fcabb7c96a1..0148e095638 100644 --- a/arch/alpha/kernel/sys_jensen.c +++ b/arch/alpha/kernel/sys_jensen.c @@ -206,11 +206,11 @@ jensen_init_irq(void) { init_i8259a_irqs(); - irq_desc[1].handler = &jensen_local_irq_type; - irq_desc[4].handler = &jensen_local_irq_type; - irq_desc[3].handler = &jensen_local_irq_type; - irq_desc[7].handler = &jensen_local_irq_type; - irq_desc[9].handler = &jensen_local_irq_type; + irq_desc[1].chip = &jensen_local_irq_type; + irq_desc[4].chip = &jensen_local_irq_type; + irq_desc[3].chip = &jensen_local_irq_type; + irq_desc[7].chip = &jensen_local_irq_type; + irq_desc[9].chip = &jensen_local_irq_type; common_init_isa_dma(); } diff --git a/arch/alpha/kernel/sys_marvel.c b/arch/alpha/kernel/sys_marvel.c index e32fee50522..36d21595437 100644 --- a/arch/alpha/kernel/sys_marvel.c +++ b/arch/alpha/kernel/sys_marvel.c @@ -303,7 +303,7 @@ init_io7_irqs(struct io7 *io7, /* Set up the lsi irqs. */ for (i = 0; i < 128; ++i) { irq_desc[base + i].status = IRQ_DISABLED | IRQ_LEVEL; - irq_desc[base + i].handler = lsi_ops; + irq_desc[base + i].chip = lsi_ops; } /* Disable the implemented irqs in hardware. */ @@ -317,7 +317,7 @@ init_io7_irqs(struct io7 *io7, /* Set up the msi irqs. */ for (i = 128; i < (128 + 512); ++i) { irq_desc[base + i].status = IRQ_DISABLED | IRQ_LEVEL; - irq_desc[base + i].handler = msi_ops; + irq_desc[base + i].chip = msi_ops; } for (i = 0; i < 16; ++i) @@ -335,7 +335,7 @@ marvel_init_irq(void) /* Reserve the legacy irqs. */ for (i = 0; i < 16; ++i) { irq_desc[i].status = IRQ_DISABLED; - irq_desc[i].handler = &marvel_legacy_irq_type; + irq_desc[i].chip = &marvel_legacy_irq_type; } /* Init the io7 irqs. */ diff --git a/arch/alpha/kernel/sys_mikasa.c b/arch/alpha/kernel/sys_mikasa.c index d78a0daa616..b741600e376 100644 --- a/arch/alpha/kernel/sys_mikasa.c +++ b/arch/alpha/kernel/sys_mikasa.c @@ -117,7 +117,7 @@ mikasa_init_irq(void) for (i = 16; i < 32; ++i) { irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL; - irq_desc[i].handler = &mikasa_irq_type; + irq_desc[i].chip = &mikasa_irq_type; } init_i8259a_irqs(); diff --git a/arch/alpha/kernel/sys_noritake.c b/arch/alpha/kernel/sys_noritake.c index 65061f5d741..55db02d318d 100644 --- a/arch/alpha/kernel/sys_noritake.c +++ b/arch/alpha/kernel/sys_noritake.c @@ -139,7 +139,7 @@ noritake_init_irq(void) for (i = 16; i < 48; ++i) { irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL; - irq_desc[i].handler = &noritake_irq_type; + irq_desc[i].chip = &noritake_irq_type; } init_i8259a_irqs(); diff --git a/arch/alpha/kernel/sys_rawhide.c b/arch/alpha/kernel/sys_rawhide.c index 05888a02a60..949607e3d6f 100644 --- a/arch/alpha/kernel/sys_rawhide.c +++ b/arch/alpha/kernel/sys_rawhide.c @@ -180,7 +180,7 @@ rawhide_init_irq(void) for (i = 16; i < 128; ++i) { irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL; - irq_desc[i].handler = &rawhide_irq_type; + irq_desc[i].chip = &rawhide_irq_type; } init_i8259a_irqs(); diff --git a/arch/alpha/kernel/sys_rx164.c b/arch/alpha/kernel/sys_rx164.c index 58404243057..6ae50605263 100644 --- a/arch/alpha/kernel/sys_rx164.c +++ b/arch/alpha/kernel/sys_rx164.c @@ -117,7 +117,7 @@ rx164_init_irq(void) rx164_update_irq_hw(0); for (i = 16; i < 40; ++i) { irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL; - irq_desc[i].handler = &rx164_irq_type; + irq_desc[i].chip = &rx164_irq_type; } init_i8259a_irqs(); diff --git a/arch/alpha/kernel/sys_sable.c b/arch/alpha/kernel/sys_sable.c index a7ff84474ac..24dea40c9bf 100644 --- a/arch/alpha/kernel/sys_sable.c +++ b/arch/alpha/kernel/sys_sable.c @@ -537,7 +537,7 @@ sable_lynx_init_irq(int nr_irqs) for (i = 0; i < nr_irqs; ++i) { irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL; - irq_desc[i].handler = &sable_lynx_irq_type; + irq_desc[i].chip = &sable_lynx_irq_type; } common_init_isa_dma(); diff --git a/arch/alpha/kernel/sys_takara.c b/arch/alpha/kernel/sys_takara.c index 7955bdfc2db..2c75cd1fd81 100644 --- a/arch/alpha/kernel/sys_takara.c +++ b/arch/alpha/kernel/sys_takara.c @@ -154,7 +154,7 @@ takara_init_irq(void) for (i = 16; i < 128; ++i) { irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL; - irq_desc[i].handler = &takara_irq_type; + irq_desc[i].chip = &takara_irq_type; } common_init_isa_dma(); diff --git a/arch/alpha/kernel/sys_titan.c b/arch/alpha/kernel/sys_titan.c index 2551fb49ae0..13f3ed8ed7a 100644 --- a/arch/alpha/kernel/sys_titan.c +++ b/arch/alpha/kernel/sys_titan.c @@ -189,7 +189,7 @@ init_titan_irqs(struct hw_interrupt_type * ops, int imin, int imax) long i; for (i = imin; i <= imax; ++i) { irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL; - irq_desc[i].handler = ops; + irq_desc[i].chip = ops; } } diff --git a/arch/alpha/kernel/sys_wildfire.c b/arch/alpha/kernel/sys_wildfire.c index 1553f470246..22c5798fe08 100644 --- a/arch/alpha/kernel/sys_wildfire.c +++ b/arch/alpha/kernel/sys_wildfire.c @@ -199,14 +199,14 @@ wildfire_init_irq_per_pca(int qbbno, int pcano) if (i == 2) continue; irq_desc[i+irq_bias].status = IRQ_DISABLED | IRQ_LEVEL; - irq_desc[i+irq_bias].handler = &wildfire_irq_type; + irq_desc[i+irq_bias].chip = &wildfire_irq_type; } irq_desc[36+irq_bias].status = IRQ_DISABLED | IRQ_LEVEL; - irq_desc[36+irq_bias].handler = &wildfire_irq_type; + irq_desc[36+irq_bias].chip = &wildfire_irq_type; for (i = 40; i < 64; ++i) { irq_desc[i+irq_bias].status = IRQ_DISABLED | IRQ_LEVEL; - irq_desc[i+irq_bias].handler = &wildfire_irq_type; + irq_desc[i+irq_bias].chip = &wildfire_irq_type; } setup_irq(32+irq_bias, &isa_enable); diff --git a/arch/cris/arch-v10/kernel/irq.c b/arch/cris/arch-v10/kernel/irq.c index 4b368a12201..2d5be93b519 100644 --- a/arch/cris/arch-v10/kernel/irq.c +++ b/arch/cris/arch-v10/kernel/irq.c @@ -172,7 +172,7 @@ init_IRQ(void) /* Initialize IRQ handler descriptiors. */ for(i = 2; i < NR_IRQS; i++) { - irq_desc[i].handler = &crisv10_irq_type; + irq_desc[i].chip = &crisv10_irq_type; set_int_vector(i, interrupt[i]); } diff --git a/arch/cris/arch-v32/kernel/irq.c b/arch/cris/arch-v32/kernel/irq.c index c78cc268513..06260874f01 100644 --- a/arch/cris/arch-v32/kernel/irq.c +++ b/arch/cris/arch-v32/kernel/irq.c @@ -369,7 +369,7 @@ init_IRQ(void) /* Point all IRQ's to bad handlers. */ for (i = FIRST_IRQ, j = 0; j < NR_IRQS; i++, j++) { - irq_desc[j].handler = &crisv32_irq_type; + irq_desc[j].chip = &crisv32_irq_type; set_exception_vector(i, interrupt[j]); } diff --git a/arch/cris/kernel/irq.c b/arch/cris/kernel/irq.c index b504def3e34..6547bb64636 100644 --- a/arch/cris/kernel/irq.c +++ b/arch/cris/kernel/irq.c @@ -69,7 +69,7 @@ int show_interrupts(struct seq_file *p, void *v) for_each_online_cpu(j) seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]); #endif - seq_printf(p, " %14s", irq_desc[i].handler->typename); + seq_printf(p, " %14s", irq_desc[i].chip->typename); seq_printf(p, " %s", action->name); for (action=action->next; action; action = action->next) diff --git a/arch/i386/kernel/i8259.c b/arch/i386/kernel/i8259.c index c1a42feba28..3c6063671a9 100644 --- a/arch/i386/kernel/i8259.c +++ b/arch/i386/kernel/i8259.c @@ -132,7 +132,7 @@ void make_8259A_irq(unsigned int irq) { disable_irq_nosync(irq); io_apic_irqs &= ~(1<typename); + seq_printf(p, " %14s", irq_desc[i].chip->typename); seq_printf(p, " %s", action->name); for (action=action->next; action; action = action->next) @@ -296,8 +296,8 @@ void fixup_irqs(cpumask_t map) printk("Breaking affinity for irq %i\n", irq); mask = map; } - if (irq_desc[irq].handler->set_affinity) - irq_desc[irq].handler->set_affinity(irq, mask); + if (irq_desc[irq].chip->set_affinity) + irq_desc[irq].chip->set_affinity(irq, mask); else if (irq_desc[irq].action && !(warned++)) printk("Cannot set affinity for irq %i\n", irq); } diff --git a/arch/i386/mach-visws/visws_apic.c b/arch/i386/mach-visws/visws_apic.c index 3e64fb72129..c418521dd55 100644 --- a/arch/i386/mach-visws/visws_apic.c +++ b/arch/i386/mach-visws/visws_apic.c @@ -278,22 +278,22 @@ void init_VISWS_APIC_irqs(void) irq_desc[i].depth = 1; if (i == 0) { - irq_desc[i].handler = &cobalt_irq_type; + irq_desc[i].chip = &cobalt_irq_type; } else if (i == CO_IRQ_IDE0) { - irq_desc[i].handler = &cobalt_irq_type; + irq_desc[i].chip = &cobalt_irq_type; } else if (i == CO_IRQ_IDE1) { - irq_desc[i].handler = &cobalt_irq_type; + irq_desc[i].chip = &cobalt_irq_type; } else if (i == CO_IRQ_8259) { - irq_desc[i].handler = &piix4_master_irq_type; + irq_desc[i].chip = &piix4_master_irq_type; } else if (i < CO_IRQ_APIC0) { - irq_desc[i].handler = &piix4_virtual_irq_type; + irq_desc[i].chip = &piix4_virtual_irq_type; } else if (IS_CO_APIC(i)) { - irq_desc[i].handler = &cobalt_irq_type; + irq_desc[i].chip = &cobalt_irq_type; } } diff --git a/arch/i386/mach-voyager/voyager_smp.c b/arch/i386/mach-voyager/voyager_smp.c index 8242af9ebc6..5b8b579a079 100644 --- a/arch/i386/mach-voyager/voyager_smp.c +++ b/arch/i386/mach-voyager/voyager_smp.c @@ -1419,7 +1419,7 @@ smp_intr_init(void) * This is for later: first 16 correspond to PC IRQs; next 16 * are Primary MC IRQs and final 16 are Secondary MC IRQs */ for(i = 0; i < 48; i++) - irq_desc[i].handler = &vic_irq_type; + irq_desc[i].chip = &vic_irq_type; } /* send a CPI at level cpi to a set of cpus in cpuset (set 1 bit per diff --git a/arch/ia64/kernel/iosapic.c b/arch/ia64/kernel/iosapic.c index d58c1c5c903..abb4cb1c831 100644 --- a/arch/ia64/kernel/iosapic.c +++ b/arch/ia64/kernel/iosapic.c @@ -660,13 +660,13 @@ register_intr (unsigned int gsi, int vector, unsigned char delivery, irq_type = &irq_type_iosapic_level; idesc = irq_descp(vector); - if (idesc->handler != irq_type) { - if (idesc->handler != &no_irq_type) + if (idesc->chip != irq_type) { + if (idesc->chip != &no_irq_type) printk(KERN_WARNING "%s: changing vector %d from %s to %s\n", __FUNCTION__, vector, - idesc->handler->typename, irq_type->typename); - idesc->handler = irq_type; + idesc->chip->typename, irq_type->typename); + idesc->chip = irq_type; } return 0; } @@ -903,7 +903,7 @@ iosapic_unregister_intr (unsigned int gsi) BUG_ON(iosapic_intr_info[vector].count); /* Clear the interrupt controller descriptor */ - idesc->handler = &no_irq_type; + idesc->chip = &no_irq_type; /* Clear the interrupt information */ memset(&iosapic_intr_info[vector], 0, diff --git a/arch/ia64/kernel/irq.c b/arch/ia64/kernel/irq.c index 9c72ea3f643..2645153dba8 100644 --- a/arch/ia64/kernel/irq.c +++ b/arch/ia64/kernel/irq.c @@ -76,7 +76,7 @@ int show_interrupts(struct seq_file *p, void *v) seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]); } #endif - seq_printf(p, " %14s", irq_desc[i].handler->typename); + seq_printf(p, " %14s", irq_desc[i].chip->typename); seq_printf(p, " %s", action->name); for (action=action->next; action; action = action->next) @@ -144,15 +144,15 @@ static void migrate_irqs(void) /* * Al three are essential, currently WARN_ON.. maybe panic? */ - if (desc->handler && desc->handler->disable && - desc->handler->enable && desc->handler->set_affinity) { - desc->handler->disable(irq); - desc->handler->set_affinity(irq, mask); - desc->handler->enable(irq); + if (desc->chip && desc->chip->disable && + desc->chip->enable && desc->chip->set_affinity) { + desc->chip->disable(irq); + desc->chip->set_affinity(irq, mask); + desc->chip->enable(irq); } else { - WARN_ON((!(desc->handler) || !(desc->handler->disable) || - !(desc->handler->enable) || - !(desc->handler->set_affinity))); + WARN_ON((!(desc->chip) || !(desc->chip->disable) || + !(desc->chip->enable) || + !(desc->chip->set_affinity))); } } } diff --git a/arch/ia64/kernel/irq_ia64.c b/arch/ia64/kernel/irq_ia64.c index ef9a2b49307..6d8fc9498ed 100644 --- a/arch/ia64/kernel/irq_ia64.c +++ b/arch/ia64/kernel/irq_ia64.c @@ -251,7 +251,7 @@ register_percpu_irq (ia64_vector vec, struct irqaction *action) if (irq_to_vector(irq) == vec) { desc = irq_descp(irq); desc->status |= IRQ_PER_CPU; - desc->handler = &irq_type_ia64_lsapic; + desc->chip = &irq_type_ia64_lsapic; if (action) setup_irq(irq, action); } diff --git a/arch/ia64/kernel/smpboot.c b/arch/ia64/kernel/smpboot.c index 44e9547878a..d6928805559 100644 --- a/arch/ia64/kernel/smpboot.c +++ b/arch/ia64/kernel/smpboot.c @@ -684,9 +684,9 @@ int migrate_platform_irqs(unsigned int cpu) * polling before making changes. */ if (desc) { - desc->handler->disable(ia64_cpe_irq); - desc->handler->set_affinity(ia64_cpe_irq, mask); - desc->handler->enable(ia64_cpe_irq); + desc->chip->disable(ia64_cpe_irq); + desc->chip->set_affinity(ia64_cpe_irq, mask); + desc->chip->enable(ia64_cpe_irq); printk ("Re-targetting CPEI to cpu %d\n", new_cpei_cpu); } } diff --git a/arch/ia64/sn/kernel/irq.c b/arch/ia64/sn/kernel/irq.c index 677c6c0fd66..7bb6ad188ba 100644 --- a/arch/ia64/sn/kernel/irq.c +++ b/arch/ia64/sn/kernel/irq.c @@ -225,8 +225,8 @@ void sn_irq_init(void) ia64_last_device_vector = IA64_SN2_LAST_DEVICE_VECTOR; for (i = 0; i < NR_IRQS; i++) { - if (base_desc[i].handler == &no_irq_type) { - base_desc[i].handler = &irq_type_sn; + if (base_desc[i].chip == &no_irq_type) { + base_desc[i].chip = &irq_type_sn; } } } diff --git a/arch/m32r/kernel/irq.c b/arch/m32r/kernel/irq.c index a4634b06f67..3841861df6a 100644 --- a/arch/m32r/kernel/irq.c +++ b/arch/m32r/kernel/irq.c @@ -54,7 +54,7 @@ int show_interrupts(struct seq_file *p, void *v) for_each_online_cpu(j) seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]); #endif - seq_printf(p, " %14s", irq_desc[i].handler->typename); + seq_printf(p, " %14s", irq_desc[i].chip->typename); seq_printf(p, " %s", action->name); for (action=action->next; action; action = action->next) diff --git a/arch/m32r/kernel/setup_m32104ut.c b/arch/m32r/kernel/setup_m32104ut.c index 6328e1357a8..f9f56c27019 100644 --- a/arch/m32r/kernel/setup_m32104ut.c +++ b/arch/m32r/kernel/setup_m32104ut.c @@ -87,7 +87,7 @@ void __init init_IRQ(void) #if defined(CONFIG_SMC91X) /* INT#0: LAN controller on M32104UT-LAN (SMC91C111)*/ irq_desc[M32R_IRQ_INT0].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_INT0].handler = &m32104ut_irq_type; + irq_desc[M32R_IRQ_INT0].chip = &m32104ut_irq_type; irq_desc[M32R_IRQ_INT0].action = 0; irq_desc[M32R_IRQ_INT0].depth = 1; icu_data[M32R_IRQ_INT0].icucr = M32R_ICUCR_IEN | M32R_ICUCR_ISMOD11; /* "H" level sense */ @@ -96,7 +96,7 @@ void __init init_IRQ(void) /* MFT2 : system timer */ irq_desc[M32R_IRQ_MFT2].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_MFT2].handler = &m32104ut_irq_type; + irq_desc[M32R_IRQ_MFT2].chip = &m32104ut_irq_type; irq_desc[M32R_IRQ_MFT2].action = 0; irq_desc[M32R_IRQ_MFT2].depth = 1; icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN; @@ -105,7 +105,7 @@ void __init init_IRQ(void) #ifdef CONFIG_SERIAL_M32R_SIO /* SIO0_R : uart receive data */ irq_desc[M32R_IRQ_SIO0_R].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_SIO0_R].handler = &m32104ut_irq_type; + irq_desc[M32R_IRQ_SIO0_R].chip = &m32104ut_irq_type; irq_desc[M32R_IRQ_SIO0_R].action = 0; irq_desc[M32R_IRQ_SIO0_R].depth = 1; icu_data[M32R_IRQ_SIO0_R].icucr = M32R_ICUCR_IEN; @@ -113,7 +113,7 @@ void __init init_IRQ(void) /* SIO0_S : uart send data */ irq_desc[M32R_IRQ_SIO0_S].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_SIO0_S].handler = &m32104ut_irq_type; + irq_desc[M32R_IRQ_SIO0_S].chip = &m32104ut_irq_type; irq_desc[M32R_IRQ_SIO0_S].action = 0; irq_desc[M32R_IRQ_SIO0_S].depth = 1; icu_data[M32R_IRQ_SIO0_S].icucr = M32R_ICUCR_IEN; diff --git a/arch/m32r/kernel/setup_m32700ut.c b/arch/m32r/kernel/setup_m32700ut.c index fad1fc99bb2..b6ab00eff58 100644 --- a/arch/m32r/kernel/setup_m32700ut.c +++ b/arch/m32r/kernel/setup_m32700ut.c @@ -301,7 +301,7 @@ void __init init_IRQ(void) #if defined(CONFIG_SMC91X) /* INT#0: LAN controller on M32700UT-LAN (SMC91C111)*/ irq_desc[M32700UT_LAN_IRQ_LAN].status = IRQ_DISABLED; - irq_desc[M32700UT_LAN_IRQ_LAN].handler = &m32700ut_lanpld_irq_type; + irq_desc[M32700UT_LAN_IRQ_LAN].chip = &m32700ut_lanpld_irq_type; irq_desc[M32700UT_LAN_IRQ_LAN].action = 0; irq_desc[M32700UT_LAN_IRQ_LAN].depth = 1; /* disable nested irq */ lanpld_icu_data[irq2lanpldirq(M32700UT_LAN_IRQ_LAN)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD02; /* "H" edge sense */ @@ -310,7 +310,7 @@ void __init init_IRQ(void) /* MFT2 : system timer */ irq_desc[M32R_IRQ_MFT2].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_MFT2].handler = &m32700ut_irq_type; + irq_desc[M32R_IRQ_MFT2].chip = &m32700ut_irq_type; irq_desc[M32R_IRQ_MFT2].action = 0; irq_desc[M32R_IRQ_MFT2].depth = 1; icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN; @@ -318,7 +318,7 @@ void __init init_IRQ(void) /* SIO0 : receive */ irq_desc[M32R_IRQ_SIO0_R].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_SIO0_R].handler = &m32700ut_irq_type; + irq_desc[M32R_IRQ_SIO0_R].chip = &m32700ut_irq_type; irq_desc[M32R_IRQ_SIO0_R].action = 0; irq_desc[M32R_IRQ_SIO0_R].depth = 1; icu_data[M32R_IRQ_SIO0_R].icucr = 0; @@ -326,7 +326,7 @@ void __init init_IRQ(void) /* SIO0 : send */ irq_desc[M32R_IRQ_SIO0_S].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_SIO0_S].handler = &m32700ut_irq_type; + irq_desc[M32R_IRQ_SIO0_S].chip = &m32700ut_irq_type; irq_desc[M32R_IRQ_SIO0_S].action = 0; irq_desc[M32R_IRQ_SIO0_S].depth = 1; icu_data[M32R_IRQ_SIO0_S].icucr = 0; @@ -334,7 +334,7 @@ void __init init_IRQ(void) /* SIO1 : receive */ irq_desc[M32R_IRQ_SIO1_R].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_SIO1_R].handler = &m32700ut_irq_type; + irq_desc[M32R_IRQ_SIO1_R].chip = &m32700ut_irq_type; irq_desc[M32R_IRQ_SIO1_R].action = 0; irq_desc[M32R_IRQ_SIO1_R].depth = 1; icu_data[M32R_IRQ_SIO1_R].icucr = 0; @@ -342,7 +342,7 @@ void __init init_IRQ(void) /* SIO1 : send */ irq_desc[M32R_IRQ_SIO1_S].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_SIO1_S].handler = &m32700ut_irq_type; + irq_desc[M32R_IRQ_SIO1_S].chip = &m32700ut_irq_type; irq_desc[M32R_IRQ_SIO1_S].action = 0; irq_desc[M32R_IRQ_SIO1_S].depth = 1; icu_data[M32R_IRQ_SIO1_S].icucr = 0; @@ -350,7 +350,7 @@ void __init init_IRQ(void) /* DMA1 : */ irq_desc[M32R_IRQ_DMA1].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_DMA1].handler = &m32700ut_irq_type; + irq_desc[M32R_IRQ_DMA1].chip = &m32700ut_irq_type; irq_desc[M32R_IRQ_DMA1].action = 0; irq_desc[M32R_IRQ_DMA1].depth = 1; icu_data[M32R_IRQ_DMA1].icucr = 0; @@ -359,7 +359,7 @@ void __init init_IRQ(void) #ifdef CONFIG_SERIAL_M32R_PLDSIO /* INT#1: SIO0 Receive on PLD */ irq_desc[PLD_IRQ_SIO0_RCV].status = IRQ_DISABLED; - irq_desc[PLD_IRQ_SIO0_RCV].handler = &m32700ut_pld_irq_type; + irq_desc[PLD_IRQ_SIO0_RCV].chip = &m32700ut_pld_irq_type; irq_desc[PLD_IRQ_SIO0_RCV].action = 0; irq_desc[PLD_IRQ_SIO0_RCV].depth = 1; /* disable nested irq */ pld_icu_data[irq2pldirq(PLD_IRQ_SIO0_RCV)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD03; @@ -367,7 +367,7 @@ void __init init_IRQ(void) /* INT#1: SIO0 Send on PLD */ irq_desc[PLD_IRQ_SIO0_SND].status = IRQ_DISABLED; - irq_desc[PLD_IRQ_SIO0_SND].handler = &m32700ut_pld_irq_type; + irq_desc[PLD_IRQ_SIO0_SND].chip = &m32700ut_pld_irq_type; irq_desc[PLD_IRQ_SIO0_SND].action = 0; irq_desc[PLD_IRQ_SIO0_SND].depth = 1; /* disable nested irq */ pld_icu_data[irq2pldirq(PLD_IRQ_SIO0_SND)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD03; @@ -376,7 +376,7 @@ void __init init_IRQ(void) /* INT#1: CFC IREQ on PLD */ irq_desc[PLD_IRQ_CFIREQ].status = IRQ_DISABLED; - irq_desc[PLD_IRQ_CFIREQ].handler = &m32700ut_pld_irq_type; + irq_desc[PLD_IRQ_CFIREQ].chip = &m32700ut_pld_irq_type; irq_desc[PLD_IRQ_CFIREQ].action = 0; irq_desc[PLD_IRQ_CFIREQ].depth = 1; /* disable nested irq */ pld_icu_data[irq2pldirq(PLD_IRQ_CFIREQ)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD01; /* 'L' level sense */ @@ -384,7 +384,7 @@ void __init init_IRQ(void) /* INT#1: CFC Insert on PLD */ irq_desc[PLD_IRQ_CFC_INSERT].status = IRQ_DISABLED; - irq_desc[PLD_IRQ_CFC_INSERT].handler = &m32700ut_pld_irq_type; + irq_desc[PLD_IRQ_CFC_INSERT].chip = &m32700ut_pld_irq_type; irq_desc[PLD_IRQ_CFC_INSERT].action = 0; irq_desc[PLD_IRQ_CFC_INSERT].depth = 1; /* disable nested irq */ pld_icu_data[irq2pldirq(PLD_IRQ_CFC_INSERT)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD00; /* 'L' edge sense */ @@ -392,7 +392,7 @@ void __init init_IRQ(void) /* INT#1: CFC Eject on PLD */ irq_desc[PLD_IRQ_CFC_EJECT].status = IRQ_DISABLED; - irq_desc[PLD_IRQ_CFC_EJECT].handler = &m32700ut_pld_irq_type; + irq_desc[PLD_IRQ_CFC_EJECT].chip = &m32700ut_pld_irq_type; irq_desc[PLD_IRQ_CFC_EJECT].action = 0; irq_desc[PLD_IRQ_CFC_EJECT].depth = 1; /* disable nested irq */ pld_icu_data[irq2pldirq(PLD_IRQ_CFC_EJECT)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD02; /* 'H' edge sense */ @@ -416,7 +416,7 @@ void __init init_IRQ(void) outw(USBCR_OTGS, USBCR); /* USBCR: non-OTG */ irq_desc[M32700UT_LCD_IRQ_USB_INT1].status = IRQ_DISABLED; - irq_desc[M32700UT_LCD_IRQ_USB_INT1].handler = &m32700ut_lcdpld_irq_type; + irq_desc[M32700UT_LCD_IRQ_USB_INT1].chip = &m32700ut_lcdpld_irq_type; irq_desc[M32700UT_LCD_IRQ_USB_INT1].action = 0; irq_desc[M32700UT_LCD_IRQ_USB_INT1].depth = 1; lcdpld_icu_data[irq2lcdpldirq(M32700UT_LCD_IRQ_USB_INT1)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD01; /* "L" level sense */ @@ -434,7 +434,7 @@ void __init init_IRQ(void) * INT3# is used for AR */ irq_desc[M32R_IRQ_INT3].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_INT3].handler = &m32700ut_irq_type; + irq_desc[M32R_IRQ_INT3].chip = &m32700ut_irq_type; irq_desc[M32R_IRQ_INT3].action = 0; irq_desc[M32R_IRQ_INT3].depth = 1; icu_data[M32R_IRQ_INT3].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10; diff --git a/arch/m32r/kernel/setup_mappi.c b/arch/m32r/kernel/setup_mappi.c index 00f253209cb..c268044185f 100644 --- a/arch/m32r/kernel/setup_mappi.c +++ b/arch/m32r/kernel/setup_mappi.c @@ -86,7 +86,7 @@ void __init init_IRQ(void) #ifdef CONFIG_NE2000 /* INT0 : LAN controller (RTL8019AS) */ irq_desc[M32R_IRQ_INT0].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_INT0].handler = &mappi_irq_type; + irq_desc[M32R_IRQ_INT0].chip = &mappi_irq_type; irq_desc[M32R_IRQ_INT0].action = 0; irq_desc[M32R_IRQ_INT0].depth = 1; icu_data[M32R_IRQ_INT0].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10; @@ -95,7 +95,7 @@ void __init init_IRQ(void) /* MFT2 : system timer */ irq_desc[M32R_IRQ_MFT2].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_MFT2].handler = &mappi_irq_type; + irq_desc[M32R_IRQ_MFT2].chip = &mappi_irq_type; irq_desc[M32R_IRQ_MFT2].action = 0; irq_desc[M32R_IRQ_MFT2].depth = 1; icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN; @@ -104,7 +104,7 @@ void __init init_IRQ(void) #ifdef CONFIG_SERIAL_M32R_SIO /* SIO0_R : uart receive data */ irq_desc[M32R_IRQ_SIO0_R].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_SIO0_R].handler = &mappi_irq_type; + irq_desc[M32R_IRQ_SIO0_R].chip = &mappi_irq_type; irq_desc[M32R_IRQ_SIO0_R].action = 0; irq_desc[M32R_IRQ_SIO0_R].depth = 1; icu_data[M32R_IRQ_SIO0_R].icucr = 0; @@ -112,7 +112,7 @@ void __init init_IRQ(void) /* SIO0_S : uart send data */ irq_desc[M32R_IRQ_SIO0_S].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_SIO0_S].handler = &mappi_irq_type; + irq_desc[M32R_IRQ_SIO0_S].chip = &mappi_irq_type; irq_desc[M32R_IRQ_SIO0_S].action = 0; irq_desc[M32R_IRQ_SIO0_S].depth = 1; icu_data[M32R_IRQ_SIO0_S].icucr = 0; @@ -120,7 +120,7 @@ void __init init_IRQ(void) /* SIO1_R : uart receive data */ irq_desc[M32R_IRQ_SIO1_R].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_SIO1_R].handler = &mappi_irq_type; + irq_desc[M32R_IRQ_SIO1_R].chip = &mappi_irq_type; irq_desc[M32R_IRQ_SIO1_R].action = 0; irq_desc[M32R_IRQ_SIO1_R].depth = 1; icu_data[M32R_IRQ_SIO1_R].icucr = 0; @@ -128,7 +128,7 @@ void __init init_IRQ(void) /* SIO1_S : uart send data */ irq_desc[M32R_IRQ_SIO1_S].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_SIO1_S].handler = &mappi_irq_type; + irq_desc[M32R_IRQ_SIO1_S].chip = &mappi_irq_type; irq_desc[M32R_IRQ_SIO1_S].action = 0; irq_desc[M32R_IRQ_SIO1_S].depth = 1; icu_data[M32R_IRQ_SIO1_S].icucr = 0; @@ -138,7 +138,7 @@ void __init init_IRQ(void) #if defined(CONFIG_M32R_PCC) /* INT1 : pccard0 interrupt */ irq_desc[M32R_IRQ_INT1].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_INT1].handler = &mappi_irq_type; + irq_desc[M32R_IRQ_INT1].chip = &mappi_irq_type; irq_desc[M32R_IRQ_INT1].action = 0; irq_desc[M32R_IRQ_INT1].depth = 1; icu_data[M32R_IRQ_INT1].icucr = M32R_ICUCR_IEN | M32R_ICUCR_ISMOD00; @@ -146,7 +146,7 @@ void __init init_IRQ(void) /* INT2 : pccard1 interrupt */ irq_desc[M32R_IRQ_INT2].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_INT2].handler = &mappi_irq_type; + irq_desc[M32R_IRQ_INT2].chip = &mappi_irq_type; irq_desc[M32R_IRQ_INT2].action = 0; irq_desc[M32R_IRQ_INT2].depth = 1; icu_data[M32R_IRQ_INT2].icucr = M32R_ICUCR_IEN | M32R_ICUCR_ISMOD00; diff --git a/arch/m32r/kernel/setup_mappi2.c b/arch/m32r/kernel/setup_mappi2.c index eebc9d8b4e7..bd2327d5cca 100644 --- a/arch/m32r/kernel/setup_mappi2.c +++ b/arch/m32r/kernel/setup_mappi2.c @@ -87,7 +87,7 @@ void __init init_IRQ(void) #if defined(CONFIG_SMC91X) /* INT0 : LAN controller (SMC91111) */ irq_desc[M32R_IRQ_INT0].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_INT0].handler = &mappi2_irq_type; + irq_desc[M32R_IRQ_INT0].chip = &mappi2_irq_type; irq_desc[M32R_IRQ_INT0].action = 0; irq_desc[M32R_IRQ_INT0].depth = 1; icu_data[M32R_IRQ_INT0].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10; @@ -96,7 +96,7 @@ void __init init_IRQ(void) /* MFT2 : system timer */ irq_desc[M32R_IRQ_MFT2].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_MFT2].handler = &mappi2_irq_type; + irq_desc[M32R_IRQ_MFT2].chip = &mappi2_irq_type; irq_desc[M32R_IRQ_MFT2].action = 0; irq_desc[M32R_IRQ_MFT2].depth = 1; icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN; @@ -105,7 +105,7 @@ void __init init_IRQ(void) #ifdef CONFIG_SERIAL_M32R_SIO /* SIO0_R : uart receive data */ irq_desc[M32R_IRQ_SIO0_R].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_SIO0_R].handler = &mappi2_irq_type; + irq_desc[M32R_IRQ_SIO0_R].chip = &mappi2_irq_type; irq_desc[M32R_IRQ_SIO0_R].action = 0; irq_desc[M32R_IRQ_SIO0_R].depth = 1; icu_data[M32R_IRQ_SIO0_R].icucr = 0; @@ -113,14 +113,14 @@ void __init init_IRQ(void) /* SIO0_S : uart send data */ irq_desc[M32R_IRQ_SIO0_S].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_SIO0_S].handler = &mappi2_irq_type; + irq_desc[M32R_IRQ_SIO0_S].chip = &mappi2_irq_type; irq_desc[M32R_IRQ_SIO0_S].action = 0; irq_desc[M32R_IRQ_SIO0_S].depth = 1; icu_data[M32R_IRQ_SIO0_S].icucr = 0; disable_mappi2_irq(M32R_IRQ_SIO0_S); /* SIO1_R : uart receive data */ irq_desc[M32R_IRQ_SIO1_R].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_SIO1_R].handler = &mappi2_irq_type; + irq_desc[M32R_IRQ_SIO1_R].chip = &mappi2_irq_type; irq_desc[M32R_IRQ_SIO1_R].action = 0; irq_desc[M32R_IRQ_SIO1_R].depth = 1; icu_data[M32R_IRQ_SIO1_R].icucr = 0; @@ -128,7 +128,7 @@ void __init init_IRQ(void) /* SIO1_S : uart send data */ irq_desc[M32R_IRQ_SIO1_S].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_SIO1_S].handler = &mappi2_irq_type; + irq_desc[M32R_IRQ_SIO1_S].chip = &mappi2_irq_type; irq_desc[M32R_IRQ_SIO1_S].action = 0; irq_desc[M32R_IRQ_SIO1_S].depth = 1; icu_data[M32R_IRQ_SIO1_S].icucr = 0; @@ -138,7 +138,7 @@ void __init init_IRQ(void) #if defined(CONFIG_USB) /* INT1 : USB Host controller interrupt */ irq_desc[M32R_IRQ_INT1].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_INT1].handler = &mappi2_irq_type; + irq_desc[M32R_IRQ_INT1].chip = &mappi2_irq_type; irq_desc[M32R_IRQ_INT1].action = 0; irq_desc[M32R_IRQ_INT1].depth = 1; icu_data[M32R_IRQ_INT1].icucr = M32R_ICUCR_ISMOD01; @@ -147,7 +147,7 @@ void __init init_IRQ(void) /* ICUCR40: CFC IREQ */ irq_desc[PLD_IRQ_CFIREQ].status = IRQ_DISABLED; - irq_desc[PLD_IRQ_CFIREQ].handler = &mappi2_irq_type; + irq_desc[PLD_IRQ_CFIREQ].chip = &mappi2_irq_type; irq_desc[PLD_IRQ_CFIREQ].action = 0; irq_desc[PLD_IRQ_CFIREQ].depth = 1; /* disable nested irq */ icu_data[PLD_IRQ_CFIREQ].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD01; @@ -156,7 +156,7 @@ void __init init_IRQ(void) #if defined(CONFIG_M32R_CFC) /* ICUCR41: CFC Insert */ irq_desc[PLD_IRQ_CFC_INSERT].status = IRQ_DISABLED; - irq_desc[PLD_IRQ_CFC_INSERT].handler = &mappi2_irq_type; + irq_desc[PLD_IRQ_CFC_INSERT].chip = &mappi2_irq_type; irq_desc[PLD_IRQ_CFC_INSERT].action = 0; irq_desc[PLD_IRQ_CFC_INSERT].depth = 1; /* disable nested irq */ icu_data[PLD_IRQ_CFC_INSERT].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD00; @@ -164,7 +164,7 @@ void __init init_IRQ(void) /* ICUCR42: CFC Eject */ irq_desc[PLD_IRQ_CFC_EJECT].status = IRQ_DISABLED; - irq_desc[PLD_IRQ_CFC_EJECT].handler = &mappi2_irq_type; + irq_desc[PLD_IRQ_CFC_EJECT].chip = &mappi2_irq_type; irq_desc[PLD_IRQ_CFC_EJECT].action = 0; irq_desc[PLD_IRQ_CFC_EJECT].depth = 1; /* disable nested irq */ icu_data[PLD_IRQ_CFC_EJECT].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10; diff --git a/arch/m32r/kernel/setup_mappi3.c b/arch/m32r/kernel/setup_mappi3.c index d2ff021e2d3..014b51d1750 100644 --- a/arch/m32r/kernel/setup_mappi3.c +++ b/arch/m32r/kernel/setup_mappi3.c @@ -87,7 +87,7 @@ void __init init_IRQ(void) #if defined(CONFIG_SMC91X) /* INT0 : LAN controller (SMC91111) */ irq_desc[M32R_IRQ_INT0].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_INT0].handler = &mappi3_irq_type; + irq_desc[M32R_IRQ_INT0].chip = &mappi3_irq_type; irq_desc[M32R_IRQ_INT0].action = 0; irq_desc[M32R_IRQ_INT0].depth = 1; icu_data[M32R_IRQ_INT0].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10; @@ -96,7 +96,7 @@ void __init init_IRQ(void) /* MFT2 : system timer */ irq_desc[M32R_IRQ_MFT2].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_MFT2].handler = &mappi3_irq_type; + irq_desc[M32R_IRQ_MFT2].chip = &mappi3_irq_type; irq_desc[M32R_IRQ_MFT2].action = 0; irq_desc[M32R_IRQ_MFT2].depth = 1; icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN; @@ -105,7 +105,7 @@ void __init init_IRQ(void) #ifdef CONFIG_SERIAL_M32R_SIO /* SIO0_R : uart receive data */ irq_desc[M32R_IRQ_SIO0_R].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_SIO0_R].handler = &mappi3_irq_type; + irq_desc[M32R_IRQ_SIO0_R].chip = &mappi3_irq_type; irq_desc[M32R_IRQ_SIO0_R].action = 0; irq_desc[M32R_IRQ_SIO0_R].depth = 1; icu_data[M32R_IRQ_SIO0_R].icucr = 0; @@ -113,14 +113,14 @@ void __init init_IRQ(void) /* SIO0_S : uart send data */ irq_desc[M32R_IRQ_SIO0_S].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_SIO0_S].handler = &mappi3_irq_type; + irq_desc[M32R_IRQ_SIO0_S].chip = &mappi3_irq_type; irq_desc[M32R_IRQ_SIO0_S].action = 0; irq_desc[M32R_IRQ_SIO0_S].depth = 1; icu_data[M32R_IRQ_SIO0_S].icucr = 0; disable_mappi3_irq(M32R_IRQ_SIO0_S); /* SIO1_R : uart receive data */ irq_desc[M32R_IRQ_SIO1_R].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_SIO1_R].handler = &mappi3_irq_type; + irq_desc[M32R_IRQ_SIO1_R].chip = &mappi3_irq_type; irq_desc[M32R_IRQ_SIO1_R].action = 0; irq_desc[M32R_IRQ_SIO1_R].depth = 1; icu_data[M32R_IRQ_SIO1_R].icucr = 0; @@ -128,7 +128,7 @@ void __init init_IRQ(void) /* SIO1_S : uart send data */ irq_desc[M32R_IRQ_SIO1_S].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_SIO1_S].handler = &mappi3_irq_type; + irq_desc[M32R_IRQ_SIO1_S].chip = &mappi3_irq_type; irq_desc[M32R_IRQ_SIO1_S].action = 0; irq_desc[M32R_IRQ_SIO1_S].depth = 1; icu_data[M32R_IRQ_SIO1_S].icucr = 0; @@ -138,7 +138,7 @@ void __init init_IRQ(void) #if defined(CONFIG_USB) /* INT1 : USB Host controller interrupt */ irq_desc[M32R_IRQ_INT1].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_INT1].handler = &mappi3_irq_type; + irq_desc[M32R_IRQ_INT1].chip = &mappi3_irq_type; irq_desc[M32R_IRQ_INT1].action = 0; irq_desc[M32R_IRQ_INT1].depth = 1; icu_data[M32R_IRQ_INT1].icucr = M32R_ICUCR_ISMOD01; @@ -147,7 +147,7 @@ void __init init_IRQ(void) /* CFC IREQ */ irq_desc[PLD_IRQ_CFIREQ].status = IRQ_DISABLED; - irq_desc[PLD_IRQ_CFIREQ].handler = &mappi3_irq_type; + irq_desc[PLD_IRQ_CFIREQ].chip = &mappi3_irq_type; irq_desc[PLD_IRQ_CFIREQ].action = 0; irq_desc[PLD_IRQ_CFIREQ].depth = 1; /* disable nested irq */ icu_data[PLD_IRQ_CFIREQ].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD01; @@ -156,7 +156,7 @@ void __init init_IRQ(void) #if defined(CONFIG_M32R_CFC) /* ICUCR41: CFC Insert & eject */ irq_desc[PLD_IRQ_CFC_INSERT].status = IRQ_DISABLED; - irq_desc[PLD_IRQ_CFC_INSERT].handler = &mappi3_irq_type; + irq_desc[PLD_IRQ_CFC_INSERT].chip = &mappi3_irq_type; irq_desc[PLD_IRQ_CFC_INSERT].action = 0; irq_desc[PLD_IRQ_CFC_INSERT].depth = 1; /* disable nested irq */ icu_data[PLD_IRQ_CFC_INSERT].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD00; @@ -166,7 +166,7 @@ void __init init_IRQ(void) /* IDE IREQ */ irq_desc[PLD_IRQ_IDEIREQ].status = IRQ_DISABLED; - irq_desc[PLD_IRQ_IDEIREQ].handler = &mappi3_irq_type; + irq_desc[PLD_IRQ_IDEIREQ].chip = &mappi3_irq_type; irq_desc[PLD_IRQ_IDEIREQ].action = 0; irq_desc[PLD_IRQ_IDEIREQ].depth = 1; /* disable nested irq */ icu_data[PLD_IRQ_IDEIREQ].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10; diff --git a/arch/m32r/kernel/setup_oaks32r.c b/arch/m32r/kernel/setup_oaks32r.c index 0e9e63538c0..ea64831aef7 100644 --- a/arch/m32r/kernel/setup_oaks32r.c +++ b/arch/m32r/kernel/setup_oaks32r.c @@ -85,7 +85,7 @@ void __init init_IRQ(void) #ifdef CONFIG_NE2000 /* INT3 : LAN controller (RTL8019AS) */ irq_desc[M32R_IRQ_INT3].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_INT3].handler = &oaks32r_irq_type; + irq_desc[M32R_IRQ_INT3].chip = &oaks32r_irq_type; irq_desc[M32R_IRQ_INT3].action = 0; irq_desc[M32R_IRQ_INT3].depth = 1; icu_data[M32R_IRQ_INT3].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10; @@ -94,7 +94,7 @@ void __init init_IRQ(void) /* MFT2 : system timer */ irq_desc[M32R_IRQ_MFT2].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_MFT2].handler = &oaks32r_irq_type; + irq_desc[M32R_IRQ_MFT2].chip = &oaks32r_irq_type; irq_desc[M32R_IRQ_MFT2].action = 0; irq_desc[M32R_IRQ_MFT2].depth = 1; icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN; @@ -103,7 +103,7 @@ void __init init_IRQ(void) #ifdef CONFIG_SERIAL_M32R_SIO /* SIO0_R : uart receive data */ irq_desc[M32R_IRQ_SIO0_R].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_SIO0_R].handler = &oaks32r_irq_type; + irq_desc[M32R_IRQ_SIO0_R].chip = &oaks32r_irq_type; irq_desc[M32R_IRQ_SIO0_R].action = 0; irq_desc[M32R_IRQ_SIO0_R].depth = 1; icu_data[M32R_IRQ_SIO0_R].icucr = 0; @@ -111,7 +111,7 @@ void __init init_IRQ(void) /* SIO0_S : uart send data */ irq_desc[M32R_IRQ_SIO0_S].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_SIO0_S].handler = &oaks32r_irq_type; + irq_desc[M32R_IRQ_SIO0_S].chip = &oaks32r_irq_type; irq_desc[M32R_IRQ_SIO0_S].action = 0; irq_desc[M32R_IRQ_SIO0_S].depth = 1; icu_data[M32R_IRQ_SIO0_S].icucr = 0; @@ -119,7 +119,7 @@ void __init init_IRQ(void) /* SIO1_R : uart receive data */ irq_desc[M32R_IRQ_SIO1_R].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_SIO1_R].handler = &oaks32r_irq_type; + irq_desc[M32R_IRQ_SIO1_R].chip = &oaks32r_irq_type; irq_desc[M32R_IRQ_SIO1_R].action = 0; irq_desc[M32R_IRQ_SIO1_R].depth = 1; icu_data[M32R_IRQ_SIO1_R].icucr = 0; @@ -127,7 +127,7 @@ void __init init_IRQ(void) /* SIO1_S : uart send data */ irq_desc[M32R_IRQ_SIO1_S].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_SIO1_S].handler = &oaks32r_irq_type; + irq_desc[M32R_IRQ_SIO1_S].chip = &oaks32r_irq_type; irq_desc[M32R_IRQ_SIO1_S].action = 0; irq_desc[M32R_IRQ_SIO1_S].depth = 1; icu_data[M32R_IRQ_SIO1_S].icucr = 0; diff --git a/arch/m32r/kernel/setup_opsput.c b/arch/m32r/kernel/setup_opsput.c index 548e8fc7949..55e8972d455 100644 --- a/arch/m32r/kernel/setup_opsput.c +++ b/arch/m32r/kernel/setup_opsput.c @@ -302,7 +302,7 @@ void __init init_IRQ(void) #if defined(CONFIG_SMC91X) /* INT#0: LAN controller on OPSPUT-LAN (SMC91C111)*/ irq_desc[OPSPUT_LAN_IRQ_LAN].status = IRQ_DISABLED; - irq_desc[OPSPUT_LAN_IRQ_LAN].handler = &opsput_lanpld_irq_type; + irq_desc[OPSPUT_LAN_IRQ_LAN].chip = &opsput_lanpld_irq_type; irq_desc[OPSPUT_LAN_IRQ_LAN].action = 0; irq_desc[OPSPUT_LAN_IRQ_LAN].depth = 1; /* disable nested irq */ lanpld_icu_data[irq2lanpldirq(OPSPUT_LAN_IRQ_LAN)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD02; /* "H" edge sense */ @@ -311,7 +311,7 @@ void __init init_IRQ(void) /* MFT2 : system timer */ irq_desc[M32R_IRQ_MFT2].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_MFT2].handler = &opsput_irq_type; + irq_desc[M32R_IRQ_MFT2].chip = &opsput_irq_type; irq_desc[M32R_IRQ_MFT2].action = 0; irq_desc[M32R_IRQ_MFT2].depth = 1; icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN; @@ -319,7 +319,7 @@ void __init init_IRQ(void) /* SIO0 : receive */ irq_desc[M32R_IRQ_SIO0_R].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_SIO0_R].handler = &opsput_irq_type; + irq_desc[M32R_IRQ_SIO0_R].chip = &opsput_irq_type; irq_desc[M32R_IRQ_SIO0_R].action = 0; irq_desc[M32R_IRQ_SIO0_R].depth = 1; icu_data[M32R_IRQ_SIO0_R].icucr = 0; @@ -327,7 +327,7 @@ void __init init_IRQ(void) /* SIO0 : send */ irq_desc[M32R_IRQ_SIO0_S].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_SIO0_S].handler = &opsput_irq_type; + irq_desc[M32R_IRQ_SIO0_S].chip = &opsput_irq_type; irq_desc[M32R_IRQ_SIO0_S].action = 0; irq_desc[M32R_IRQ_SIO0_S].depth = 1; icu_data[M32R_IRQ_SIO0_S].icucr = 0; @@ -335,7 +335,7 @@ void __init init_IRQ(void) /* SIO1 : receive */ irq_desc[M32R_IRQ_SIO1_R].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_SIO1_R].handler = &opsput_irq_type; + irq_desc[M32R_IRQ_SIO1_R].chip = &opsput_irq_type; irq_desc[M32R_IRQ_SIO1_R].action = 0; irq_desc[M32R_IRQ_SIO1_R].depth = 1; icu_data[M32R_IRQ_SIO1_R].icucr = 0; @@ -343,7 +343,7 @@ void __init init_IRQ(void) /* SIO1 : send */ irq_desc[M32R_IRQ_SIO1_S].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_SIO1_S].handler = &opsput_irq_type; + irq_desc[M32R_IRQ_SIO1_S].chip = &opsput_irq_type; irq_desc[M32R_IRQ_SIO1_S].action = 0; irq_desc[M32R_IRQ_SIO1_S].depth = 1; icu_data[M32R_IRQ_SIO1_S].icucr = 0; @@ -351,7 +351,7 @@ void __init init_IRQ(void) /* DMA1 : */ irq_desc[M32R_IRQ_DMA1].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_DMA1].handler = &opsput_irq_type; + irq_desc[M32R_IRQ_DMA1].chip = &opsput_irq_type; irq_desc[M32R_IRQ_DMA1].action = 0; irq_desc[M32R_IRQ_DMA1].depth = 1; icu_data[M32R_IRQ_DMA1].icucr = 0; @@ -360,7 +360,7 @@ void __init init_IRQ(void) #ifdef CONFIG_SERIAL_M32R_PLDSIO /* INT#1: SIO0 Receive on PLD */ irq_desc[PLD_IRQ_SIO0_RCV].status = IRQ_DISABLED; - irq_desc[PLD_IRQ_SIO0_RCV].handler = &opsput_pld_irq_type; + irq_desc[PLD_IRQ_SIO0_RCV].chip = &opsput_pld_irq_type; irq_desc[PLD_IRQ_SIO0_RCV].action = 0; irq_desc[PLD_IRQ_SIO0_RCV].depth = 1; /* disable nested irq */ pld_icu_data[irq2pldirq(PLD_IRQ_SIO0_RCV)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD03; @@ -368,7 +368,7 @@ void __init init_IRQ(void) /* INT#1: SIO0 Send on PLD */ irq_desc[PLD_IRQ_SIO0_SND].status = IRQ_DISABLED; - irq_desc[PLD_IRQ_SIO0_SND].handler = &opsput_pld_irq_type; + irq_desc[PLD_IRQ_SIO0_SND].chip = &opsput_pld_irq_type; irq_desc[PLD_IRQ_SIO0_SND].action = 0; irq_desc[PLD_IRQ_SIO0_SND].depth = 1; /* disable nested irq */ pld_icu_data[irq2pldirq(PLD_IRQ_SIO0_SND)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD03; @@ -378,7 +378,7 @@ void __init init_IRQ(void) #if defined(CONFIG_M32R_CFC) /* INT#1: CFC IREQ on PLD */ irq_desc[PLD_IRQ_CFIREQ].status = IRQ_DISABLED; - irq_desc[PLD_IRQ_CFIREQ].handler = &opsput_pld_irq_type; + irq_desc[PLD_IRQ_CFIREQ].chip = &opsput_pld_irq_type; irq_desc[PLD_IRQ_CFIREQ].action = 0; irq_desc[PLD_IRQ_CFIREQ].depth = 1; /* disable nested irq */ pld_icu_data[irq2pldirq(PLD_IRQ_CFIREQ)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD01; /* 'L' level sense */ @@ -386,7 +386,7 @@ void __init init_IRQ(void) /* INT#1: CFC Insert on PLD */ irq_desc[PLD_IRQ_CFC_INSERT].status = IRQ_DISABLED; - irq_desc[PLD_IRQ_CFC_INSERT].handler = &opsput_pld_irq_type; + irq_desc[PLD_IRQ_CFC_INSERT].chip = &opsput_pld_irq_type; irq_desc[PLD_IRQ_CFC_INSERT].action = 0; irq_desc[PLD_IRQ_CFC_INSERT].depth = 1; /* disable nested irq */ pld_icu_data[irq2pldirq(PLD_IRQ_CFC_INSERT)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD00; /* 'L' edge sense */ @@ -394,7 +394,7 @@ void __init init_IRQ(void) /* INT#1: CFC Eject on PLD */ irq_desc[PLD_IRQ_CFC_EJECT].status = IRQ_DISABLED; - irq_desc[PLD_IRQ_CFC_EJECT].handler = &opsput_pld_irq_type; + irq_desc[PLD_IRQ_CFC_EJECT].chip = &opsput_pld_irq_type; irq_desc[PLD_IRQ_CFC_EJECT].action = 0; irq_desc[PLD_IRQ_CFC_EJECT].depth = 1; /* disable nested irq */ pld_icu_data[irq2pldirq(PLD_IRQ_CFC_EJECT)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD02; /* 'H' edge sense */ @@ -420,7 +420,7 @@ void __init init_IRQ(void) outw(USBCR_OTGS, USBCR); /* USBCR: non-OTG */ irq_desc[OPSPUT_LCD_IRQ_USB_INT1].status = IRQ_DISABLED; - irq_desc[OPSPUT_LCD_IRQ_USB_INT1].handler = &opsput_lcdpld_irq_type; + irq_desc[OPSPUT_LCD_IRQ_USB_INT1].chip = &opsput_lcdpld_irq_type; irq_desc[OPSPUT_LCD_IRQ_USB_INT1].action = 0; irq_desc[OPSPUT_LCD_IRQ_USB_INT1].depth = 1; lcdpld_icu_data[irq2lcdpldirq(OPSPUT_LCD_IRQ_USB_INT1)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD01; /* "L" level sense */ @@ -438,7 +438,7 @@ void __init init_IRQ(void) * INT3# is used for AR */ irq_desc[M32R_IRQ_INT3].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_INT3].handler = &opsput_irq_type; + irq_desc[M32R_IRQ_INT3].chip = &opsput_irq_type; irq_desc[M32R_IRQ_INT3].action = 0; irq_desc[M32R_IRQ_INT3].depth = 1; icu_data[M32R_IRQ_INT3].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10; diff --git a/arch/m32r/kernel/setup_usrv.c b/arch/m32r/kernel/setup_usrv.c index 64be659a23e..7fa12d8f66b 100644 --- a/arch/m32r/kernel/setup_usrv.c +++ b/arch/m32r/kernel/setup_usrv.c @@ -158,7 +158,7 @@ void __init init_IRQ(void) /* MFT2 : system timer */ irq_desc[M32R_IRQ_MFT2].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_MFT2].handler = &mappi_irq_type; + irq_desc[M32R_IRQ_MFT2].chip = &mappi_irq_type; irq_desc[M32R_IRQ_MFT2].action = 0; irq_desc[M32R_IRQ_MFT2].depth = 1; icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN; @@ -167,7 +167,7 @@ void __init init_IRQ(void) #if defined(CONFIG_SERIAL_M32R_SIO) /* SIO0_R : uart receive data */ irq_desc[M32R_IRQ_SIO0_R].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_SIO0_R].handler = &mappi_irq_type; + irq_desc[M32R_IRQ_SIO0_R].chip = &mappi_irq_type; irq_desc[M32R_IRQ_SIO0_R].action = 0; irq_desc[M32R_IRQ_SIO0_R].depth = 1; icu_data[M32R_IRQ_SIO0_R].icucr = 0; @@ -175,7 +175,7 @@ void __init init_IRQ(void) /* SIO0_S : uart send data */ irq_desc[M32R_IRQ_SIO0_S].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_SIO0_S].handler = &mappi_irq_type; + irq_desc[M32R_IRQ_SIO0_S].chip = &mappi_irq_type; irq_desc[M32R_IRQ_SIO0_S].action = 0; irq_desc[M32R_IRQ_SIO0_S].depth = 1; icu_data[M32R_IRQ_SIO0_S].icucr = 0; @@ -183,7 +183,7 @@ void __init init_IRQ(void) /* SIO1_R : uart receive data */ irq_desc[M32R_IRQ_SIO1_R].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_SIO1_R].handler = &mappi_irq_type; + irq_desc[M32R_IRQ_SIO1_R].chip = &mappi_irq_type; irq_desc[M32R_IRQ_SIO1_R].action = 0; irq_desc[M32R_IRQ_SIO1_R].depth = 1; icu_data[M32R_IRQ_SIO1_R].icucr = 0; @@ -191,7 +191,7 @@ void __init init_IRQ(void) /* SIO1_S : uart send data */ irq_desc[M32R_IRQ_SIO1_S].status = IRQ_DISABLED; - irq_desc[M32R_IRQ_SIO1_S].handler = &mappi_irq_type; + irq_desc[M32R_IRQ_SIO1_S].chip = &mappi_irq_type; irq_desc[M32R_IRQ_SIO1_S].action = 0; irq_desc[M32R_IRQ_SIO1_S].depth = 1; icu_data[M32R_IRQ_SIO1_S].icucr = 0; @@ -201,7 +201,7 @@ void __init init_IRQ(void) /* INT#67-#71: CFC#0 IREQ on PLD */ for (i = 0 ; i < CONFIG_CFC_NUM ; i++ ) { irq_desc[PLD_IRQ_CF0 + i].status = IRQ_DISABLED; - irq_desc[PLD_IRQ_CF0 + i].handler = &m32700ut_pld_irq_type; + irq_desc[PLD_IRQ_CF0 + i].chip = &m32700ut_pld_irq_type; irq_desc[PLD_IRQ_CF0 + i].action = 0; irq_desc[PLD_IRQ_CF0 + i].depth = 1; /* disable nested irq */ pld_icu_data[irq2pldirq(PLD_IRQ_CF0 + i)].icucr @@ -212,7 +212,7 @@ void __init init_IRQ(void) #if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE) /* INT#76: 16552D#0 IREQ on PLD */ irq_desc[PLD_IRQ_UART0].status = IRQ_DISABLED; - irq_desc[PLD_IRQ_UART0].handler = &m32700ut_pld_irq_type; + irq_desc[PLD_IRQ_UART0].chip = &m32700ut_pld_irq_type; irq_desc[PLD_IRQ_UART0].action = 0; irq_desc[PLD_IRQ_UART0].depth = 1; /* disable nested irq */ pld_icu_data[irq2pldirq(PLD_IRQ_UART0)].icucr @@ -221,7 +221,7 @@ void __init init_IRQ(void) /* INT#77: 16552D#1 IREQ on PLD */ irq_desc[PLD_IRQ_UART1].status = IRQ_DISABLED; - irq_desc[PLD_IRQ_UART1].handler = &m32700ut_pld_irq_type; + irq_desc[PLD_IRQ_UART1].chip = &m32700ut_pld_irq_type; irq_desc[PLD_IRQ_UART1].action = 0; irq_desc[PLD_IRQ_UART1].depth = 1; /* disable nested irq */ pld_icu_data[irq2pldirq(PLD_IRQ_UART1)].icucr @@ -232,7 +232,7 @@ void __init init_IRQ(void) #if defined(CONFIG_IDC_AK4524) || defined(CONFIG_IDC_AK4524_MODULE) /* INT#80: AK4524 IREQ on PLD */ irq_desc[PLD_IRQ_SNDINT].status = IRQ_DISABLED; - irq_desc[PLD_IRQ_SNDINT].handler = &m32700ut_pld_irq_type; + irq_desc[PLD_IRQ_SNDINT].chip = &m32700ut_pld_irq_type; irq_desc[PLD_IRQ_SNDINT].action = 0; irq_desc[PLD_IRQ_SNDINT].depth = 1; /* disable nested irq */ pld_icu_data[irq2pldirq(PLD_IRQ_SNDINT)].icucr diff --git a/arch/mips/au1000/common/irq.c b/arch/mips/au1000/common/irq.c index afe05ec12c2..da74ac21954 100644 --- a/arch/mips/au1000/common/irq.c +++ b/arch/mips/au1000/common/irq.c @@ -333,31 +333,31 @@ static void setup_local_irq(unsigned int irq_nr, int type, int int_req) au_writel(1<<(irq_nr-32), IC1_CFG2CLR); au_writel(1<<(irq_nr-32), IC1_CFG1CLR); au_writel(1<<(irq_nr-32), IC1_CFG0SET); - irq_desc[irq_nr].handler = &rise_edge_irq_type; + irq_desc[irq_nr].chip = &rise_edge_irq_type; break; case INTC_INT_FALL_EDGE: /* 0:1:0 */ au_writel(1<<(irq_nr-32), IC1_CFG2CLR); au_writel(1<<(irq_nr-32), IC1_CFG1SET); au_writel(1<<(irq_nr-32), IC1_CFG0CLR); - irq_desc[irq_nr].handler = &fall_edge_irq_type; + irq_desc[irq_nr].chip = &fall_edge_irq_type; break; case INTC_INT_RISE_AND_FALL_EDGE: /* 0:1:1 */ au_writel(1<<(irq_nr-32), IC1_CFG2CLR); au_writel(1<<(irq_nr-32), IC1_CFG1SET); au_writel(1<<(irq_nr-32), IC1_CFG0SET); - irq_desc[irq_nr].handler = &either_edge_irq_type; + irq_desc[irq_nr].chip = &either_edge_irq_type; break; case INTC_INT_HIGH_LEVEL: /* 1:0:1 */ au_writel(1<<(irq_nr-32), IC1_CFG2SET); au_writel(1<<(irq_nr-32), IC1_CFG1CLR); au_writel(1<<(irq_nr-32), IC1_CFG0SET); - irq_desc[irq_nr].handler = &level_irq_type; + irq_desc[irq_nr].chip = &level_irq_type; break; case INTC_INT_LOW_LEVEL: /* 1:1:0 */ au_writel(1<<(irq_nr-32), IC1_CFG2SET); au_writel(1<<(irq_nr-32), IC1_CFG1SET); au_writel(1<<(irq_nr-32), IC1_CFG0CLR); - irq_desc[irq_nr].handler = &level_irq_type; + irq_desc[irq_nr].chip = &level_irq_type; break; case INTC_INT_DISABLED: /* 0:0:0 */ au_writel(1<<(irq_nr-32), IC1_CFG0CLR); @@ -385,31 +385,31 @@ static void setup_local_irq(unsigned int irq_nr, int type, int int_req) au_writel(1<im_type) { case MSC01_IRQ_EDGE: - irq_desc[base+n].handler = &msc_edgeirq_type; + irq_desc[base+n].chip = &msc_edgeirq_type; if (cpu_has_veic) MSCIC_WRITE(MSC01_IC_SUP+n*8, MSC01_IC_SUP_EDGE_BIT); else MSCIC_WRITE(MSC01_IC_SUP+n*8, MSC01_IC_SUP_EDGE_BIT | imp->im_lvl); break; case MSC01_IRQ_LEVEL: - irq_desc[base+n].handler = &msc_levelirq_type; + irq_desc[base+n].chip = &msc_levelirq_type; if (cpu_has_veic) MSCIC_WRITE(MSC01_IC_SUP+n*8, 0); else diff --git a/arch/mips/kernel/irq-mv6434x.c b/arch/mips/kernel/irq-mv6434x.c index 0613f1f36b1..f9c763a6554 100644 --- a/arch/mips/kernel/irq-mv6434x.c +++ b/arch/mips/kernel/irq-mv6434x.c @@ -155,7 +155,7 @@ void __init mv64340_irq_init(unsigned int base) irq_desc[i].status = IRQ_DISABLED; irq_desc[i].action = 0; irq_desc[i].depth = 2; - irq_desc[i].handler = &mv64340_irq_type; + irq_desc[i].chip = &mv64340_irq_type; } irq_base = base; diff --git a/arch/mips/kernel/irq-rm7000.c b/arch/mips/kernel/irq-rm7000.c index 0b130c5ac5d..121da385a94 100644 --- a/arch/mips/kernel/irq-rm7000.c +++ b/arch/mips/kernel/irq-rm7000.c @@ -91,7 +91,7 @@ void __init rm7k_cpu_irq_init(int base) irq_desc[i].status = IRQ_DISABLED; irq_desc[i].action = NULL; irq_desc[i].depth = 1; - irq_desc[i].handler = &rm7k_irq_controller; + irq_desc[i].chip = &rm7k_irq_controller; } irq_base = base; diff --git a/arch/mips/kernel/irq-rm9000.c b/arch/mips/kernel/irq-rm9000.c index 9b5f20c32ac..25109c103e4 100644 --- a/arch/mips/kernel/irq-rm9000.c +++ b/arch/mips/kernel/irq-rm9000.c @@ -139,11 +139,11 @@ void __init rm9k_cpu_irq_init(int base) irq_desc[i].status = IRQ_DISABLED; irq_desc[i].action = NULL; irq_desc[i].depth = 1; - irq_desc[i].handler = &rm9k_irq_controller; + irq_desc[i].chip = &rm9k_irq_controller; } rm9000_perfcount_irq = base + 1; - irq_desc[rm9000_perfcount_irq].handler = &rm9k_perfcounter_irq; + irq_desc[rm9000_perfcount_irq].chip = &rm9k_perfcounter_irq; irq_base = base; } diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c index 3dce742e716..5c9dcd5eed5 100644 --- a/arch/mips/kernel/irq.c +++ b/arch/mips/kernel/irq.c @@ -95,7 +95,7 @@ int show_interrupts(struct seq_file *p, void *v) for_each_online_cpu(j) seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]); #endif - seq_printf(p, " %14s", irq_desc[i].handler->typename); + seq_printf(p, " %14s", irq_desc[i].chip->typename); seq_printf(p, " %s", action->name); for (action=action->next; action; action = action->next) @@ -137,7 +137,7 @@ void __init init_IRQ(void) irq_desc[i].status = IRQ_DISABLED; irq_desc[i].action = NULL; irq_desc[i].depth = 1; - irq_desc[i].handler = &no_irq_type; + irq_desc[i].chip = &no_irq_type; spin_lock_init(&irq_desc[i].lock); #ifdef CONFIG_MIPS_MT_SMTC irq_hwmask[i] = 0; diff --git a/arch/mips/kernel/irq_cpu.c b/arch/mips/kernel/irq_cpu.c index 5db67e31ec1..0e455a8ad86 100644 --- a/arch/mips/kernel/irq_cpu.c +++ b/arch/mips/kernel/irq_cpu.c @@ -167,14 +167,14 @@ void __init mips_cpu_irq_init(int irq_base) irq_desc[i].status = IRQ_DISABLED; irq_desc[i].action = NULL; irq_desc[i].depth = 1; - irq_desc[i].handler = &mips_mt_cpu_irq_controller; + irq_desc[i].chip = &mips_mt_cpu_irq_controller; } for (i = irq_base + 2; i < irq_base + 8; i++) { irq_desc[i].status = IRQ_DISABLED; irq_desc[i].action = NULL; irq_desc[i].depth = 1; - irq_desc[i].handler = &mips_cpu_irq_controller; + irq_desc[i].chip = &mips_cpu_irq_controller; } mips_cpu_irq_base = irq_base; diff --git a/arch/mips/lasat/interrupt.c b/arch/mips/lasat/interrupt.c index 2d3472b21eb..9316a024a81 100644 --- a/arch/mips/lasat/interrupt.c +++ b/arch/mips/lasat/interrupt.c @@ -156,6 +156,6 @@ void __init arch_init_irq(void) irq_desc[i].status = IRQ_DISABLED; irq_desc[i].action = 0; irq_desc[i].depth = 1; - irq_desc[i].handler = &lasat_irq_type; + irq_desc[i].chip = &lasat_irq_type; } } diff --git a/arch/mips/mips-boards/atlas/atlas_int.c b/arch/mips/mips-boards/atlas/atlas_int.c index db53950b7cf..9dd6b892558 100644 --- a/arch/mips/mips-boards/atlas/atlas_int.c +++ b/arch/mips/mips-boards/atlas/atlas_int.c @@ -215,7 +215,7 @@ void __init arch_init_irq(void) irq_desc[i].status = IRQ_DISABLED; irq_desc[i].action = 0; irq_desc[i].depth = 1; - irq_desc[i].handler = &atlas_irq_type; + irq_desc[i].chip = &atlas_irq_type; spin_lock_init(&irq_desc[i].lock); } } diff --git a/arch/mips/momentum/ocelot_c/cpci-irq.c b/arch/mips/momentum/ocelot_c/cpci-irq.c index bd885785e2f..31d179c4673 100644 --- a/arch/mips/momentum/ocelot_c/cpci-irq.c +++ b/arch/mips/momentum/ocelot_c/cpci-irq.c @@ -147,6 +147,6 @@ void cpci_irq_init(void) irq_desc[i].status = IRQ_DISABLED; irq_desc[i].action = 0; irq_desc[i].depth = 2; - irq_desc[i].handler = &cpci_irq_type; + irq_desc[i].chip = &cpci_irq_type; } } diff --git a/arch/mips/momentum/ocelot_c/uart-irq.c b/arch/mips/momentum/ocelot_c/uart-irq.c index 755bde5146b..852265026fd 100644 --- a/arch/mips/momentum/ocelot_c/uart-irq.c +++ b/arch/mips/momentum/ocelot_c/uart-irq.c @@ -137,10 +137,10 @@ void uart_irq_init(void) irq_desc[80].status = IRQ_DISABLED; irq_desc[80].action = 0; irq_desc[80].depth = 2; - irq_desc[80].handler = &uart_irq_type; + irq_desc[80].chip = &uart_irq_type; irq_desc[81].status = IRQ_DISABLED; irq_desc[81].action = 0; irq_desc[81].depth = 2; - irq_desc[81].handler = &uart_irq_type; + irq_desc[81].chip = &uart_irq_type; } diff --git a/arch/mips/philips/pnx8550/common/int.c b/arch/mips/philips/pnx8550/common/int.c index 39ee6314f62..8f18764a235 100644 --- a/arch/mips/philips/pnx8550/common/int.c +++ b/arch/mips/philips/pnx8550/common/int.c @@ -236,7 +236,7 @@ void __init arch_init_irq(void) int configPR; for (i = 0; i < PNX8550_INT_CP0_TOTINT; i++) { - irq_desc[i].handler = &level_irq_type; + irq_desc[i].chip = &level_irq_type; pnx8550_ack(i); /* mask the irq just in case */ } @@ -273,7 +273,7 @@ void __init arch_init_irq(void) /* mask/priority is still 0 so we will not get any * interrupts until it is unmasked */ - irq_desc[i].handler = &level_irq_type; + irq_desc[i].chip = &level_irq_type; } /* Priority level 0 */ @@ -282,12 +282,12 @@ void __init arch_init_irq(void) /* Set int vector table address */ PNX8550_GIC_VECTOR_0 = PNX8550_GIC_VECTOR_1 = 0; - irq_desc[MIPS_CPU_GIC_IRQ].handler = &level_irq_type; + irq_desc[MIPS_CPU_GIC_IRQ].chip = &level_irq_type; setup_irq(MIPS_CPU_GIC_IRQ, &gic_action); /* init of Timer interrupts */ for (i = PNX8550_INT_TIMER_MIN; i <= PNX8550_INT_TIMER_MAX; i++) { - irq_desc[i].handler = &level_irq_type; + irq_desc[i].chip = &level_irq_type; } /* Stop Timer 1-3 */ @@ -295,7 +295,7 @@ void __init arch_init_irq(void) configPR |= 0x00000038; write_c0_config7(configPR); - irq_desc[MIPS_CPU_TIMER_IRQ].handler = &level_irq_type; + irq_desc[MIPS_CPU_TIMER_IRQ].chip = &level_irq_type; setup_irq(MIPS_CPU_TIMER_IRQ, &timer_action); } diff --git a/arch/mips/sgi-ip22/ip22-eisa.c b/arch/mips/sgi-ip22/ip22-eisa.c index b19820110aa..989167b49ce 100644 --- a/arch/mips/sgi-ip22/ip22-eisa.c +++ b/arch/mips/sgi-ip22/ip22-eisa.c @@ -279,9 +279,9 @@ int __init ip22_eisa_init(void) irq_desc[i].action = 0; irq_desc[i].depth = 1; if (i < (SGINT_EISA + 8)) - irq_desc[i].handler = &ip22_eisa1_irq_type; + irq_desc[i].chip = &ip22_eisa1_irq_type; else - irq_desc[i].handler = &ip22_eisa2_irq_type; + irq_desc[i].chip = &ip22_eisa2_irq_type; } /* Cannot use request_irq because of kmalloc not being ready at such diff --git a/arch/mips/sgi-ip22/ip22-int.c b/arch/mips/sgi-ip22/ip22-int.c index fc6a7e2b189..18906af6969 100644 --- a/arch/mips/sgi-ip22/ip22-int.c +++ b/arch/mips/sgi-ip22/ip22-int.c @@ -436,7 +436,7 @@ void __init arch_init_irq(void) irq_desc[i].status = IRQ_DISABLED; irq_desc[i].action = 0; irq_desc[i].depth = 1; - irq_desc[i].handler = handler; + irq_desc[i].chip = handler; } /* vector handler. this register the IRQ as non-sharable */ diff --git a/arch/mips/sgi-ip27/ip27-irq.c b/arch/mips/sgi-ip27/ip27-irq.c index 0b61a39ce2b..869566c360a 100644 --- a/arch/mips/sgi-ip27/ip27-irq.c +++ b/arch/mips/sgi-ip27/ip27-irq.c @@ -386,7 +386,7 @@ void __devinit register_bridge_irq(unsigned int irq) irq_desc[irq].status = IRQ_DISABLED; irq_desc[irq].action = 0; irq_desc[irq].depth = 1; - irq_desc[irq].handler = &bridge_irq_type; + irq_desc[irq].chip = &bridge_irq_type; } int __devinit request_bridge_irq(struct bridge_controller *bc) diff --git a/arch/mips/sgi-ip32/ip32-irq.c b/arch/mips/sgi-ip32/ip32-irq.c index 8ba08047d16..00b94aaf637 100644 --- a/arch/mips/sgi-ip32/ip32-irq.c +++ b/arch/mips/sgi-ip32/ip32-irq.c @@ -591,7 +591,7 @@ void __init arch_init_irq(void) irq_desc[irq].status = IRQ_DISABLED; irq_desc[irq].action = 0; irq_desc[irq].depth = 0; - irq_desc[irq].handler = controller; + irq_desc[irq].chip = controller; } setup_irq(CRIME_MEMERR_IRQ, &memerr_irq); setup_irq(CRIME_CPUERR_IRQ, &cpuerr_irq); diff --git a/arch/mips/sibyte/bcm1480/irq.c b/arch/mips/sibyte/bcm1480/irq.c index e61760b14d9..610df40cb82 100644 --- a/arch/mips/sibyte/bcm1480/irq.c +++ b/arch/mips/sibyte/bcm1480/irq.c @@ -276,10 +276,10 @@ void __init init_bcm1480_irqs(void) irq_desc[i].action = 0; irq_desc[i].depth = 1; if (i < BCM1480_NR_IRQS) { - irq_desc[i].handler = &bcm1480_irq_type; + irq_desc[i].chip = &bcm1480_irq_type; bcm1480_irq_owner[i] = 0; } else { - irq_desc[i].handler = &no_irq_type; + irq_desc[i].chip = &no_irq_type; } } } diff --git a/arch/mips/sibyte/sb1250/irq.c b/arch/mips/sibyte/sb1250/irq.c index f853c32f60a..fcc61940f1f 100644 --- a/arch/mips/sibyte/sb1250/irq.c +++ b/arch/mips/sibyte/sb1250/irq.c @@ -246,10 +246,10 @@ void __init init_sb1250_irqs(void) irq_desc[i].action = 0; irq_desc[i].depth = 1; if (i < SB1250_NR_IRQS) { - irq_desc[i].handler = &sb1250_irq_type; + irq_desc[i].chip = &sb1250_irq_type; sb1250_irq_owner[i] = 0; } else { - irq_desc[i].handler = &no_irq_type; + irq_desc[i].chip = &no_irq_type; } } } diff --git a/arch/mips/sni/irq.c b/arch/mips/sni/irq.c index 7365b4853dd..c19e158ec40 100644 --- a/arch/mips/sni/irq.c +++ b/arch/mips/sni/irq.c @@ -203,7 +203,7 @@ void __init arch_init_irq(void) irq_desc[i].status = IRQ_DISABLED; irq_desc[i].action = 0; irq_desc[i].depth = 1; - irq_desc[i].handler = &pciasic_irq_type; + irq_desc[i].chip = &pciasic_irq_type; } change_c0_status(ST0_IM, IE_IRQ1|IE_IRQ2|IE_IRQ3|IE_IRQ4); diff --git a/arch/mips/tx4927/common/tx4927_irq.c b/arch/mips/tx4927/common/tx4927_irq.c index 8ca68015cf4..a42be00483e 100644 --- a/arch/mips/tx4927/common/tx4927_irq.c +++ b/arch/mips/tx4927/common/tx4927_irq.c @@ -227,7 +227,7 @@ static void __init tx4927_irq_cp0_init(void) irq_desc[i].status = IRQ_DISABLED; irq_desc[i].action = 0; irq_desc[i].depth = 1; - irq_desc[i].handler = &tx4927_irq_cp0_type; + irq_desc[i].chip = &tx4927_irq_cp0_type; } return; @@ -435,7 +435,7 @@ static void __init tx4927_irq_pic_init(void) irq_desc[i].status = IRQ_DISABLED; irq_desc[i].action = 0; irq_desc[i].depth = 2; - irq_desc[i].handler = &tx4927_irq_pic_type; + irq_desc[i].chip = &tx4927_irq_pic_type; } setup_irq(TX4927_IRQ_NEST_PIC_ON_CP0, &tx4927_irq_pic_action); diff --git a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c b/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c index aee07ff2212..c67978b6dae 100644 --- a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c +++ b/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c @@ -368,7 +368,7 @@ static void __init toshiba_rbtx4927_irq_ioc_init(void) irq_desc[i].status = IRQ_DISABLED; irq_desc[i].action = 0; irq_desc[i].depth = 3; - irq_desc[i].handler = &toshiba_rbtx4927_irq_ioc_type; + irq_desc[i].chip = &toshiba_rbtx4927_irq_ioc_type; } setup_irq(TOSHIBA_RBTX4927_IRQ_NEST_IOC_ON_PIC, @@ -526,7 +526,7 @@ static void __init toshiba_rbtx4927_irq_isa_init(void) irq_desc[i].action = 0; irq_desc[i].depth = ((i < TOSHIBA_RBTX4927_IRQ_ISA_MID) ? (4) : (5)); - irq_desc[i].handler = &toshiba_rbtx4927_irq_isa_type; + irq_desc[i].chip = &toshiba_rbtx4927_irq_isa_type; } setup_irq(TOSHIBA_RBTX4927_IRQ_NEST_ISA_ON_IOC, @@ -692,13 +692,13 @@ void toshiba_rbtx4927_irq_dump(char *key) { u32 i, j = 0; for (i = 0; i < NR_IRQS; i++) { - if (strcmp(irq_desc[i].handler->typename, "none") + if (strcmp(irq_desc[i].chip->typename, "none") == 0) continue; if ((i >= 1) - && (irq_desc[i - 1].handler->typename == - irq_desc[i].handler->typename)) { + && (irq_desc[i - 1].chip->typename == + irq_desc[i].chip->typename)) { j++; } else { j = 0; @@ -707,12 +707,12 @@ void toshiba_rbtx4927_irq_dump(char *key) (TOSHIBA_RBTX4927_IRQ_INFO, "%s irq=0x%02x/%3d s=0x%08x h=0x%08x a=0x%08x ah=0x%08x d=%1d n=%s/%02d\n", key, i, i, irq_desc[i].status, - (u32) irq_desc[i].handler, + (u32) irq_desc[i].chip, (u32) irq_desc[i].action, (u32) (irq_desc[i].action ? irq_desc[i]. action->handler : 0), irq_desc[i].depth, - irq_desc[i].handler->typename, j); + irq_desc[i].chip->typename, j); } } #endif diff --git a/arch/mips/tx4938/common/irq.c b/arch/mips/tx4938/common/irq.c index 873805178d8..0b2f8c84921 100644 --- a/arch/mips/tx4938/common/irq.c +++ b/arch/mips/tx4938/common/irq.c @@ -102,7 +102,7 @@ tx4938_irq_cp0_init(void) irq_desc[i].status = IRQ_DISABLED; irq_desc[i].action = 0; irq_desc[i].depth = 1; - irq_desc[i].handler = &tx4938_irq_cp0_type; + irq_desc[i].chip = &tx4938_irq_cp0_type; } return; @@ -306,7 +306,7 @@ tx4938_irq_pic_init(void) irq_desc[i].status = IRQ_DISABLED; irq_desc[i].action = 0; irq_desc[i].depth = 2; - irq_desc[i].handler = &tx4938_irq_pic_type; + irq_desc[i].chip = &tx4938_irq_pic_type; } setup_irq(TX4938_IRQ_NEST_PIC_ON_CP0, &tx4938_irq_pic_action); diff --git a/arch/mips/tx4938/toshiba_rbtx4938/irq.c b/arch/mips/tx4938/toshiba_rbtx4938/irq.c index 9cd9c0fe226..3b8245dc5bd 100644 --- a/arch/mips/tx4938/toshiba_rbtx4938/irq.c +++ b/arch/mips/tx4938/toshiba_rbtx4938/irq.c @@ -146,7 +146,7 @@ toshiba_rbtx4938_irq_ioc_init(void) irq_desc[i].status = IRQ_DISABLED; irq_desc[i].action = 0; irq_desc[i].depth = 3; - irq_desc[i].handler = &toshiba_rbtx4938_irq_ioc_type; + irq_desc[i].chip = &toshiba_rbtx4938_irq_ioc_type; } setup_irq(RBTX4938_IRQ_IOCINT, diff --git a/arch/mips/vr41xx/common/icu.c b/arch/mips/vr41xx/common/icu.c index 07ae19cf0c2..b9323302cc4 100644 --- a/arch/mips/vr41xx/common/icu.c +++ b/arch/mips/vr41xx/common/icu.c @@ -722,10 +722,10 @@ static int __init vr41xx_icu_init(void) icu2_write(MGIUINTHREG, 0xffff); for (i = SYSINT1_IRQ_BASE; i <= SYSINT1_IRQ_LAST; i++) - irq_desc[i].handler = &sysint1_irq_type; + irq_desc[i].chip = &sysint1_irq_type; for (i = SYSINT2_IRQ_BASE; i <= SYSINT2_IRQ_LAST; i++) - irq_desc[i].handler = &sysint2_irq_type; + irq_desc[i].chip = &sysint2_irq_type; cascade_irq(INT0_IRQ, icu_get_irq); cascade_irq(INT1_IRQ, icu_get_irq); diff --git a/arch/mips/vr41xx/common/irq.c b/arch/mips/vr41xx/common/irq.c index 86796bb63c3..66aa50802de 100644 --- a/arch/mips/vr41xx/common/irq.c +++ b/arch/mips/vr41xx/common/irq.c @@ -73,13 +73,13 @@ static void irq_dispatch(unsigned int irq, struct pt_regs *regs) if (cascade->get_irq != NULL) { unsigned int source_irq = irq; desc = irq_desc + source_irq; - desc->handler->ack(source_irq); + desc->chip->ack(source_irq); irq = cascade->get_irq(irq, regs); if (irq < 0) atomic_inc(&irq_err_count); else irq_dispatch(irq, regs); - desc->handler->end(source_irq); + desc->chip->end(source_irq); } else do_IRQ(irq, regs); } diff --git a/arch/mips/vr41xx/common/vrc4173.c b/arch/mips/vr41xx/common/vrc4173.c index 3e31f8193d2..2d287b8893d 100644 --- a/arch/mips/vr41xx/common/vrc4173.c +++ b/arch/mips/vr41xx/common/vrc4173.c @@ -483,7 +483,7 @@ static inline int vrc4173_icu_init(int cascade_irq) vr41xx_set_irq_level(GIU_IRQ_TO_PIN(cascade_irq), LEVEL_LOW); for (i = VRC4173_IRQ_BASE; i <= VRC4173_IRQ_LAST; i++) - irq_desc[i].handler = &vrc4173_irq_type; + irq_desc[i].chip = &vrc4173_irq_type; return 0; } diff --git a/arch/mips/vr41xx/nec-cmbvr4133/irq.c b/arch/mips/vr41xx/nec-cmbvr4133/irq.c index 31db6b61a39..7b2511ca0a6 100644 --- a/arch/mips/vr41xx/nec-cmbvr4133/irq.c +++ b/arch/mips/vr41xx/nec-cmbvr4133/irq.c @@ -104,7 +104,7 @@ void __init rockhopper_init_irq(void) } for (i = I8259_IRQ_BASE; i <= I8259_IRQ_LAST; i++) - irq_desc[i].handler = &i8259_irq_type; + irq_desc[i].chip = &i8259_irq_type; setup_irq(I8259_SLAVE_IRQ, &i8259_slave_cascade); diff --git a/arch/parisc/kernel/irq.c b/arch/parisc/kernel/irq.c index 197936d9359..26e69f73fdb 100644 --- a/arch/parisc/kernel/irq.c +++ b/arch/parisc/kernel/irq.c @@ -158,7 +158,7 @@ int show_interrupts(struct seq_file *p, void *v) seq_printf(p, "%10u ", kstat_irqs(i)); #endif - seq_printf(p, " %14s", irq_desc[i].handler->typename); + seq_printf(p, " %14s", irq_desc[i].chip->typename); #ifndef PARISC_IRQ_CR16_COUNTS seq_printf(p, " %s", action->name); @@ -210,12 +210,12 @@ int cpu_claim_irq(unsigned int irq, struct hw_interrupt_type *type, void *data) { if (irq_desc[irq].action) return -EBUSY; - if (irq_desc[irq].handler != &cpu_interrupt_type) + if (irq_desc[irq].chip != &cpu_interrupt_type) return -EBUSY; if (type) { - irq_desc[irq].handler = type; - irq_desc[irq].handler_data = data; + irq_desc[irq].chip = type; + irq_desc[irq].chip_data = data; cpu_interrupt_type.enable(irq); } return 0; @@ -378,7 +378,7 @@ static void claim_cpu_irqs(void) { int i; for (i = CPU_IRQ_BASE; i <= CPU_IRQ_MAX; i++) { - irq_desc[i].handler = &cpu_interrupt_type; + irq_desc[i].chip = &cpu_interrupt_type; } irq_desc[TIMER_IRQ].action = &timer_action; diff --git a/arch/powerpc/kernel/crash.c b/arch/powerpc/kernel/crash.c index e253a45dcf1..1bfad7c2f8c 100644 --- a/arch/powerpc/kernel/crash.c +++ b/arch/powerpc/kernel/crash.c @@ -193,10 +193,10 @@ void default_machine_crash_shutdown(struct pt_regs *regs) struct irq_desc *desc = irq_descp(irq); if (desc->status & IRQ_INPROGRESS) - desc->handler->end(irq); + desc->chip->end(irq); if (!(desc->status & IRQ_DISABLED)) - desc->handler->disable(irq); + desc->chip->disable(irq); } if (ppc_md.kexec_cpu_down) diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c index 40d4c14fde8..8cfc779d882 100644 --- a/arch/powerpc/kernel/irq.c +++ b/arch/powerpc/kernel/irq.c @@ -120,8 +120,8 @@ int show_interrupts(struct seq_file *p, void *v) #else seq_printf(p, "%10u ", kstat_irqs(i)); #endif /* CONFIG_SMP */ - if (desc->handler) - seq_printf(p, " %s ", desc->handler->typename); + if (desc->chip) + seq_printf(p, " %s ", desc->chip->typename); else seq_puts(p, " None "); seq_printf(p, "%s", (desc->status & IRQ_LEVEL) ? "Level " : "Edge "); @@ -169,8 +169,8 @@ void fixup_irqs(cpumask_t map) printk("Breaking affinity for irq %i\n", irq); mask = map; } - if (irq_desc[irq].handler->set_affinity) - irq_desc[irq].handler->set_affinity(irq, mask); + if (irq_desc[irq].chip->set_affinity) + irq_desc[irq].chip->set_affinity(irq, mask); else if (irq_desc[irq].action && !(warned++)) printk("Cannot set affinity for irq %i\n", irq); } diff --git a/arch/powerpc/platforms/cell/interrupt.c b/arch/powerpc/platforms/cell/interrupt.c index 1bbf822b4ef..7bff3cbc572 100644 --- a/arch/powerpc/platforms/cell/interrupt.c +++ b/arch/powerpc/platforms/cell/interrupt.c @@ -307,7 +307,7 @@ static void iic_request_ipi(int ipi, const char *name) irq = iic_ipi_to_irq(ipi); /* IPIs are marked SA_INTERRUPT as they must run with irqs * disabled */ - get_irq_desc(irq)->handler = &iic_pic; + get_irq_desc(irq)->chip = &iic_pic; get_irq_desc(irq)->status |= IRQ_PER_CPU; request_irq(irq, iic_ipi_action, SA_INTERRUPT, name, NULL); } @@ -330,7 +330,7 @@ static void iic_setup_spe_handlers(void) for (be=0; be < num_present_cpus() / 2; be++) { for (isrc = 0; isrc < IIC_CLASS_STRIDE * 3; isrc++) { int irq = IIC_NODE_STRIDE * be + IIC_SPE_OFFSET + isrc; - get_irq_desc(irq)->handler = &iic_pic; + get_irq_desc(irq)->chip = &iic_pic; } } } diff --git a/arch/powerpc/platforms/cell/spider-pic.c b/arch/powerpc/platforms/cell/spider-pic.c index 55cbdd77a62..7c3a0b6d34f 100644 --- a/arch/powerpc/platforms/cell/spider-pic.c +++ b/arch/powerpc/platforms/cell/spider-pic.c @@ -162,7 +162,7 @@ void spider_init_IRQ_hardcoded(void) spider_pics[node] = ioremap(spiderpic, 0x800); for (n = 0; n < IIC_NUM_EXT; n++) { int irq = n + IIC_EXT_OFFSET + node * IIC_NODE_STRIDE; - get_irq_desc(irq)->handler = &spider_pic; + get_irq_desc(irq)->chip = &spider_pic; } /* do not mask any interrupts because of level */ @@ -217,7 +217,7 @@ void spider_init_IRQ(void) for (n = 0; n < IIC_NUM_EXT; n++) { int irq = n + IIC_EXT_OFFSET + node * IIC_NODE_STRIDE; - get_irq_desc(irq)->handler = &spider_pic; + get_irq_desc(irq)->chip = &spider_pic; } /* do not mask any interrupts because of level */ diff --git a/arch/powerpc/platforms/iseries/irq.c b/arch/powerpc/platforms/iseries/irq.c index 62bbbcf5ded..33bb4aa0e1e 100644 --- a/arch/powerpc/platforms/iseries/irq.c +++ b/arch/powerpc/platforms/iseries/irq.c @@ -242,9 +242,9 @@ void __init iSeries_activate_IRQs() for_each_irq (irq) { irq_desc_t *desc = get_irq_desc(irq); - if (desc && desc->handler && desc->handler->startup) { + if (desc && desc->chip && desc->chip->startup) { spin_lock_irqsave(&desc->lock, flags); - desc->handler->startup(irq); + desc->chip->startup(irq); spin_unlock_irqrestore(&desc->lock, flags); } } @@ -324,7 +324,7 @@ int __init iSeries_allocate_IRQ(HvBusNumber bus, + function; virtirq = virt_irq_create_mapping(realirq); - irq_desc[virtirq].handler = &iSeries_IRQ_handler; + irq_desc[virtirq].chip = &iSeries_IRQ_handler; return virtirq; } diff --git a/arch/powerpc/platforms/powermac/pic.c b/arch/powerpc/platforms/powermac/pic.c index 18bf3011d1e..9f6189af6dd 100644 --- a/arch/powerpc/platforms/powermac/pic.c +++ b/arch/powerpc/platforms/powermac/pic.c @@ -446,7 +446,7 @@ static void __init pmac_pic_probe_oldstyle(void) /* Set the handler for the main PIC */ for ( i = 0; i < max_real_irqs ; i++ ) - irq_desc[i].handler = &pmac_pic; + irq_desc[i].chip = &pmac_pic; /* Get addresses of first controller if we have a node for it */ BUG_ON(of_address_to_resource(master, 0, &r)); @@ -493,7 +493,7 @@ static void __init pmac_pic_probe_oldstyle(void) /* Setup handlers for secondary controller and hook cascade irq*/ if (slave) { for ( i = max_real_irqs ; i < max_irqs ; i++ ) - irq_desc[i].handler = &gatwick_pic; + irq_desc[i].chip = &gatwick_pic; setup_irq(irq_cascade, &gatwick_cascade_action); } printk(KERN_INFO "irq: System has %d possible interrupts\n", max_irqs); diff --git a/arch/powerpc/platforms/pseries/xics.c b/arch/powerpc/platforms/pseries/xics.c index b14f9b5c114..bdc9e26a93c 100644 --- a/arch/powerpc/platforms/pseries/xics.c +++ b/arch/powerpc/platforms/pseries/xics.c @@ -558,7 +558,7 @@ nextnode: } for (i = irq_offset_value(); i < NR_IRQS; ++i) - get_irq_desc(i)->handler = &xics_pic; + get_irq_desc(i)->chip = &xics_pic; xics_setup_cpu(); @@ -701,9 +701,9 @@ void xics_migrate_irqs_away(void) continue; /* We only need to migrate enabled IRQS */ - if (desc == NULL || desc->handler == NULL + if (desc == NULL || desc->chip == NULL || desc->action == NULL - || desc->handler->set_affinity == NULL) + || desc->chip->set_affinity == NULL) continue; spin_lock_irqsave(&desc->lock, flags); @@ -728,7 +728,7 @@ void xics_migrate_irqs_away(void) virq, cpu); /* Reset affinity to all cpus */ - desc->handler->set_affinity(virq, CPU_MASK_ALL); + desc->chip->set_affinity(virq, CPU_MASK_ALL); irq_affinity[virq] = CPU_MASK_ALL; unlock: spin_unlock_irqrestore(&desc->lock, flags); diff --git a/arch/powerpc/sysdev/i8259.c b/arch/powerpc/sysdev/i8259.c index b7ac32fdd77..2bff30f6d63 100644 --- a/arch/powerpc/sysdev/i8259.c +++ b/arch/powerpc/sysdev/i8259.c @@ -208,7 +208,7 @@ void __init i8259_init(unsigned long intack_addr, int offset) spin_unlock_irqrestore(&i8259_lock, flags); for (i = 0; i < NUM_ISA_INTERRUPTS; ++i) - irq_desc[offset + i].handler = &i8259_pic; + irq_desc[offset + i].chip = &i8259_pic; /* reserve our resources */ setup_irq(offset + 2, &i8259_irqaction); diff --git a/arch/powerpc/sysdev/ipic.c b/arch/powerpc/sysdev/ipic.c index 8f01e0f1d84..46801f5ec03 100644 --- a/arch/powerpc/sysdev/ipic.c +++ b/arch/powerpc/sysdev/ipic.c @@ -472,7 +472,7 @@ void __init ipic_init(phys_addr_t phys_addr, ipic_write(primary_ipic->regs, IPIC_SEMSR, temp); for (i = 0 ; i < NR_IPIC_INTS ; i++) { - irq_desc[i+irq_offset].handler = &ipic; + irq_desc[i+irq_offset].chip = &ipic; irq_desc[i+irq_offset].status = IRQ_LEVEL; } diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c index bffe50d02c9..f4613ee6b7a 100644 --- a/arch/powerpc/sysdev/mpic.c +++ b/arch/powerpc/sysdev/mpic.c @@ -379,14 +379,14 @@ static inline u32 mpic_physmask(u32 cpumask) /* Get the mpic structure from the IPI number */ static inline struct mpic * mpic_from_ipi(unsigned int ipi) { - return container_of(irq_desc[ipi].handler, struct mpic, hc_ipi); + return container_of(irq_desc[ipi].chip, struct mpic, hc_ipi); } #endif /* Get the mpic structure from the irq number */ static inline struct mpic * mpic_from_irq(unsigned int irq) { - return container_of(irq_desc[irq].handler, struct mpic, hc_irq); + return container_of(irq_desc[irq].chip, struct mpic, hc_irq); } /* Send an EOI */ @@ -752,7 +752,7 @@ void __init mpic_init(struct mpic *mpic) if (!(mpic->flags & MPIC_PRIMARY)) continue; irq_desc[mpic->ipi_offset+i].status |= IRQ_PER_CPU; - irq_desc[mpic->ipi_offset+i].handler = &mpic->hc_ipi; + irq_desc[mpic->ipi_offset+i].chip = &mpic->hc_ipi; #endif /* CONFIG_SMP */ } @@ -813,7 +813,7 @@ void __init mpic_init(struct mpic *mpic) /* init linux descriptors */ if (i < mpic->irq_count) { irq_desc[mpic->irq_offset+i].status = level ? IRQ_LEVEL : 0; - irq_desc[mpic->irq_offset+i].handler = &mpic->hc_irq; + irq_desc[mpic->irq_offset+i].chip = &mpic->hc_irq; } } diff --git a/arch/ppc/8xx_io/commproc.c b/arch/ppc/8xx_io/commproc.c index 12b84ca5132..9b3ace26280 100644 --- a/arch/ppc/8xx_io/commproc.c +++ b/arch/ppc/8xx_io/commproc.c @@ -187,7 +187,7 @@ cpm_interrupt_init(void) * interrupt vectors */ for ( i = CPM_IRQ_OFFSET ; i < CPM_IRQ_OFFSET + NR_CPM_INTS ; i++ ) - irq_desc[i].handler = &cpm_pic; + irq_desc[i].chip = &cpm_pic; /* Set our interrupt handler with the core CPU. */ if (setup_irq(CPM_INTERRUPT, &cpm_interrupt_irqaction)) diff --git a/arch/ppc/platforms/apus_setup.c b/arch/ppc/platforms/apus_setup.c index fe0cdc04d43..5c4118a459f 100644 --- a/arch/ppc/platforms/apus_setup.c +++ b/arch/ppc/platforms/apus_setup.c @@ -734,9 +734,9 @@ void apus_init_IRQ(void) for ( i = 0 ; i < AMI_IRQS; i++ ) { irq_desc[i].status = IRQ_LEVEL; if (i < IRQ_AMIGA_AUTO) { - irq_desc[i].handler = &amiga_irqctrl; + irq_desc[i].chip = &amiga_irqctrl; } else { - irq_desc[i].handler = &amiga_sys_irqctrl; + irq_desc[i].chip = &amiga_sys_irqctrl; action = &amiga_sys_irqaction[i-IRQ_AMIGA_AUTO]; if (action->name) setup_irq(i, action); diff --git a/arch/ppc/platforms/sbc82xx.c b/arch/ppc/platforms/sbc82xx.c index 866807b4ad0..41006d2b4b3 100644 --- a/arch/ppc/platforms/sbc82xx.c +++ b/arch/ppc/platforms/sbc82xx.c @@ -172,7 +172,7 @@ void __init sbc82xx_init_IRQ(void) /* Set up the interrupt handlers for the i8259 IRQs */ for (i = NR_SIU_INTS; i < NR_SIU_INTS + 8; i++) { - irq_desc[i].handler = &sbc82xx_i8259_ic; + irq_desc[i].chip = &sbc82xx_i8259_ic; irq_desc[i].status |= IRQ_LEVEL; } diff --git a/arch/ppc/syslib/cpc700_pic.c b/arch/ppc/syslib/cpc700_pic.c index 5add0a919ef..172aa215fdb 100644 --- a/arch/ppc/syslib/cpc700_pic.c +++ b/arch/ppc/syslib/cpc700_pic.c @@ -140,12 +140,12 @@ cpc700_init_IRQ(void) /* IRQ 0 is highest */ for (i = 0; i < 17; i++) { - irq_desc[i].handler = &cpc700_pic; + irq_desc[i].chip = &cpc700_pic; cpc700_pic_init_irq(i); } for (i = 20; i < 32; i++) { - irq_desc[i].handler = &cpc700_pic; + irq_desc[i].chip = &cpc700_pic; cpc700_pic_init_irq(i); } diff --git a/arch/ppc/syslib/cpm2_pic.c b/arch/ppc/syslib/cpm2_pic.c index 29d95d415ce..c0fee0beb81 100644 --- a/arch/ppc/syslib/cpm2_pic.c +++ b/arch/ppc/syslib/cpm2_pic.c @@ -171,7 +171,7 @@ void cpm2_init_IRQ(void) /* Enable chaining to OpenPIC, and make everything level */ for (i = 0; i < NR_CPM_INTS; i++) { - irq_desc[i+CPM_IRQ_OFFSET].handler = &cpm2_pic; + irq_desc[i+CPM_IRQ_OFFSET].chip = &cpm2_pic; irq_desc[i+CPM_IRQ_OFFSET].status |= IRQ_LEVEL; } } diff --git a/arch/ppc/syslib/gt64260_pic.c b/arch/ppc/syslib/gt64260_pic.c index dc3bd9ecbbf..91096b38ae7 100644 --- a/arch/ppc/syslib/gt64260_pic.c +++ b/arch/ppc/syslib/gt64260_pic.c @@ -98,7 +98,7 @@ gt64260_init_irq(void) /* use the gt64260 for all (possible) interrupt sources */ for (i = gt64260_irq_base; i < (gt64260_irq_base + 96); i++) - irq_desc[i].handler = >64260_pic; + irq_desc[i].chip = >64260_pic; if (ppc_md.progress) ppc_md.progress("gt64260_init_irq: exit", 0x0); diff --git a/arch/ppc/syslib/m82xx_pci.c b/arch/ppc/syslib/m82xx_pci.c index 1941a8c7ca9..63fa5b31339 100644 --- a/arch/ppc/syslib/m82xx_pci.c +++ b/arch/ppc/syslib/m82xx_pci.c @@ -159,7 +159,7 @@ pq2pci_init_irq(void) immap->im_memctl.memc_or8 = 0xffff8010; #endif for (irq = NR_CPM_INTS; irq < NR_CPM_INTS + 4; irq++) - irq_desc[irq].handler = &pq2pci_ic; + irq_desc[irq].chip = &pq2pci_ic; /* make PCI IRQ level sensitive */ immap->im_intctl.ic_siexr &= diff --git a/arch/ppc/syslib/m8xx_setup.c b/arch/ppc/syslib/m8xx_setup.c index dae9af78bde..0c4c0de7c59 100644 --- a/arch/ppc/syslib/m8xx_setup.c +++ b/arch/ppc/syslib/m8xx_setup.c @@ -347,13 +347,13 @@ m8xx_init_IRQ(void) int i; for (i = SIU_IRQ_OFFSET ; i < SIU_IRQ_OFFSET + NR_SIU_INTS ; i++) - irq_desc[i].handler = &ppc8xx_pic; + irq_desc[i].chip = &ppc8xx_pic; cpm_interrupt_init(); #if defined(CONFIG_PCI) for (i = I8259_IRQ_OFFSET ; i < I8259_IRQ_OFFSET + NR_8259_INTS ; i++) - irq_desc[i].handler = &i8259_pic; + irq_desc[i].chip = &i8259_pic; i8259_pic_irq_offset = I8259_IRQ_OFFSET; i8259_init(0); diff --git a/arch/ppc/syslib/mpc52xx_pic.c b/arch/ppc/syslib/mpc52xx_pic.c index c4406f9dc6a..6425b5cee7d 100644 --- a/arch/ppc/syslib/mpc52xx_pic.c +++ b/arch/ppc/syslib/mpc52xx_pic.c @@ -204,9 +204,9 @@ mpc52xx_init_irq(void) out_be32(&intr->main_pri1, 0); out_be32(&intr->main_pri2, 0); - /* Initialize irq_desc[i].handler's with mpc52xx_ic. */ + /* Initialize irq_desc[i].chip's with mpc52xx_ic. */ for (i = 0; i < NR_IRQS; i++) { - irq_desc[i].handler = &mpc52xx_ic; + irq_desc[i].chip = &mpc52xx_ic; irq_desc[i].status = IRQ_LEVEL; } diff --git a/arch/ppc/syslib/mv64360_pic.c b/arch/ppc/syslib/mv64360_pic.c index 5a19697060f..a4244d46838 100644 --- a/arch/ppc/syslib/mv64360_pic.c +++ b/arch/ppc/syslib/mv64360_pic.c @@ -119,7 +119,7 @@ mv64360_init_irq(void) /* All interrupts are level interrupts */ for (i = mv64360_irq_base; i < (mv64360_irq_base + 96); i++) { irq_desc[i].status |= IRQ_LEVEL; - irq_desc[i].handler = &mv64360_pic; + irq_desc[i].chip = &mv64360_pic; } if (ppc_md.progress) diff --git a/arch/ppc/syslib/open_pic.c b/arch/ppc/syslib/open_pic.c index 70456c8f998..822058c2983 100644 --- a/arch/ppc/syslib/open_pic.c +++ b/arch/ppc/syslib/open_pic.c @@ -373,7 +373,7 @@ void __init openpic_init(int offset) OPENPIC_VEC_IPI+i+offset); /* IPIs are per-CPU */ irq_desc[OPENPIC_VEC_IPI+i+offset].status |= IRQ_PER_CPU; - irq_desc[OPENPIC_VEC_IPI+i+offset].handler = &open_pic_ipi; + irq_desc[OPENPIC_VEC_IPI+i+offset].chip = &open_pic_ipi; } #endif @@ -408,7 +408,7 @@ void __init openpic_init(int offset) /* Init descriptors */ for (i = offset; i < NumSources + offset; i++) - irq_desc[i].handler = &open_pic; + irq_desc[i].chip = &open_pic; /* Initialize the spurious interrupt */ if (ppc_md.progress) ppc_md.progress("openpic: spurious",0x3bd); diff --git a/arch/ppc/syslib/open_pic2.c b/arch/ppc/syslib/open_pic2.c index bcbe40de26f..b8154efff6e 100644 --- a/arch/ppc/syslib/open_pic2.c +++ b/arch/ppc/syslib/open_pic2.c @@ -290,7 +290,7 @@ void __init openpic2_init(int offset) /* Init descriptors */ for (i = offset; i < NumSources + offset; i++) - irq_desc[i].handler = &open_pic2; + irq_desc[i].chip = &open_pic2; /* Initialize the spurious interrupt */ if (ppc_md.progress) ppc_md.progress("openpic2: spurious",0x3bd); diff --git a/arch/ppc/syslib/ppc403_pic.c b/arch/ppc/syslib/ppc403_pic.c index c46043c4722..1584c8b1229 100644 --- a/arch/ppc/syslib/ppc403_pic.c +++ b/arch/ppc/syslib/ppc403_pic.c @@ -121,5 +121,5 @@ ppc4xx_pic_init(void) ppc_md.get_irq = ppc403_pic_get_irq; for (i = 0; i < NR_IRQS; i++) - irq_desc[i].handler = &ppc403_aic; + irq_desc[i].chip = &ppc403_aic; } diff --git a/arch/ppc/syslib/ppc4xx_pic.c b/arch/ppc/syslib/ppc4xx_pic.c index fd9af0fc0e9..e669c1335d4 100644 --- a/arch/ppc/syslib/ppc4xx_pic.c +++ b/arch/ppc/syslib/ppc4xx_pic.c @@ -276,7 +276,7 @@ void __init ppc4xx_pic_init(void) /* Attach low-level handlers */ for (i = 0; i < (NR_UICS << 5); ++i) { - irq_desc[i].handler = &__uic[i >> 5].decl; + irq_desc[i].chip = &__uic[i >> 5].decl; if (is_level_sensitive(i)) irq_desc[i].status |= IRQ_LEVEL; } diff --git a/arch/ppc/syslib/xilinx_pic.c b/arch/ppc/syslib/xilinx_pic.c index e672b600f31..39a93dc6375 100644 --- a/arch/ppc/syslib/xilinx_pic.c +++ b/arch/ppc/syslib/xilinx_pic.c @@ -143,7 +143,7 @@ ppc4xx_pic_init(void) ppc_md.get_irq = xilinx_pic_get_irq; for (i = 0; i < NR_IRQS; ++i) { - irq_desc[i].handler = &xilinx_intc; + irq_desc[i].chip = &xilinx_intc; if (XPAR_INTC_0_KIND_OF_INTR & (0x00000001 << i)) irq_desc[i].status &= ~IRQ_LEVEL; diff --git a/arch/sh/boards/adx/irq_maskreg.c b/arch/sh/boards/adx/irq_maskreg.c index c0973f8d57b..357fab1bac2 100644 --- a/arch/sh/boards/adx/irq_maskreg.c +++ b/arch/sh/boards/adx/irq_maskreg.c @@ -102,6 +102,6 @@ static void end_maskreg_irq(unsigned int irq) void make_maskreg_irq(unsigned int irq) { disable_irq_nosync(irq); - irq_desc[irq].handler = &maskreg_irq_type; + irq_desc[irq].chip = &maskreg_irq_type; disable_maskreg_irq(irq); } diff --git a/arch/sh/boards/bigsur/irq.c b/arch/sh/boards/bigsur/irq.c index 6ddbcc77244..1d32425782c 100644 --- a/arch/sh/boards/bigsur/irq.c +++ b/arch/sh/boards/bigsur/irq.c @@ -253,7 +253,7 @@ static void make_bigsur_l1isr(unsigned int irq) { /* sanity check first */ if(irq >= BIGSUR_IRQ_LOW && irq < BIGSUR_IRQ_HIGH) { /* save the handler in the main description table */ - irq_desc[irq].handler = &bigsur_l1irq_type; + irq_desc[irq].chip = &bigsur_l1irq_type; irq_desc[irq].status = IRQ_DISABLED; irq_desc[irq].action = 0; irq_desc[irq].depth = 1; @@ -270,7 +270,7 @@ static void make_bigsur_l2isr(unsigned int irq) { /* sanity check first */ if(irq >= BIGSUR_2NDLVL_IRQ_LOW && irq < BIGSUR_2NDLVL_IRQ_HIGH) { /* save the handler in the main description table */ - irq_desc[irq].handler = &bigsur_l2irq_type; + irq_desc[irq].chip = &bigsur_l2irq_type; irq_desc[irq].status = IRQ_DISABLED; irq_desc[irq].action = 0; irq_desc[irq].depth = 1; diff --git a/arch/sh/boards/cqreek/irq.c b/arch/sh/boards/cqreek/irq.c index d1da0d84456..2955adc5231 100644 --- a/arch/sh/boards/cqreek/irq.c +++ b/arch/sh/boards/cqreek/irq.c @@ -103,7 +103,7 @@ void __init init_cqreek_IRQ(void) cqreek_irq_data[14].stat_port = BRIDGE_IDE_INTR_STAT; cqreek_irq_data[14].bit = 1; - irq_desc[14].handler = &cqreek_irq_type; + irq_desc[14].chip = &cqreek_irq_type; irq_desc[14].status = IRQ_DISABLED; irq_desc[14].action = 0; irq_desc[14].depth = 1; @@ -117,7 +117,7 @@ void __init init_cqreek_IRQ(void) cqreek_irq_data[10].bit = (1 << 10); /* XXX: Err... we may need demultiplexer for ISA irq... */ - irq_desc[10].handler = &cqreek_irq_type; + irq_desc[10].chip = &cqreek_irq_type; irq_desc[10].status = IRQ_DISABLED; irq_desc[10].action = 0; irq_desc[10].depth = 1; diff --git a/arch/sh/boards/dreamcast/setup.c b/arch/sh/boards/dreamcast/setup.c index 55dece35cde..0027b80a234 100644 --- a/arch/sh/boards/dreamcast/setup.c +++ b/arch/sh/boards/dreamcast/setup.c @@ -70,7 +70,7 @@ int __init platform_setup(void) /* Assign all virtual IRQs to the System ASIC int. handler */ for (i = HW_EVENT_IRQ_BASE; i < HW_EVENT_IRQ_MAX; i++) - irq_desc[i].handler = &systemasic_int; + irq_desc[i].chip = &systemasic_int; board_time_init = aica_time_init; diff --git a/arch/sh/boards/ec3104/setup.c b/arch/sh/boards/ec3104/setup.c index 5130ba2b6ff..4b3ef16a0e9 100644 --- a/arch/sh/boards/ec3104/setup.c +++ b/arch/sh/boards/ec3104/setup.c @@ -63,7 +63,7 @@ int __init platform_setup(void) str[i] = ctrl_readb(EC3104_BASE + i); for (i = EC3104_IRQBASE; i < EC3104_IRQBASE + 32; i++) - irq_desc[i].handler = &ec3104_int; + irq_desc[i].chip = &ec3104_int; printk("initializing EC3104 \"%.8s\" at %08x, IRQ %d, IRQ base %d\n", str, EC3104_BASE, EC3104_IRQ, EC3104_IRQBASE); diff --git a/arch/sh/boards/harp/irq.c b/arch/sh/boards/harp/irq.c index 52d0ba39031..701fa55d529 100644 --- a/arch/sh/boards/harp/irq.c +++ b/arch/sh/boards/harp/irq.c @@ -114,7 +114,7 @@ static void enable_harp_irq(unsigned int irq) static void __init make_harp_irq(unsigned int irq) { disable_irq_nosync(irq); - irq_desc[irq].handler = &harp_irq_type; + irq_desc[irq].chip = &harp_irq_type; disable_harp_irq(irq); } diff --git a/arch/sh/boards/mpc1211/setup.c b/arch/sh/boards/mpc1211/setup.c index 2bb581b9168..b72f009c52c 100644 --- a/arch/sh/boards/mpc1211/setup.c +++ b/arch/sh/boards/mpc1211/setup.c @@ -194,7 +194,7 @@ static struct hw_interrupt_type mpc1211_irq_type = { static void make_mpc1211_irq(unsigned int irq) { - irq_desc[irq].handler = &mpc1211_irq_type; + irq_desc[irq].chip = &mpc1211_irq_type; irq_desc[irq].status = IRQ_DISABLED; irq_desc[irq].action = 0; irq_desc[irq].depth = 1; diff --git a/arch/sh/boards/overdrive/irq.c b/arch/sh/boards/overdrive/irq.c index 715e8feb3a6..2c13a7de6b2 100644 --- a/arch/sh/boards/overdrive/irq.c +++ b/arch/sh/boards/overdrive/irq.c @@ -150,7 +150,7 @@ static void enable_od_irq(unsigned int irq) static void __init make_od_irq(unsigned int irq) { disable_irq_nosync(irq); - irq_desc[irq].handler = &od_irq_type; + irq_desc[irq].chip = &od_irq_type; disable_od_irq(irq); } diff --git a/arch/sh/boards/renesas/hs7751rvoip/irq.c b/arch/sh/boards/renesas/hs7751rvoip/irq.c index ed4c5b50ea4..52a98b524e1 100644 --- a/arch/sh/boards/renesas/hs7751rvoip/irq.c +++ b/arch/sh/boards/renesas/hs7751rvoip/irq.c @@ -86,7 +86,7 @@ static struct hw_interrupt_type hs7751rvoip_irq_type = { static void make_hs7751rvoip_irq(unsigned int irq) { disable_irq_nosync(irq); - irq_desc[irq].handler = &hs7751rvoip_irq_type; + irq_desc[irq].chip = &hs7751rvoip_irq_type; disable_hs7751rvoip_irq(irq); } diff --git a/arch/sh/boards/renesas/rts7751r2d/irq.c b/arch/sh/boards/renesas/rts7751r2d/irq.c index d36c9374aed..e16915d9cda 100644 --- a/arch/sh/boards/renesas/rts7751r2d/irq.c +++ b/arch/sh/boards/renesas/rts7751r2d/irq.c @@ -100,7 +100,7 @@ static struct hw_interrupt_type rts7751r2d_irq_type = { static void make_rts7751r2d_irq(unsigned int irq) { disable_irq_nosync(irq); - irq_desc[irq].handler = &rts7751r2d_irq_type; + irq_desc[irq].chip = &rts7751r2d_irq_type; disable_rts7751r2d_irq(irq); } diff --git a/arch/sh/boards/renesas/systemh/irq.c b/arch/sh/boards/renesas/systemh/irq.c index 7a2eb10edb5..84597918105 100644 --- a/arch/sh/boards/renesas/systemh/irq.c +++ b/arch/sh/boards/renesas/systemh/irq.c @@ -105,7 +105,7 @@ static void end_systemh_irq(unsigned int irq) void make_systemh_irq(unsigned int irq) { disable_irq_nosync(irq); - irq_desc[irq].handler = &systemh_irq_type; + irq_desc[irq].chip = &systemh_irq_type; disable_systemh_irq(irq); } diff --git a/arch/sh/boards/se/73180/irq.c b/arch/sh/boards/se/73180/irq.c index 70f04caad9a..402735c7c89 100644 --- a/arch/sh/boards/se/73180/irq.c +++ b/arch/sh/boards/se/73180/irq.c @@ -85,7 +85,7 @@ void make_intreq_irq(unsigned int irq) { disable_irq_nosync(irq); - irq_desc[irq].handler = &intreq_irq_type; + irq_desc[irq].chip = &intreq_irq_type; disable_intreq_irq(irq); } diff --git a/arch/sh/boards/superh/microdev/irq.c b/arch/sh/boards/superh/microdev/irq.c index efcbd86b7cd..cb5999425d1 100644 --- a/arch/sh/boards/superh/microdev/irq.c +++ b/arch/sh/boards/superh/microdev/irq.c @@ -147,7 +147,7 @@ static void enable_microdev_irq(unsigned int irq) static void __init make_microdev_irq(unsigned int irq) { disable_irq_nosync(irq); - irq_desc[irq].handler = µdev_irq_type; + irq_desc[irq].chip = µdev_irq_type; disable_microdev_irq(irq); } diff --git a/arch/sh/cchips/hd6446x/hd64461/setup.c b/arch/sh/cchips/hd6446x/hd64461/setup.c index f014b9bf692..724db04cb39 100644 --- a/arch/sh/cchips/hd6446x/hd64461/setup.c +++ b/arch/sh/cchips/hd6446x/hd64461/setup.c @@ -154,7 +154,7 @@ int __init setup_hd64461(void) outw(0xffff, HD64461_NIMR); for (i = HD64461_IRQBASE; i < HD64461_IRQBASE + 16; i++) { - irq_desc[i].handler = &hd64461_irq_type; + irq_desc[i].chip = &hd64461_irq_type; } setup_irq(CONFIG_HD64461_IRQ, &irq0); diff --git a/arch/sh/cchips/hd6446x/hd64465/setup.c b/arch/sh/cchips/hd6446x/hd64465/setup.c index 68e4c4e4283..cf9142c620b 100644 --- a/arch/sh/cchips/hd6446x/hd64465/setup.c +++ b/arch/sh/cchips/hd6446x/hd64465/setup.c @@ -182,7 +182,7 @@ static int __init setup_hd64465(void) outw(0xffff, HD64465_REG_NIMR); /* mask all interrupts */ for (i = 0; i < HD64465_IRQ_NUM ; i++) { - irq_desc[HD64465_IRQ_BASE + i].handler = &hd64465_irq_type; + irq_desc[HD64465_IRQ_BASE + i].chip = &hd64465_irq_type; } setup_irq(CONFIG_HD64465_IRQ, &irq0); diff --git a/arch/sh/cchips/voyagergx/irq.c b/arch/sh/cchips/voyagergx/irq.c index 2ee330b3c38..892214bade1 100644 --- a/arch/sh/cchips/voyagergx/irq.c +++ b/arch/sh/cchips/voyagergx/irq.c @@ -191,7 +191,7 @@ void __init setup_voyagergx_irq(void) flag = 1; } if (flag == 1) - irq_desc[VOYAGER_IRQ_BASE + i].handler = &voyagergx_irq_type; + irq_desc[VOYAGER_IRQ_BASE + i].chip = &voyagergx_irq_type; } setup_irq(IRQ_VOYAGER, &irq0); diff --git a/arch/sh/kernel/cpu/irq/imask.c b/arch/sh/kernel/cpu/irq/imask.c index baed9a550d3..a33ae3e0a5a 100644 --- a/arch/sh/kernel/cpu/irq/imask.c +++ b/arch/sh/kernel/cpu/irq/imask.c @@ -105,6 +105,6 @@ static void shutdown_imask_irq(unsigned int irq) void make_imask_irq(unsigned int irq) { disable_irq_nosync(irq); - irq_desc[irq].handler = &imask_irq_type; + irq_desc[irq].chip = &imask_irq_type; enable_irq(irq); } diff --git a/arch/sh/kernel/cpu/irq/intc2.c b/arch/sh/kernel/cpu/irq/intc2.c index 06e8afab32e..30064bf6e15 100644 --- a/arch/sh/kernel/cpu/irq/intc2.c +++ b/arch/sh/kernel/cpu/irq/intc2.c @@ -137,7 +137,7 @@ void make_intc2_irq(unsigned int irq, local_irq_restore(flags); - irq_desc[irq].handler = &intc2_irq_type; + irq_desc[irq].chip = &intc2_irq_type; disable_intc2_irq(irq); } diff --git a/arch/sh/kernel/cpu/irq/ipr.c b/arch/sh/kernel/cpu/irq/ipr.c index e55150ed085..0373b65c77f 100644 --- a/arch/sh/kernel/cpu/irq/ipr.c +++ b/arch/sh/kernel/cpu/irq/ipr.c @@ -115,7 +115,7 @@ void make_ipr_irq(unsigned int irq, unsigned int addr, int pos, int priority) ipr_data[irq].shift = pos*4; /* POSition (0-3) x 4 means shift */ ipr_data[irq].priority = priority; - irq_desc[irq].handler = &ipr_irq_type; + irq_desc[irq].chip = &ipr_irq_type; disable_ipr_irq(irq); } diff --git a/arch/sh/kernel/cpu/irq/pint.c b/arch/sh/kernel/cpu/irq/pint.c index 95d6024fe1a..714963a25bb 100644 --- a/arch/sh/kernel/cpu/irq/pint.c +++ b/arch/sh/kernel/cpu/irq/pint.c @@ -85,7 +85,7 @@ static void end_pint_irq(unsigned int irq) void make_pint_irq(unsigned int irq) { disable_irq_nosync(irq); - irq_desc[irq].handler = &pint_irq_type; + irq_desc[irq].chip = &pint_irq_type; disable_pint_irq(irq); } diff --git a/arch/sh/kernel/irq.c b/arch/sh/kernel/irq.c index b56e79632f2..c2e07f7f349 100644 --- a/arch/sh/kernel/irq.c +++ b/arch/sh/kernel/irq.c @@ -47,7 +47,7 @@ int show_interrupts(struct seq_file *p, void *v) goto unlock; seq_printf(p, "%3d: ",i); seq_printf(p, "%10u ", kstat_irqs(i)); - seq_printf(p, " %14s", irq_desc[i].handler->typename); + seq_printf(p, " %14s", irq_desc[i].chip->typename); seq_printf(p, " %s", action->name); for (action=action->next; action; action = action->next) diff --git a/arch/sh64/kernel/irq.c b/arch/sh64/kernel/irq.c index d69879c0e06..675776a5477 100644 --- a/arch/sh64/kernel/irq.c +++ b/arch/sh64/kernel/irq.c @@ -65,7 +65,7 @@ int show_interrupts(struct seq_file *p, void *v) goto unlock; seq_printf(p, "%3d: ",i); seq_printf(p, "%10u ", kstat_irqs(i)); - seq_printf(p, " %14s", irq_desc[i].handler->typename); + seq_printf(p, " %14s", irq_desc[i].chip->typename); seq_printf(p, " %s", action->name); for (action=action->next; action; action = action->next) diff --git a/arch/sh64/kernel/irq_intc.c b/arch/sh64/kernel/irq_intc.c index fc99bf4e362..fa730f5fe2e 100644 --- a/arch/sh64/kernel/irq_intc.c +++ b/arch/sh64/kernel/irq_intc.c @@ -178,7 +178,7 @@ static void end_intc_irq(unsigned int irq) void make_intc_irq(unsigned int irq) { disable_irq_nosync(irq); - irq_desc[irq].handler = &intc_irq_type; + irq_desc[irq].chip = &intc_irq_type; disable_intc_irq(irq); } @@ -208,7 +208,7 @@ void __init init_IRQ(void) /* Set default: per-line enable/disable, priority driven ack/eoi */ for (i = 0; i < NR_INTC_IRQS; i++) { if (platform_int_priority[i] != NO_PRIORITY) { - irq_desc[i].handler = &intc_irq_type; + irq_desc[i].chip = &intc_irq_type; } } diff --git a/arch/sh64/mach-cayman/irq.c b/arch/sh64/mach-cayman/irq.c index f797c84bfdd..05eb7cdc26f 100644 --- a/arch/sh64/mach-cayman/irq.c +++ b/arch/sh64/mach-cayman/irq.c @@ -187,7 +187,7 @@ void init_cayman_irq(void) } for (i=0; itypename); + seq_printf(p, " %9s", irq_desc[i].chip->typename); seq_printf(p, " %s", action->name); for (action=action->next; action; action = action->next) @@ -414,8 +414,8 @@ void irq_install_pre_handler(int virt_irq, data->pre_handler_arg1 = arg1; data->pre_handler_arg2 = arg2; - desc->handler = (desc->handler == &sun4u_irq ? - &sun4u_irq_ack : &sun4v_irq_ack); + desc->chip = (desc->chip == &sun4u_irq ? + &sun4u_irq_ack : &sun4v_irq_ack); } unsigned int build_irq(int inofixup, unsigned long iclr, unsigned long imap) @@ -431,7 +431,7 @@ unsigned int build_irq(int inofixup, unsigned long iclr, unsigned long imap) bucket = &ivector_table[ino]; if (!bucket->virt_irq) { bucket->virt_irq = virt_irq_alloc(__irq(bucket)); - irq_desc[bucket->virt_irq].handler = &sun4u_irq; + irq_desc[bucket->virt_irq].chip = &sun4u_irq; } desc = irq_desc + bucket->virt_irq; @@ -465,7 +465,7 @@ unsigned int sun4v_build_irq(u32 devhandle, unsigned int devino) bucket = &ivector_table[sysino]; if (!bucket->virt_irq) { bucket->virt_irq = virt_irq_alloc(__irq(bucket)); - irq_desc[bucket->virt_irq].handler = &sun4v_irq; + irq_desc[bucket->virt_irq].chip = &sun4v_irq; } desc = irq_desc + bucket->virt_irq; diff --git a/arch/um/kernel/irq.c b/arch/um/kernel/irq.c index 2ffda012385..fae43a3054a 100644 --- a/arch/um/kernel/irq.c +++ b/arch/um/kernel/irq.c @@ -63,7 +63,7 @@ int show_interrupts(struct seq_file *p, void *v) for_each_online_cpu(j) seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]); #endif - seq_printf(p, " %14s", irq_desc[i].handler->typename); + seq_printf(p, " %14s", irq_desc[i].chip->typename); seq_printf(p, " %s", action->name); for (action=action->next; action; action = action->next) @@ -451,13 +451,13 @@ void __init init_IRQ(void) irq_desc[TIMER_IRQ].status = IRQ_DISABLED; irq_desc[TIMER_IRQ].action = NULL; irq_desc[TIMER_IRQ].depth = 1; - irq_desc[TIMER_IRQ].handler = &SIGVTALRM_irq_type; + irq_desc[TIMER_IRQ].chip = &SIGVTALRM_irq_type; enable_irq(TIMER_IRQ); for (i = 1; i < NR_IRQS; i++) { irq_desc[i].status = IRQ_DISABLED; irq_desc[i].action = NULL; irq_desc[i].depth = 1; - irq_desc[i].handler = &normal_irq_type; + irq_desc[i].chip = &normal_irq_type; enable_irq(i); } } diff --git a/arch/v850/kernel/irq.c b/arch/v850/kernel/irq.c index 7a151c26f82..858c45819aa 100644 --- a/arch/v850/kernel/irq.c +++ b/arch/v850/kernel/irq.c @@ -65,10 +65,10 @@ int show_interrupts(struct seq_file *p, void *v) int j; int count = 0; int num = -1; - const char *type_name = irq_desc[irq].handler->typename; + const char *type_name = irq_desc[irq].chip->typename; for (j = 0; j < NR_IRQS; j++) - if (irq_desc[j].handler->typename == type_name){ + if (irq_desc[j].chip->typename == type_name){ if (irq == j) num = count; count++; @@ -117,7 +117,7 @@ init_irq_handlers (int base_irq, int num, int interval, irq_desc[base_irq].status = IRQ_DISABLED; irq_desc[base_irq].action = NULL; irq_desc[base_irq].depth = 1; - irq_desc[base_irq].handler = irq_type; + irq_desc[base_irq].chip = irq_type; base_irq += interval; } } diff --git a/arch/x86_64/kernel/i8259.c b/arch/x86_64/kernel/i8259.c index 86b2c1e197a..3dd1659427d 100644 --- a/arch/x86_64/kernel/i8259.c +++ b/arch/x86_64/kernel/i8259.c @@ -235,7 +235,7 @@ void make_8259A_irq(unsigned int irq) { disable_irq_nosync(irq); io_apic_irqs &= ~(1<typename); + seq_printf(p, " %14s", irq_desc[i].chip->typename); seq_printf(p, " %s", action->name); for (action=action->next; action; action = action->next) @@ -151,8 +151,8 @@ void fixup_irqs(cpumask_t map) printk("Breaking affinity for irq %i\n", irq); mask = map; } - if (irq_desc[irq].handler->set_affinity) - irq_desc[irq].handler->set_affinity(irq, mask); + if (irq_desc[irq].chip->set_affinity) + irq_desc[irq].chip->set_affinity(irq, mask); else if (irq_desc[irq].action && !(warned++)) printk("Cannot set affinity for irq %i\n", irq); } diff --git a/arch/xtensa/kernel/irq.c b/arch/xtensa/kernel/irq.c index 51f9bed455f..1cf744ee095 100644 --- a/arch/xtensa/kernel/irq.c +++ b/arch/xtensa/kernel/irq.c @@ -100,7 +100,7 @@ int show_interrupts(struct seq_file *p, void *v) for_each_online_cpu(j) seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]); #endif - seq_printf(p, " %14s", irq_desc[i].handler->typename); + seq_printf(p, " %14s", irq_desc[i].chip->typename); seq_printf(p, " %s", action->name); for (action=action->next; action; action = action->next) @@ -181,7 +181,7 @@ void __init init_IRQ(void) int i; for (i=0; i < XTENSA_NR_IRQS; i++) - irq_desc[i].handler = &xtensa_irq_type; + irq_desc[i].chip = &xtensa_irq_type; cached_irq_mask = 0; diff --git a/drivers/char/vr41xx_giu.c b/drivers/char/vr41xx_giu.c index 05e6e814d86..073da48c092 100644 --- a/drivers/char/vr41xx_giu.c +++ b/drivers/char/vr41xx_giu.c @@ -689,9 +689,9 @@ static int __devinit giu_probe(struct platform_device *dev) for (i = GIU_IRQ_BASE; i <= GIU_IRQ_LAST; i++) { if (i < GIU_IRQ(GIUINT_HIGH_OFFSET)) - irq_desc[i].handler = &giuint_low_irq_type; + irq_desc[i].chip = &giuint_low_irq_type; else - irq_desc[i].handler = &giuint_high_irq_type; + irq_desc[i].chip = &giuint_high_irq_type; } return cascade_irq(GIUINT_IRQ, giu_get_irq); diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c index 6e8ed0c81a6..ce0a6ebcff1 100644 --- a/drivers/parisc/dino.c +++ b/drivers/parisc/dino.c @@ -299,7 +299,7 @@ struct pci_port_ops dino_port_ops = { static void dino_disable_irq(unsigned int irq) { - struct dino_device *dino_dev = irq_desc[irq].handler_data; + struct dino_device *dino_dev = irq_desc[irq].chip_data; int local_irq = gsc_find_local_irq(irq, dino_dev->global_irq, DINO_LOCAL_IRQS); DBG(KERN_WARNING "%s(0x%p, %d)\n", __FUNCTION__, dino_dev, irq); @@ -311,7 +311,7 @@ static void dino_disable_irq(unsigned int irq) static void dino_enable_irq(unsigned int irq) { - struct dino_device *dino_dev = irq_desc[irq].handler_data; + struct dino_device *dino_dev = irq_desc[irq].chip_data; int local_irq = gsc_find_local_irq(irq, dino_dev->global_irq, DINO_LOCAL_IRQS); u32 tmp; diff --git a/drivers/parisc/eisa.c b/drivers/parisc/eisa.c index 9d3bd15bf53..58f0ce8d78e 100644 --- a/drivers/parisc/eisa.c +++ b/drivers/parisc/eisa.c @@ -350,7 +350,7 @@ static int __devinit eisa_probe(struct parisc_device *dev) irq_desc[2].action = &irq2_action; for (i = 0; i < 16; i++) { - irq_desc[i].handler = &eisa_interrupt_type; + irq_desc[i].chip = &eisa_interrupt_type; } EISA_bus = 1; diff --git a/drivers/parisc/gsc.c b/drivers/parisc/gsc.c index 16d40f95978..5476ba7709b 100644 --- a/drivers/parisc/gsc.c +++ b/drivers/parisc/gsc.c @@ -109,7 +109,7 @@ int gsc_find_local_irq(unsigned int irq, int *global_irqs, int limit) static void gsc_asic_disable_irq(unsigned int irq) { - struct gsc_asic *irq_dev = irq_desc[irq].handler_data; + struct gsc_asic *irq_dev = irq_desc[irq].chip_data; int local_irq = gsc_find_local_irq(irq, irq_dev->global_irq, 32); u32 imr; @@ -124,7 +124,7 @@ static void gsc_asic_disable_irq(unsigned int irq) static void gsc_asic_enable_irq(unsigned int irq) { - struct gsc_asic *irq_dev = irq_desc[irq].handler_data; + struct gsc_asic *irq_dev = irq_desc[irq].chip_data; int local_irq = gsc_find_local_irq(irq, irq_dev->global_irq, 32); u32 imr; @@ -164,8 +164,8 @@ int gsc_assign_irq(struct hw_interrupt_type *type, void *data) if (irq > GSC_IRQ_MAX) return NO_IRQ; - irq_desc[irq].handler = type; - irq_desc[irq].handler_data = data; + irq_desc[irq].chip = type; + irq_desc[irq].chip_data = data; return irq++; } diff --git a/drivers/parisc/iosapic.c b/drivers/parisc/iosapic.c index 7a458d5bc75..1fbda77cefc 100644 --- a/drivers/parisc/iosapic.c +++ b/drivers/parisc/iosapic.c @@ -619,7 +619,7 @@ iosapic_set_irt_data( struct vector_info *vi, u32 *dp0, u32 *dp1) static struct vector_info *iosapic_get_vector(unsigned int irq) { - return irq_desc[irq].handler_data; + return irq_desc[irq].chip_data; } static void iosapic_disable_irq(unsigned int irq) diff --git a/drivers/parisc/superio.c b/drivers/parisc/superio.c index 828eb45062d..a988dc7a9ab 100644 --- a/drivers/parisc/superio.c +++ b/drivers/parisc/superio.c @@ -360,7 +360,7 @@ int superio_fixup_irq(struct pci_dev *pcidev) #endif for (i = 0; i < 16; i++) { - irq_desc[i].handler = &superio_interrupt_type; + irq_desc[i].chip = &superio_interrupt_type; } /* diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index 7f8429284fa..76d023d8a33 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c @@ -429,12 +429,12 @@ static void irq_handler_init(int cap_id, int pos, int mask) spin_lock_irqsave(&irq_desc[pos].lock, flags); if (cap_id == PCI_CAP_ID_MSIX) - irq_desc[pos].handler = &msix_irq_type; + irq_desc[pos].chip = &msix_irq_type; else { if (!mask) - irq_desc[pos].handler = &msi_irq_wo_maskbit_type; + irq_desc[pos].chip = &msi_irq_wo_maskbit_type; else - irq_desc[pos].handler = &msi_irq_w_maskbit_type; + irq_desc[pos].chip = &msi_irq_w_maskbit_type; } spin_unlock_irqrestore(&irq_desc[pos].lock, flags); } diff --git a/drivers/pcmcia/hd64465_ss.c b/drivers/pcmcia/hd64465_ss.c index b39435bbfae..c662e4f89d4 100644 --- a/drivers/pcmcia/hd64465_ss.c +++ b/drivers/pcmcia/hd64465_ss.c @@ -244,8 +244,8 @@ static void hs_map_irq(hs_socket_t *sp, unsigned int irq) hs_mapped_irq[irq].sock = sp; /* insert ourselves as the irq controller */ - hs_mapped_irq[irq].old_handler = irq_desc[irq].handler; - irq_desc[irq].handler = &hd64465_ss_irq_type; + hs_mapped_irq[irq].old_handler = irq_desc[irq].chip; + irq_desc[irq].chip = &hd64465_ss_irq_type; } @@ -260,7 +260,7 @@ static void hs_unmap_irq(hs_socket_t *sp, unsigned int irq) return; /* restore the original irq controller */ - irq_desc[irq].handler = hs_mapped_irq[irq].old_handler; + irq_desc[irq].chip = hs_mapped_irq[irq].old_handler; } /*============================================================*/ diff --git a/include/asm-powerpc/hw_irq.h b/include/asm-powerpc/hw_irq.h index ce0f7db63c1..a27ed3feb31 100644 --- a/include/asm-powerpc/hw_irq.h +++ b/include/asm-powerpc/hw_irq.h @@ -86,20 +86,20 @@ static inline void local_irq_save_ptr(unsigned long *flags) #define mask_irq(irq) \ ({ \ irq_desc_t *desc = get_irq_desc(irq); \ - if (desc->handler && desc->handler->disable) \ - desc->handler->disable(irq); \ + if (desc->chip && desc->chip->disable) \ + desc->chip->disable(irq); \ }) #define unmask_irq(irq) \ ({ \ irq_desc_t *desc = get_irq_desc(irq); \ - if (desc->handler && desc->handler->enable) \ - desc->handler->enable(irq); \ + if (desc->chip && desc->chip->enable) \ + desc->chip->enable(irq); \ }) #define ack_irq(irq) \ ({ \ irq_desc_t *desc = get_irq_desc(irq); \ - if (desc->handler && desc->handler->ack) \ - desc->handler->ack(irq); \ + if (desc->chip && desc->chip->ack) \ + desc->chip->ack(irq); \ }) /* Should we handle this via lost interrupts and IPIs or should we don't care like diff --git a/include/linux/irq.h b/include/linux/irq.h index 676e00dfb21..9597a690423 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -69,8 +69,8 @@ typedef struct hw_interrupt_type hw_irq_controller; * Pad this out to 32 bytes for cache and indexing reasons. */ typedef struct irq_desc { - hw_irq_controller *handler; - void *handler_data; + hw_irq_controller *chip; + void *chip_data; struct irqaction *action; /* IRQ action list */ unsigned int status; /* IRQ status */ unsigned int depth; /* nested irq disables */ diff --git a/kernel/irq/autoprobe.c b/kernel/irq/autoprobe.c index 3467097ca61..6f1e68a46cb 100644 --- a/kernel/irq/autoprobe.c +++ b/kernel/irq/autoprobe.c @@ -41,7 +41,7 @@ unsigned long probe_irq_on(void) spin_lock_irq(&desc->lock); if (!irq_desc[i].action) - irq_desc[i].handler->startup(i); + irq_desc[i].chip->startup(i); spin_unlock_irq(&desc->lock); } @@ -59,7 +59,7 @@ unsigned long probe_irq_on(void) spin_lock_irq(&desc->lock); if (!desc->action) { desc->status |= IRQ_AUTODETECT | IRQ_WAITING; - if (desc->handler->startup(i)) + if (desc->chip->startup(i)) desc->status |= IRQ_PENDING; } spin_unlock_irq(&desc->lock); @@ -85,7 +85,7 @@ unsigned long probe_irq_on(void) /* It triggered already - consider it spurious. */ if (!(status & IRQ_WAITING)) { desc->status = status & ~IRQ_AUTODETECT; - desc->handler->shutdown(i); + desc->chip->shutdown(i); } else if (i < 32) val |= 1 << i; @@ -128,7 +128,7 @@ unsigned int probe_irq_mask(unsigned long val) mask |= 1 << i; desc->status = status & ~IRQ_AUTODETECT; - desc->handler->shutdown(i); + desc->chip->shutdown(i); } spin_unlock_irq(&desc->lock); } @@ -173,7 +173,7 @@ int probe_irq_off(unsigned long val) nr_irqs++; } desc->status = status & ~IRQ_AUTODETECT; - desc->handler->shutdown(i); + desc->chip->shutdown(i); } spin_unlock_irq(&desc->lock); } diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c index 0f653011710..f9d95705a4a 100644 --- a/kernel/irq/handle.c +++ b/kernel/irq/handle.c @@ -31,7 +31,7 @@ irq_desc_t irq_desc[NR_IRQS] __cacheline_aligned = { [0 ... NR_IRQS-1] = { .status = IRQ_DISABLED, - .handler = &no_irq_type, + .chip = &no_irq_type, .lock = SPIN_LOCK_UNLOCKED } }; @@ -118,16 +118,16 @@ fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs) /* * No locking required for CPU-local interrupts: */ - if (desc->handler->ack) - desc->handler->ack(irq); + if (desc->chip->ack) + desc->chip->ack(irq); action_ret = handle_IRQ_event(irq, regs, desc->action); - desc->handler->end(irq); + desc->chip->end(irq); return 1; } spin_lock(&desc->lock); - if (desc->handler->ack) - desc->handler->ack(irq); + if (desc->chip->ack) + desc->chip->ack(irq); /* * REPLAY is when Linux resends an IRQ that was dropped earlier * WAITING is used by probe to mark irqs that are being tested @@ -187,7 +187,7 @@ out: * The ->end() handler has to deal with interrupts which got * disabled while the handler was running. */ - desc->handler->end(irq); + desc->chip->end(irq); spin_unlock(&desc->lock); return 1; diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index 1279e349953..31ee1f3bfcf 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -69,7 +69,7 @@ void disable_irq_nosync(unsigned int irq) spin_lock_irqsave(&desc->lock, flags); if (!desc->depth++) { desc->status |= IRQ_DISABLED; - desc->handler->disable(irq); + desc->chip->disable(irq); } spin_unlock_irqrestore(&desc->lock, flags); } @@ -131,9 +131,9 @@ void enable_irq(unsigned int irq) desc->status = status; if ((status & (IRQ_PENDING | IRQ_REPLAY)) == IRQ_PENDING) { desc->status = status | IRQ_REPLAY; - hw_resend_irq(desc->handler,irq); + hw_resend_irq(desc->chip,irq); } - desc->handler->enable(irq); + desc->chip->enable(irq); /* fall-through */ } default: @@ -178,7 +178,7 @@ int setup_irq(unsigned int irq, struct irqaction * new) if (irq >= NR_IRQS) return -EINVAL; - if (desc->handler == &no_irq_type) + if (desc->chip == &no_irq_type) return -ENOSYS; /* * Some drivers like serial.c use request_irq() heavily, @@ -230,10 +230,10 @@ int setup_irq(unsigned int irq, struct irqaction * new) desc->depth = 0; desc->status &= ~(IRQ_DISABLED | IRQ_AUTODETECT | IRQ_WAITING | IRQ_INPROGRESS); - if (desc->handler->startup) - desc->handler->startup(irq); + if (desc->chip->startup) + desc->chip->startup(irq); else - desc->handler->enable(irq); + desc->chip->enable(irq); } spin_unlock_irqrestore(&desc->lock,flags); @@ -295,16 +295,16 @@ void free_irq(unsigned int irq, void *dev_id) /* Currently used only by UML, might disappear one day.*/ #ifdef CONFIG_IRQ_RELEASE_METHOD - if (desc->handler->release) - desc->handler->release(irq, dev_id); + if (desc->chip->release) + desc->chip->release(irq, dev_id); #endif if (!desc->action) { desc->status |= IRQ_DISABLED; - if (desc->handler->shutdown) - desc->handler->shutdown(irq); + if (desc->chip->shutdown) + desc->chip->shutdown(irq); else - desc->handler->disable(irq); + desc->chip->disable(irq); } spin_unlock_irqrestore(&desc->lock,flags); unregister_handler_proc(irq, action); diff --git a/kernel/irq/migration.c b/kernel/irq/migration.c index a12d00eb5e7..d978c87bca9 100644 --- a/kernel/irq/migration.c +++ b/kernel/irq/migration.c @@ -33,7 +33,7 @@ void move_native_irq(int irq) if (unlikely(cpus_empty(pending_irq_cpumask[irq]))) return; - if (!desc->handler->set_affinity) + if (!desc->chip->set_affinity) return; assert_spin_locked(&desc->lock); @@ -51,12 +51,12 @@ void move_native_irq(int irq) */ if (likely(!cpus_empty(tmp))) { if (likely(!(desc->status & IRQ_DISABLED))) - desc->handler->disable(irq); + desc->chip->disable(irq); - desc->handler->set_affinity(irq,tmp); + desc->chip->set_affinity(irq,tmp); if (likely(!(desc->status & IRQ_DISABLED))) - desc->handler->enable(irq); + desc->chip->enable(irq); } cpus_clear(pending_irq_cpumask[irq]); } diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c index afacd6f585f..90fe05f23e6 100644 --- a/kernel/irq/proc.c +++ b/kernel/irq/proc.c @@ -37,7 +37,7 @@ void proc_set_irq_affinity(unsigned int irq, cpumask_t mask_val) { set_balance_irq_affinity(irq, mask_val); irq_affinity[irq] = mask_val; - irq_desc[irq].handler->set_affinity(irq, mask_val); + irq_desc[irq].chip->set_affinity(irq, mask_val); } #endif @@ -59,7 +59,7 @@ static int irq_affinity_write_proc(struct file *file, const char __user *buffer, unsigned int irq = (int)(long)data, full_count = count, err; cpumask_t new_value, tmp; - if (!irq_desc[irq].handler->set_affinity || no_irq_affinity) + if (!irq_desc[irq].chip->set_affinity || no_irq_affinity) return -EIO; err = cpumask_parse(buffer, count, new_value); @@ -122,7 +122,7 @@ void register_irq_proc(unsigned int irq) char name [MAX_NAMELEN]; if (!root_irq_dir || - (irq_desc[irq].handler == &no_irq_type) || + (irq_desc[irq].chip == &no_irq_type) || irq_dir[irq]) return; diff --git a/kernel/irq/spurious.c b/kernel/irq/spurious.c index b2fb3c18d06..ea3ceed362d 100644 --- a/kernel/irq/spurious.c +++ b/kernel/irq/spurious.c @@ -81,7 +81,7 @@ static int misrouted_irq(int irq, struct pt_regs *regs) * IRQ controller clean up too */ if(work) - desc->handler->end(i); + desc->chip->end(i); spin_unlock(&desc->lock); } /* So the caller can adjust the irq error counts */ @@ -166,7 +166,7 @@ void note_interrupt(unsigned int irq, irq_desc_t *desc, irqreturn_t action_ret, */ printk(KERN_EMERG "Disabling IRQ #%d\n", irq); desc->status |= IRQ_DISABLED; - desc->handler->disable(irq); + desc->chip->disable(irq); } desc->irqs_unhandled = 0; } -- cgit v1.2.3-70-g09d2