* [PATCH 0/17] various irq handler cleanups
@ 2007-10-21 7:52 Jeff Garzik
2007-10-21 7:52 ` [PATCH 1/17] " Jeff Garzik
` (16 more replies)
0 siblings, 17 replies; 24+ messages in thread
From: Jeff Garzik @ 2007-10-21 7:52 UTC (permalink / raw)
To: LKML
This series continues the work of running through irq handlers that use
their 'irq' argument -- almost always for trivial (or even wrong)
reasons.
In many cases, this work eliminates some pointless code in the fastpath,
and/or otherwise makes interrupt handling [ever so] slightly more
efficient and clean.
As usual, this work is being committed to the 'irq-cleanups' branch of
git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/misc-2.6.git
which encompasses the following changes (includes some previously
posted, and not re-posted in this series):
older cleanups:
[PARPORT] Consolidate code copies into a single generic irq handler
[PARPORT] Kill useful 'irq' arg from parport_{generic_irq,ieee1284_interru
[PARPORT] Remove unused 'irq' argument from parport irq functions
[BLUETOOTH] Eliminate checks for impossible conditions in irq handler
Eliminate pointless casts from void* in a few driver irq handlers.
[SPARC, XEN, NET/CXGB3] use irq_handler_t where appropriate
[NETDRVR] lib82596, netxen: delete pointless tests from irq handler
[SCSI] aha152x: delete pointless test in irq handler
[ATM, CHAR, TOUCHSCREEN] remove needless use of irq handler first arg
new cleanups:
[IRQ ARG CLEANUP] more driver cleanups
drivers/char/ip2: split out irq core logic into separate function
drivers/char/ip2: separate polling and irq-driven work entry points
char/pcmcia/synclink_cs: trim trailing whitespace
drivers/char/pcmcia/synclink_cs.c: irq handler cleanups
drivers/char/riscom8: irq handler cleanups
drivers/char/{rio,specialix,sx}: irq handler cleanups
arch/x86/kernel/vm86_32.c: irq handler cleanup
drivers/char/{synclink,tpm}: irq handler cleanups
drivers/input/serio/i8042.c: irq handler clean
isdn/act2000: fix major bug. clean irq handler.
isdn/sc: irq handler clean
[netdrvr] driver irq handler cleanups
pcmcia/i82365: irq handler cleanups
serial, rtc/ds1374: irq handler cleanups
[SCSI] driver irq handler cleanups
RTC interrupt handling cleanups
^ permalink raw reply [flat|nested] 24+ messages in thread* [PATCH 1/17] various irq handler cleanups 2007-10-21 7:52 [PATCH 0/17] various irq handler cleanups Jeff Garzik @ 2007-10-21 7:52 ` Jeff Garzik 2007-10-21 7:52 ` [PATCH 2/17] drivers/char/ip2: split out irq core logic into separate function Jeff Garzik ` (15 subsequent siblings) 16 siblings, 0 replies; 24+ messages in thread From: Jeff Garzik @ 2007-10-21 7:52 UTC (permalink / raw) To: LKML; +Cc: acme, chas, linux-serial commit a33c4b813fea228053f6e6747bc9786f3e3db58d Author: Jeff Garzik <jeff@garzik.org> Date: Fri Oct 19 15:10:54 2007 -0400 [IRQ ARG CLEANUP] more driver cleanups drivers/atm/ambassador.c | 7 ++++--- drivers/char/cyclades.c | 17 +---------------- drivers/char/mwave/tp3780i.c | 14 ++++++++++---- drivers/serial/8250.c | 1 + 5 files changed, 17 insertions(+), 25 deletions(-) a33c4b813fea228053f6e6747bc9786f3e3db58d diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c index c2b9464..da0895e 100644 --- a/drivers/atm/ambassador.c +++ b/drivers/atm/ambassador.c @@ -862,8 +862,9 @@ static inline void interrupts_off (amb_dev * dev) { /********** interrupt handling **********/ -static irqreturn_t interrupt_handler(int irq, void *dev_id) { - amb_dev * dev = dev_id; +static irqreturn_t interrupt_handler(int irq, void *dev_id) +{ + amb_dev *dev = dev_id; PRINTD (DBG_IRQ|DBG_FLOW, "interrupt_handler: %p", dev_id); @@ -872,7 +873,7 @@ static irqreturn_t interrupt_handler(int irq, void *dev_id) { // for us or someone else sharing the same interrupt if (!interrupt) { - PRINTD (DBG_IRQ, "irq not for me"); + PRINTD (DBG_IRQ, "no irq events pending"); return IRQ_NONE; } diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c index d1bd0f0..b1b5799 100644 --- a/drivers/char/cyclades.c +++ b/drivers/char/cyclades.c @@ -1318,13 +1318,6 @@ static irqreturn_t cyy_interrupt(int irq, void *dev_id) unsigned int chip, too_many, had_work; int index; - if (unlikely(cinfo == NULL)) { -#ifdef CY_DEBUG_INTERRUPTS - printk(KERN_DEBUG "cyy_interrupt: spurious interrupt %d\n",irq); -#endif - return IRQ_NONE; /* spurious interrupt */ - } - card_base_addr = cinfo->base_addr; index = cinfo->bus_index; @@ -1730,17 +1723,9 @@ static irqreturn_t cyz_interrupt(int irq, void *dev_id) { struct cyclades_card *cinfo = dev_id; - if (unlikely(cinfo == NULL)) { -#ifdef CY_DEBUG_INTERRUPTS - printk(KERN_DEBUG "cyz_interrupt: spurious interrupt %d\n",irq); -#endif - return IRQ_NONE; /* spurious interrupt */ - } - if (unlikely(!ISZLOADED(*cinfo))) { #ifdef CY_DEBUG_INTERRUPTS - printk(KERN_DEBUG "cyz_interrupt: board not yet loaded " - "(IRQ%d).\n", irq); + printk(KERN_DEBUG "cyz_interrupt: board not yet loaded\n"); #endif return IRQ_NONE; } diff --git a/drivers/char/mwave/tp3780i.c b/drivers/char/mwave/tp3780i.c index f282976..37fe80d 100644 --- a/drivers/char/mwave/tp3780i.c +++ b/drivers/char/mwave/tp3780i.c @@ -97,20 +97,24 @@ static void EnableSRAM(THINKPAD_BD_DATA * pBDData) static irqreturn_t UartInterrupt(int irq, void *dev_id) { + int irqno = (int)(unsigned long) dev_id; + PRINTK_3(TRACE_TP3780I, - "tp3780i::UartInterrupt entry irq %x dev_id %p\n", irq, dev_id); + "tp3780i::UartInterrupt entry irq %x dev_id %p\n", irqno, dev_id); return IRQ_HANDLED; } static irqreturn_t DspInterrupt(int irq, void *dev_id) { + int irqno = (int)(unsigned long) dev_id; + pMWAVE_DEVICE_DATA pDrvData = &mwave_s_mdd; DSP_3780I_CONFIG_SETTINGS *pSettings = &pDrvData->rBDData.rDspSettings; unsigned short usDspBaseIO = pSettings->usDspBaseIO; unsigned short usIPCSource = 0, usIsolationMask, usPCNum; PRINTK_3(TRACE_TP3780I, - "tp3780i::DspInterrupt entry irq %x dev_id %p\n", irq, dev_id); + "tp3780i::DspInterrupt entry irq %x dev_id %p\n", irqno, dev_id); if (dsp3780I_GetIPCSource(usDspBaseIO, &usIPCSource) == 0) { PRINTK_2(TRACE_TP3780I, @@ -361,14 +365,16 @@ int tp3780I_EnableDSP(THINKPAD_BD_DATA * pBDData) pSettings->bPllBypass = TP_CFG_PllBypass; pSettings->usChipletEnable = TP_CFG_ChipletEnable; - if (request_irq(pSettings->usUartIrq, &UartInterrupt, 0, "mwave_uart", NULL)) { + if (request_irq(pSettings->usUartIrq, &UartInterrupt, 0, "mwave_uart", + (void *)(unsigned long) pSettings->usUartIrq)) { PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_EnableDSP: Error: Could not get UART IRQ %x\n", pSettings->usUartIrq); goto exit_cleanup; } else { /* no conflict just release */ free_irq(pSettings->usUartIrq, NULL); } - if (request_irq(pSettings->usDspIrq, &DspInterrupt, 0, "mwave_3780i", NULL)) { + if (request_irq(pSettings->usDspIrq, &DspInterrupt, 0, "mwave_3780i", + (void *)(unsigned long) pSettings->usDspIrq)) { PRINTK_ERROR("tp3780i::tp3780I_EnableDSP: Error: Could not get 3780i IRQ %x\n", pSettings->usDspIrq); goto exit_cleanup; } else { diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c index f94109c..0d661ba 100644 --- a/drivers/serial/8250.c +++ b/drivers/serial/8250.c @@ -40,6 +40,7 @@ #include <linux/serial_8250.h> #include <linux/nmi.h> #include <linux/mutex.h> +#include <linux/interrupt.h> #include <asm/io.h> #include <asm/irq.h> ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 2/17] drivers/char/ip2: split out irq core logic into separate function 2007-10-21 7:52 [PATCH 0/17] various irq handler cleanups Jeff Garzik 2007-10-21 7:52 ` [PATCH 1/17] " Jeff Garzik @ 2007-10-21 7:52 ` Jeff Garzik 2007-10-21 7:52 ` [PATCH 3/17] drivers/char/ip2: separate polling and irq-driven work entry points Jeff Garzik ` (14 subsequent siblings) 16 siblings, 0 replies; 24+ messages in thread From: Jeff Garzik @ 2007-10-21 7:52 UTC (permalink / raw) To: LKML commit 630a62678c4be9cb00500904185212cdb221c92a Author: Jeff Garzik <jeff@garzik.org> Date: Fri Oct 19 15:24:59 2007 -0400 drivers/char/ip2: split out irq core logic into separate function No changes besides code movement and glue. Signed-off-by: Jeff Garzik <jgarzik@redhat.com> drivers/char/ip2/ip2main.c | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) 630a62678c4be9cb00500904185212cdb221c92a diff --git a/drivers/char/ip2/ip2main.c b/drivers/char/ip2/ip2main.c index 2124dce..150e1e3 100644 --- a/drivers/char/ip2/ip2main.c +++ b/drivers/char/ip2/ip2main.c @@ -1166,6 +1166,31 @@ ip2_interrupt_bh(struct work_struct *work) /* */ /* */ /******************************************************************************/ +static void +ip2_irq_work(i2eBordStrPtr pB) +{ +#ifdef USE_IQI + if (NO_MAIL_HERE != ( pB->i2eStartMail = iiGetMail(pB))) { +// Disable his interrupt (will be enabled when serviced) +// This is mostly to protect from reentrancy. + iiDisableMailIrq(pB); + +// Park the board on the immediate queue for processing. + schedule_work(&pB->tqueue_interrupt); + +// Make sure the immediate queue is flagged to fire. + } +#else + +// We are using immediate servicing here. This sucks and can +// cause all sorts of havoc with ppp and others. The failsafe +// check on iiSendPendingMail could also throw a hairball. + + i2ServiceBoard( pB ); + +#endif /* USE_IQI */ +} + static irqreturn_t ip2_interrupt(int irq, void *dev_id) { @@ -1184,24 +1209,7 @@ ip2_interrupt(int irq, void *dev_id) if ( pB && (pB->i2eUsingIrq == irq) ) { handled = 1; -#ifdef USE_IQI - - if (NO_MAIL_HERE != ( pB->i2eStartMail = iiGetMail(pB))) { -// Disable his interrupt (will be enabled when serviced) -// This is mostly to protect from reentrancy. - iiDisableMailIrq(pB); - -// Park the board on the immediate queue for processing. - schedule_work(&pB->tqueue_interrupt); - -// Make sure the immediate queue is flagged to fire. - } -#else -// We are using immediate servicing here. This sucks and can -// cause all sorts of havoc with ppp and others. The failsafe -// check on iiSendPendingMail could also throw a hairball. - i2ServiceBoard( pB ); -#endif /* USE_IQI */ + ip2_irq_work(pB); } } ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 3/17] drivers/char/ip2: separate polling and irq-driven work entry points 2007-10-21 7:52 [PATCH 0/17] various irq handler cleanups Jeff Garzik 2007-10-21 7:52 ` [PATCH 1/17] " Jeff Garzik 2007-10-21 7:52 ` [PATCH 2/17] drivers/char/ip2: split out irq core logic into separate function Jeff Garzik @ 2007-10-21 7:52 ` Jeff Garzik 2007-10-21 7:52 ` [PATCH 4/17] char/pcmcia/synclink_cs: trim trailing whitespace Jeff Garzik ` (13 subsequent siblings) 16 siblings, 0 replies; 24+ messages in thread From: Jeff Garzik @ 2007-10-21 7:52 UTC (permalink / raw) To: LKML commit 5fd7ce2334028e79571afef911f938dd20715bc0 Author: Jeff Garzik <jeff@garzik.org> Date: Fri Oct 19 15:38:40 2007 -0400 drivers/char/ip2: separate polling and irq-driven work entry points Polling currently calls the irq handler, which loops through all the boards, calling the work function for all polling boards with work. irq handling loops through all the boards, finding the specific board that applies to us, and calling the work just for that one board. The two logics are sufficiently different to warrant different functions, rather than being slack and calling the same function in two different ways. This serves to make the interrupt handler a -lot- more efficient. Signed-off-by: Jeff Garzik <jgarzik@redhat.com> drivers/char/ip2/ip2main.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) 5fd7ce2334028e79571afef911f938dd20715bc0 diff --git a/drivers/char/ip2/ip2main.c b/drivers/char/ip2/ip2main.c index 150e1e3..e04e66c 100644 --- a/drivers/char/ip2/ip2main.c +++ b/drivers/char/ip2/ip2main.c @@ -752,7 +752,7 @@ retry: continue; rc = request_irq( ip2config.irq[i], ip2_interrupt, IP2_SA_FLAGS | (ip2config.type[i] == PCI ? IRQF_SHARED : 0), - pcName, (void *)&pcName); + pcName, i2BoardPtrTable[i]); if (rc) { printk(KERN_ERR "IP2: an request_irq failed: error %d\n",rc); ip2config.irq[i] = CIR_POLL; @@ -1191,12 +1191,12 @@ ip2_irq_work(i2eBordStrPtr pB) #endif /* USE_IQI */ } -static irqreturn_t -ip2_interrupt(int irq, void *dev_id) +static void +ip2_polled_interrupt(void) { int i; i2eBordStrPtr pB; - int handled = 0; + const int irq = 0; ip2trace (ITRC_NO_PORT, ITRC_INTR, 99, 1, irq ); @@ -1208,7 +1208,6 @@ ip2_interrupt(int irq, void *dev_id) // IRQ = 0 for polled boards, we won't poll "IRQ" boards if ( pB && (pB->i2eUsingIrq == irq) ) { - handled = 1; ip2_irq_work(pB); } } @@ -1216,7 +1215,21 @@ ip2_interrupt(int irq, void *dev_id) ++irq_counter; ip2trace (ITRC_NO_PORT, ITRC_INTR, ITRC_RETURN, 0 ); - return IRQ_RETVAL(handled); +} + +static irqreturn_t +ip2_interrupt(int irq, void *dev_id) +{ + i2eBordStrPtr pB = dev_id; + + ip2trace (ITRC_NO_PORT, ITRC_INTR, 99, 1, pB->i2eUsingIrq ); + + ip2_irq_work(pB); + + ++irq_counter; + + ip2trace (ITRC_NO_PORT, ITRC_INTR, ITRC_RETURN, 0 ); + return IRQ_HANDLED; } /******************************************************************************/ @@ -1239,7 +1252,7 @@ ip2_poll(unsigned long arg) // Just polled boards, IRQ = 0 will hit all non-interrupt boards. // It will NOT poll boards handled by hard interrupts. // The issue of queued BH interrups is handled in ip2_interrupt(). - ip2_interrupt(0, NULL); + ip2_polled_interrupt(); PollTimer.expires = POLL_TIMEOUT; add_timer( &PollTimer ); ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 4/17] char/pcmcia/synclink_cs: trim trailing whitespace 2007-10-21 7:52 [PATCH 0/17] various irq handler cleanups Jeff Garzik ` (2 preceding siblings ...) 2007-10-21 7:52 ` [PATCH 3/17] drivers/char/ip2: separate polling and irq-driven work entry points Jeff Garzik @ 2007-10-21 7:52 ` Jeff Garzik 2007-10-21 7:52 ` [PATCH 5/17] drivers/char/pcmcia/synclink_cs.c: irq handler cleanups Jeff Garzik ` (12 subsequent siblings) 16 siblings, 0 replies; 24+ messages in thread From: Jeff Garzik @ 2007-10-21 7:52 UTC (permalink / raw) To: LKML; +Cc: paulkf commit b81d07c9cc372d7c6e8ea4f854330e860db8801c Author: Jeff Garzik <jeff@garzik.org> Date: Fri Oct 19 15:45:35 2007 -0400 char/pcmcia/synclink_cs: trim trailing whitespace Signed-off-by: Jeff Garzik <jgarzik@redhat.com> drivers/char/pcmcia/synclink_cs.c | 706 +++++++++++++++++++------------------- 1 file changed, 353 insertions(+), 353 deletions(-) b81d07c9cc372d7c6e8ea4f854330e860db8801c diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index 2b88931..8caff0c 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c @@ -123,7 +123,7 @@ typedef struct #define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK)) struct _input_signal_events { - int ri_up; + int ri_up; int ri_down; int dsr_up; int dsr_down; @@ -137,7 +137,7 @@ struct _input_signal_events { /* * Device instance data structure */ - + typedef struct _mgslpc_info { void *if_ptr; /* General purpose pointer (used by SPPP) */ int magic; @@ -146,15 +146,15 @@ typedef struct _mgslpc_info { int line; unsigned short close_delay; unsigned short closing_wait; /* time to wait before closing */ - + struct mgsl_icount icount; - + struct tty_struct *tty; int timeout; int x_char; /* xon/xoff character */ int blocked_open; /* # of blocked opens */ unsigned char read_status_mask; - unsigned char ignore_status_mask; + unsigned char ignore_status_mask; unsigned char *tx_buf; int tx_put; @@ -170,10 +170,10 @@ typedef struct _mgslpc_info { int rx_buf_size; /* size in bytes of single rx buffer */ int rx_buf_count; /* total number of rx buffers */ int rx_frame_count; /* number of full rx buffers */ - + wait_queue_head_t open_wait; wait_queue_head_t close_wait; - + wait_queue_head_t status_event_wait_q; wait_queue_head_t event_wait_q; struct timer_list tx_timer; /* HDLC transmit timeout timer */ @@ -192,7 +192,7 @@ typedef struct _mgslpc_info { int bh_running; int bh_requested; - + int dcd_chkcount; /* check counts to prevent */ int cts_chkcount; /* too many IRQs if a signal */ int dsr_chkcount; /* is floating */ @@ -212,7 +212,7 @@ typedef struct _mgslpc_info { unsigned int io_base; /* base I/O address of adapter */ unsigned int irq_level; - + MGSL_PARAMS params; /* communications parameters */ unsigned char serial_signals; /* current serial signal states */ @@ -249,7 +249,7 @@ typedef struct _mgslpc_info { */ #define TXBUFSIZE 4096 - + #define CHA 0x00 /* channel A offset */ #define CHB 0x40 /* channel B offset */ @@ -298,9 +298,9 @@ typedef struct _mgslpc_info { #define PIM 0x3d #define PCR 0x3e #define CCR4 0x3f - + // IMR/ISR - + #define IRQ_BREAK_ON BIT15 // rx break detected #define IRQ_DATAOVERRUN BIT14 // receive data overflow #define IRQ_ALLSENT BIT13 // all sent @@ -315,13 +315,13 @@ typedef struct _mgslpc_info { #define IRQ_DCD BIT2 // carrier detect status change #define IRQ_OVERRUN BIT1 // receive frame overflow #define IRQ_RXFIFO BIT0 // receive pool full - + // STAR - + #define XFW BIT6 // transmit FIFO write enable #define CEC BIT2 // command executing #define CTS BIT1 // CTS state - + #define PVR_DTR BIT0 #define PVR_DSR BIT1 #define PVR_RI BIT2 @@ -329,25 +329,25 @@ typedef struct _mgslpc_info { #define PVR_RS232 0x20 /* 0010b */ #define PVR_V35 0xe0 /* 1110b */ #define PVR_RS422 0x40 /* 0100b */ - -/* Register access functions */ - + +/* Register access functions */ + #define write_reg(info, reg, val) outb((val),(info)->io_base + (reg)) #define read_reg(info, reg) inb((info)->io_base + (reg)) -#define read_reg16(info, reg) inw((info)->io_base + (reg)) +#define read_reg16(info, reg) inw((info)->io_base + (reg)) #define write_reg16(info, reg, val) outw((val), (info)->io_base + (reg)) - + #define set_reg_bits(info, reg, mask) \ write_reg(info, (reg), \ - (unsigned char) (read_reg(info, (reg)) | (mask))) + (unsigned char) (read_reg(info, (reg)) | (mask))) #define clear_reg_bits(info, reg, mask) \ write_reg(info, (reg), \ - (unsigned char) (read_reg(info, (reg)) & ~(mask))) + (unsigned char) (read_reg(info, (reg)) & ~(mask))) /* * interrupt enable/disable routines - */ -static void irq_disable(MGSLPC_INFO *info, unsigned char channel, unsigned short mask) + */ +static void irq_disable(MGSLPC_INFO *info, unsigned char channel, unsigned short mask) { if (channel == CHA) { info->imra_value |= mask; @@ -357,7 +357,7 @@ static void irq_disable(MGSLPC_INFO *info, unsigned char channel, unsigned short write_reg16(info, CHB + IMR, info->imrb_value); } } -static void irq_enable(MGSLPC_INFO *info, unsigned char channel, unsigned short mask) +static void irq_enable(MGSLPC_INFO *info, unsigned char channel, unsigned short mask) { if (channel == CHA) { info->imra_value &= ~mask; @@ -558,7 +558,7 @@ static int mgslpc_probe(struct pcmcia_device *link) spin_lock_init(&info->lock); spin_lock_init(&info->netlock); memcpy(&info->params,&default_params,sizeof(MGSL_PARAMS)); - info->idle_mode = HDLC_TXIDLE_FLAGS; + info->idle_mode = HDLC_TXIDLE_FLAGS; info->imra_value = 0xffff; info->imrb_value = 0xffff; info->pim_value = 0xff; @@ -600,7 +600,7 @@ static int mgslpc_config(struct pcmcia_device *link) u_char buf[64]; cistpl_cftable_entry_t dflt = { 0 }; cistpl_cftable_entry_t *cfg; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("mgslpc_config(0x%p)\n", link); @@ -624,7 +624,7 @@ static int mgslpc_config(struct pcmcia_device *link) link->conf.ConfigIndex = cfg->index; link->conf.Attributes |= CONF_ENABLE_IRQ; - + /* IO window settings */ link->io.NumPorts1 = 0; if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { @@ -644,7 +644,7 @@ static int mgslpc_config(struct pcmcia_device *link) link->conf.IntType = INT_MEMORY_AND_IO; link->conf.ConfigIndex = 8; link->conf.Present = PRESENT_OPTION; - + link->irq.Attributes |= IRQ_HANDLE_PRESENT; link->irq.Handler = mgslpc_isr; link->irq.Instance = info; @@ -753,10 +753,10 @@ static inline int mgslpc_paranoia_check(MGSLPC_INFO *info, #define CMD_TXEOM BIT1 // transmit end message #define CMD_TXRESET BIT0 // transmit reset -static BOOLEAN wait_command_complete(MGSLPC_INFO *info, unsigned char channel) +static BOOLEAN wait_command_complete(MGSLPC_INFO *info, unsigned char channel) { int i = 0; - /* wait for command completion */ + /* wait for command completion */ while (read_reg(info, (unsigned char)(channel+STAR)) & BIT2) { udelay(1); if (i++ == 1000) @@ -765,7 +765,7 @@ static BOOLEAN wait_command_complete(MGSLPC_INFO *info, unsigned char channel) return TRUE; } -static void issue_command(MGSLPC_INFO *info, unsigned char channel, unsigned char cmd) +static void issue_command(MGSLPC_INFO *info, unsigned char channel, unsigned char cmd) { wait_command_complete(info, channel); write_reg(info, (unsigned char) (channel + CMDR), cmd); @@ -775,12 +775,12 @@ static void tx_pause(struct tty_struct *tty) { MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; unsigned long flags; - + if (mgslpc_paranoia_check(info, tty->name, "tx_pause")) return; if (debug_level >= DEBUG_LEVEL_INFO) - printk("tx_pause(%s)\n",info->device_name); - + printk("tx_pause(%s)\n",info->device_name); + spin_lock_irqsave(&info->lock,flags); if (info->tx_enabled) tx_stop(info); @@ -791,12 +791,12 @@ static void tx_release(struct tty_struct *tty) { MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; unsigned long flags; - + if (mgslpc_paranoia_check(info, tty->name, "tx_release")) return; if (debug_level >= DEBUG_LEVEL_INFO) - printk("tx_release(%s)\n",info->device_name); - + printk("tx_release(%s)\n",info->device_name); + spin_lock_irqsave(&info->lock,flags); if (!info->tx_enabled) tx_start(info); @@ -810,7 +810,7 @@ static int bh_action(MGSLPC_INFO *info) { unsigned long flags; int rc = 0; - + spin_lock_irqsave(&info->lock,flags); if (info->pending_bh & BH_RECEIVE) { @@ -829,9 +829,9 @@ static int bh_action(MGSLPC_INFO *info) info->bh_running = 0; info->bh_requested = 0; } - + spin_unlock_irqrestore(&info->lock,flags); - + return rc; } @@ -842,22 +842,22 @@ static void bh_handler(struct work_struct *work) if (!info) return; - + if (debug_level >= DEBUG_LEVEL_BH) printk( "%s(%d):bh_handler(%s) entry\n", __FILE__,__LINE__,info->device_name); - + info->bh_running = 1; while((action = bh_action(info)) != 0) { - + /* Process work item */ if ( debug_level >= DEBUG_LEVEL_BH ) printk( "%s(%d):bh_handler() work item action=%d\n", __FILE__,__LINE__,action); switch (action) { - + case BH_RECEIVE: while(rx_get_frame(info)); break; @@ -897,7 +897,7 @@ static void bh_status(MGSLPC_INFO *info) info->cts_chkcount = 0; } -/* eom: non-zero = end of frame */ +/* eom: non-zero = end of frame */ static void rx_ready_hdlc(MGSLPC_INFO *info, int eom) { unsigned char data[2]; @@ -906,7 +906,7 @@ static void rx_ready_hdlc(MGSLPC_INFO *info, int eom) if (debug_level >= DEBUG_LEVEL_ISR) printk("%s(%d):rx_ready_hdlc(eom=%d)\n",__FILE__,__LINE__,eom); - + if (!info->rx_enabled) return; @@ -920,12 +920,12 @@ static void rx_ready_hdlc(MGSLPC_INFO *info, int eom) } if (eom) { - /* end of frame, get FIFO count from RBCL register */ + /* end of frame, get FIFO count from RBCL register */ if (!(fifo_count = (unsigned char)(read_reg(info, CHA+RBCL) & 0x1f))) fifo_count = 32; } else fifo_count = 32; - + do { if (fifo_count == 1) { read_count = 1; @@ -969,7 +969,7 @@ static void rx_ready_async(MGSLPC_INFO *info, int tcd) struct mgsl_icount *icount = &info->icount; if (tcd) { - /* early termination, get FIFO count from RBCL register */ + /* early termination, get FIFO count from RBCL register */ fifo_count = (unsigned char)(read_reg(info, CHA+RBCL) & 0x1f); /* Zero fifo count could mean 0 or 32 bytes available. @@ -981,7 +981,7 @@ static void rx_ready_async(MGSLPC_INFO *info, int tcd) fifo_count = 32; tty_buffer_request_room(tty, fifo_count); - /* Flush received async data to receive data buffer. */ + /* Flush received async data to receive data buffer. */ while (fifo_count) { data = read_reg(info, CHA + RXFIFO); status = read_reg(info, CHA + RXFIFO); @@ -995,7 +995,7 @@ static void rx_ready_async(MGSLPC_INFO *info, int tcd) // BIT6:framing error if (status & (BIT7 + BIT6)) { - if (status & BIT7) + if (status & BIT7) icount->parity++; else icount->frame++; @@ -1003,7 +1003,7 @@ static void rx_ready_async(MGSLPC_INFO *info, int tcd) /* discard char if tty control flags say so */ if (status & info->ignore_status_mask) continue; - + status &= info->read_status_mask; if (status & BIT7) @@ -1022,7 +1022,7 @@ static void rx_ready_async(MGSLPC_INFO *info, int tcd) __FILE__,__LINE__,icount->rx,icount->brk, icount->parity,icount->frame,icount->overrun); } - + if (work) tty_flip_buffer_push(tty); } @@ -1032,7 +1032,7 @@ static void tx_done(MGSLPC_INFO *info) { if (!info->tx_active) return; - + info->tx_active = 0; info->tx_aborting = 0; @@ -1040,8 +1040,8 @@ static void tx_done(MGSLPC_INFO *info) return; info->tx_count = info->tx_put = info->tx_get = 0; - del_timer(&info->tx_timer); - + del_timer(&info->tx_timer); + if (info->drop_rts_on_tx_done) { get_signals(info); if (info->serial_signals & SerialSignal_RTS) { @@ -1054,7 +1054,7 @@ static void tx_done(MGSLPC_INFO *info) #if SYNCLINK_GENERIC_HDLC if (info->netcount) hdlcdev_tx_done(info); - else + else #endif { if (info->tty->stopped || info->tty->hw_stopped) { @@ -1090,7 +1090,7 @@ static void tx_ready(MGSLPC_INFO *info) while (info->tx_count && fifo_count) { c = min(2, min_t(int, fifo_count, min(info->tx_count, TXBUFSIZE - info->tx_get))); - + if (c == 1) { write_reg(info, CHA + TXFIFO, *(info->tx_buf + info->tx_get)); } else { @@ -1220,9 +1220,9 @@ static void ri_change(MGSLPC_INFO *info) } /* Interrupt service routine entry point. - * + * * Arguments: - * + * * irq interrupt number that caused interrupt * dev_id device ID supplied during interrupt registration */ @@ -1233,18 +1233,18 @@ static irqreturn_t mgslpc_isr(int irq, void *dev_id) unsigned char gis, pis; int count=0; - if (debug_level >= DEBUG_LEVEL_ISR) + if (debug_level >= DEBUG_LEVEL_ISR) printk("mgslpc_isr(%d) entry.\n", irq); if (!info) return IRQ_NONE; - + if (!(info->p_dev->_locked)) return IRQ_HANDLED; spin_lock(&info->lock); while ((gis = read_reg(info, CHA + GIS))) { - if (debug_level >= DEBUG_LEVEL_ISR) + if (debug_level >= DEBUG_LEVEL_ISR) printk("mgslpc_isr %s gis=%04X\n", info->device_name,gis); if ((gis & 0x70) || count > 1000) { @@ -1268,7 +1268,7 @@ static irqreturn_t mgslpc_isr(int irq, void *dev_id) irq_disable(info, CHA, IRQ_TIMER); } - /* receive IRQs */ + /* receive IRQs */ if (isr & IRQ_EXITHUNT) { info->icount.exithunt++; wake_up_interruptible(&info->event_wait_q); @@ -1283,12 +1283,12 @@ static irqreturn_t mgslpc_isr(int irq, void *dev_id) } if (isr & (IRQ_RXEOM + IRQ_RXFIFO)) { if (info->params.mode == MGSL_MODE_HDLC) - rx_ready_hdlc(info, isr & IRQ_RXEOM); + rx_ready_hdlc(info, isr & IRQ_RXEOM); else rx_ready_async(info, isr & IRQ_RXEOM); } - /* transmit IRQs */ + /* transmit IRQs */ if (isr & IRQ_UNDERRUN) { if (info->tx_aborting) info->icount.txabort++; @@ -1311,13 +1311,13 @@ static irqreturn_t mgslpc_isr(int irq, void *dev_id) ri_change(info); } } - - /* Request bottom half processing if there's something + + /* Request bottom half processing if there's something * for it to do and the bh is not already running */ if (info->pending_bh && !info->bh_running && !info->bh_requested) { - if ( debug_level >= DEBUG_LEVEL_ISR ) + if ( debug_level >= DEBUG_LEVEL_ISR ) printk("%s(%d):%s queueing bh task.\n", __FILE__,__LINE__,info->device_name); schedule_work(&info->task); @@ -1325,8 +1325,8 @@ static irqreturn_t mgslpc_isr(int irq, void *dev_id) } spin_unlock(&info->lock); - - if (debug_level >= DEBUG_LEVEL_ISR) + + if (debug_level >= DEBUG_LEVEL_ISR) printk("%s(%d):mgslpc_isr(%d)exit.\n", __FILE__,__LINE__,irq); @@ -1338,13 +1338,13 @@ static irqreturn_t mgslpc_isr(int irq, void *dev_id) static int startup(MGSLPC_INFO * info) { int retval = 0; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):startup(%s)\n",__FILE__,__LINE__,info->device_name); - + if (info->flags & ASYNC_INITIALIZED) return 0; - + if (!info->tx_buf) { /* allocate a page of memory for a transmit buffer */ info->tx_buf = (unsigned char *)get_zeroed_page(GFP_KERNEL); @@ -1356,18 +1356,18 @@ static int startup(MGSLPC_INFO * info) } info->pending_bh = 0; - + memset(&info->icount, 0, sizeof(info->icount)); setup_timer(&info->tx_timer, tx_timeout, (unsigned long)info); /* Allocate and claim adapter resources */ retval = claim_resources(info); - + /* perform existance check and diagnostics */ if ( !retval ) retval = adapter_test(info); - + if ( retval ) { if (capable(CAP_SYS_ADMIN) && info->tty) set_bit(TTY_IO_ERROR, &info->tty->flags); @@ -1377,12 +1377,12 @@ static int startup(MGSLPC_INFO * info) /* program hardware for current parameters */ mgslpc_change_params(info); - + if (info->tty) clear_bit(TTY_IO_ERROR, &info->tty->flags); info->flags |= ASYNC_INITIALIZED; - + return 0; } @@ -1391,7 +1391,7 @@ static int startup(MGSLPC_INFO * info) static void shutdown(MGSLPC_INFO * info) { unsigned long flags; - + if (!(info->flags & ASYNC_INITIALIZED)) return; @@ -1418,16 +1418,16 @@ static void shutdown(MGSLPC_INFO * info) /* TODO:disable interrupts instead of reset to preserve signal states */ reset_device(info); - + if (!info->tty || info->tty->termios->c_cflag & HUPCL) { info->serial_signals &= ~(SerialSignal_DTR + SerialSignal_RTS); set_signals(info); } - + spin_unlock_irqrestore(&info->lock,flags); - release_resources(info); - + release_resources(info); + if (info->tty) set_bit(TTY_IO_ERROR, &info->tty->flags); @@ -1439,18 +1439,18 @@ static void mgslpc_program_hw(MGSLPC_INFO *info) unsigned long flags; spin_lock_irqsave(&info->lock,flags); - + rx_stop(info); tx_stop(info); info->tx_count = info->tx_put = info->tx_get = 0; - + if (info->params.mode == MGSL_MODE_HDLC || info->netcount) hdlc_mode(info); else async_mode(info); - + set_signals(info); - + info->dcd_chkcount = 0; info->cts_chkcount = 0; info->ri_chkcount = 0; @@ -1459,10 +1459,10 @@ static void mgslpc_program_hw(MGSLPC_INFO *info) irq_enable(info, CHB, IRQ_DCD | IRQ_CTS); port_irq_enable(info, (unsigned char) PVR_DSR | PVR_RI); get_signals(info); - + if (info->netcount || info->tty->termios->c_cflag & CREAD) rx_start(info); - + spin_unlock_irqrestore(&info->lock,flags); } @@ -1475,11 +1475,11 @@ static void mgslpc_change_params(MGSLPC_INFO *info) if (!info->tty || !info->tty->termios) return; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):mgslpc_change_params(%s)\n", __FILE__,__LINE__, info->device_name ); - + cflag = info->tty->termios->c_cflag; /* if B0 rate (hangup) specified then negate DTR and RTS */ @@ -1488,9 +1488,9 @@ static void mgslpc_change_params(MGSLPC_INFO *info) info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR; else info->serial_signals &= ~(SerialSignal_RTS + SerialSignal_DTR); - + /* byte size and parity */ - + switch (cflag & CSIZE) { case CS5: info->params.data_bits = 5; break; case CS6: info->params.data_bits = 6; break; @@ -1498,7 +1498,7 @@ static void mgslpc_change_params(MGSLPC_INFO *info) case CS8: info->params.data_bits = 8; break; default: info->params.data_bits = 7; break; } - + if (cflag & CSTOPB) info->params.stop_bits = 2; else @@ -1519,7 +1519,7 @@ static void mgslpc_change_params(MGSLPC_INFO *info) /* calculate number of jiffies to transmit a full * FIFO (32 bytes) at specified data rate */ - bits_per_char = info->params.data_bits + + bits_per_char = info->params.data_bits + info->params.stop_bits + 1; /* if port data rate is set to 460800 or less then @@ -1529,9 +1529,9 @@ static void mgslpc_change_params(MGSLPC_INFO *info) if (info->params.data_rate <= 460800) { info->params.data_rate = tty_get_baud_rate(info->tty); } - + if ( info->params.data_rate ) { - info->timeout = (32*HZ*bits_per_char) / + info->timeout = (32*HZ*bits_per_char) / info->params.data_rate; } info->timeout += HZ/50; /* Add .02 seconds of slop */ @@ -1540,14 +1540,14 @@ static void mgslpc_change_params(MGSLPC_INFO *info) info->flags |= ASYNC_CTS_FLOW; else info->flags &= ~ASYNC_CTS_FLOW; - + if (cflag & CLOCAL) info->flags &= ~ASYNC_CHECK_CD; else info->flags |= ASYNC_CHECK_CD; /* process tty input control flags */ - + info->read_status_mask = 0; if (I_INPCK(info->tty)) info->read_status_mask |= BIT7 | BIT6; @@ -1576,7 +1576,7 @@ static void mgslpc_put_char(struct tty_struct *tty, unsigned char ch) return; spin_lock_irqsave(&info->lock,flags); - + if (info->params.mode == MGSL_MODE_ASYNC || !info->tx_active) { if (info->tx_count < TXBUFSIZE - 1) { info->tx_buf[info->tx_put++] = ch; @@ -1584,7 +1584,7 @@ static void mgslpc_put_char(struct tty_struct *tty, unsigned char ch) info->tx_count++; } } - + spin_unlock_irqrestore(&info->lock,flags); } @@ -1595,11 +1595,11 @@ static void mgslpc_flush_chars(struct tty_struct *tty) { MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; unsigned long flags; - + if (debug_level >= DEBUG_LEVEL_INFO) printk( "%s(%d):mgslpc_flush_chars() entry on %s tx_count=%d\n", __FILE__,__LINE__,info->device_name,info->tx_count); - + if (mgslpc_paranoia_check(info, tty->name, "mgslpc_flush_chars")) return; @@ -1618,13 +1618,13 @@ static void mgslpc_flush_chars(struct tty_struct *tty) } /* Send a block of data - * + * * Arguments: - * + * * tty pointer to tty information structure * buf pointer to buffer containing send data * count size of send data in bytes - * + * * Returns: number of characters written */ static int mgslpc_write(struct tty_struct * tty, @@ -1633,11 +1633,11 @@ static int mgslpc_write(struct tty_struct * tty, int c, ret = 0; MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; unsigned long flags; - + if (debug_level >= DEBUG_LEVEL_INFO) printk( "%s(%d):mgslpc_write(%s) count=%d\n", __FILE__,__LINE__,info->device_name,count); - + if (mgslpc_paranoia_check(info, tty->name, "mgslpc_write") || !info->tx_buf) goto cleanup; @@ -1659,7 +1659,7 @@ static int mgslpc_write(struct tty_struct * tty, TXBUFSIZE - info->tx_put)); if (c <= 0) break; - + memcpy(info->tx_buf + info->tx_put, buf, c); spin_lock_irqsave(&info->lock,flags); @@ -1678,7 +1678,7 @@ start: tx_start(info); spin_unlock_irqrestore(&info->lock,flags); } -cleanup: +cleanup: if (debug_level >= DEBUG_LEVEL_INFO) printk( "%s(%d):mgslpc_write(%s) returning=%d\n", __FILE__,__LINE__,info->device_name,ret); @@ -1691,7 +1691,7 @@ static int mgslpc_write_room(struct tty_struct *tty) { MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; int ret; - + if (mgslpc_paranoia_check(info, tty->name, "mgslpc_write_room")) return 0; @@ -1706,7 +1706,7 @@ static int mgslpc_write_room(struct tty_struct *tty) if (ret < 0) ret = 0; } - + if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):mgslpc_write_room(%s)=%d\n", __FILE__,__LINE__, info->device_name, ret); @@ -1719,14 +1719,14 @@ static int mgslpc_chars_in_buffer(struct tty_struct *tty) { MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; int rc; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):mgslpc_chars_in_buffer(%s)\n", __FILE__,__LINE__, info->device_name ); - + if (mgslpc_paranoia_check(info, tty->name, "mgslpc_chars_in_buffer")) return 0; - + if (info->params.mode == MGSL_MODE_HDLC) rc = info->tx_active ? info->max_frame_size : 0; else @@ -1735,7 +1735,7 @@ static int mgslpc_chars_in_buffer(struct tty_struct *tty) if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):mgslpc_chars_in_buffer(%s)=%d\n", __FILE__,__LINE__, info->device_name, rc); - + return rc; } @@ -1745,17 +1745,17 @@ static void mgslpc_flush_buffer(struct tty_struct *tty) { MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; unsigned long flags; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):mgslpc_flush_buffer(%s) entry\n", __FILE__,__LINE__, info->device_name ); - + if (mgslpc_paranoia_check(info, tty->name, "mgslpc_flush_buffer")) return; - - spin_lock_irqsave(&info->lock,flags); + + spin_lock_irqsave(&info->lock,flags); info->tx_count = info->tx_put = info->tx_get = 0; - del_timer(&info->tx_timer); + del_timer(&info->tx_timer); spin_unlock_irqrestore(&info->lock,flags); wake_up_interruptible(&tty->write_wait); @@ -1772,7 +1772,7 @@ static void mgslpc_send_xchar(struct tty_struct *tty, char ch) if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):mgslpc_send_xchar(%s,%d)\n", __FILE__,__LINE__, info->device_name, ch ); - + if (mgslpc_paranoia_check(info, tty->name, "mgslpc_send_xchar")) return; @@ -1791,17 +1791,17 @@ static void mgslpc_throttle(struct tty_struct * tty) { MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; unsigned long flags; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):mgslpc_throttle(%s) entry\n", __FILE__,__LINE__, info->device_name ); if (mgslpc_paranoia_check(info, tty->name, "mgslpc_throttle")) return; - + if (I_IXOFF(tty)) mgslpc_send_xchar(tty, STOP_CHAR(tty)); - + if (tty->termios->c_cflag & CRTSCTS) { spin_lock_irqsave(&info->lock,flags); info->serial_signals &= ~SerialSignal_RTS; @@ -1816,21 +1816,21 @@ static void mgslpc_unthrottle(struct tty_struct * tty) { MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; unsigned long flags; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):mgslpc_unthrottle(%s) entry\n", __FILE__,__LINE__, info->device_name ); if (mgslpc_paranoia_check(info, tty->name, "mgslpc_unthrottle")) return; - + if (I_IXOFF(tty)) { if (info->x_char) info->x_char = 0; else mgslpc_send_xchar(tty, START_CHAR(tty)); } - + if (tty->termios->c_cflag & CRTSCTS) { spin_lock_irqsave(&info->lock,flags); info->serial_signals |= SerialSignal_RTS; @@ -1870,9 +1870,9 @@ static int get_params(MGSLPC_INFO * info, MGSL_PARAMS __user *user_params) } /* set the serial parameters - * + * * Arguments: - * + * * info pointer to device instance data * new_params user buffer containing new serial params * @@ -1883,7 +1883,7 @@ static int set_params(MGSLPC_INFO * info, MGSL_PARAMS __user *new_params) unsigned long flags; MGSL_PARAMS tmp_params; int err; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):set_params %s\n", __FILE__,__LINE__, info->device_name ); @@ -1894,13 +1894,13 @@ static int set_params(MGSLPC_INFO * info, MGSL_PARAMS __user *new_params) __FILE__,__LINE__,info->device_name); return -EFAULT; } - + spin_lock_irqsave(&info->lock,flags); memcpy(&info->params,&tmp_params,sizeof(MGSL_PARAMS)); spin_unlock_irqrestore(&info->lock,flags); - + mgslpc_change_params(info); - + return 0; } @@ -1963,10 +1963,10 @@ static int set_interface(MGSLPC_INFO * info, int if_mode) static int set_txenable(MGSLPC_INFO * info, int enable) { unsigned long flags; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("set_txenable(%s,%d)\n", info->device_name, enable); - + spin_lock_irqsave(&info->lock,flags); if (enable) { if (!info->tx_enabled) @@ -1982,10 +1982,10 @@ static int set_txenable(MGSLPC_INFO * info, int enable) static int tx_abort(MGSLPC_INFO * info) { unsigned long flags; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("tx_abort(%s)\n", info->device_name); - + spin_lock_irqsave(&info->lock,flags); if (info->tx_active && info->tx_count && info->params.mode == MGSL_MODE_HDLC) { @@ -2002,10 +2002,10 @@ static int tx_abort(MGSLPC_INFO * info) static int set_rxenable(MGSLPC_INFO * info, int enable) { unsigned long flags; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("set_rxenable(%s,%d)\n", info->device_name, enable); - + spin_lock_irqsave(&info->lock,flags); if (enable) { if (!info->rx_enabled) @@ -2019,7 +2019,7 @@ static int set_rxenable(MGSLPC_INFO * info, int enable) } /* wait for specified event to occur - * + * * Arguments: info pointer to device instance data * mask pointer to bitmask of events to wait for * Return Value: 0 if successful and bit mask updated with @@ -2040,7 +2040,7 @@ static int wait_events(MGSLPC_INFO * info, int __user *mask_ptr) COPY_FROM_USER(rc,&mask, mask_ptr, sizeof(int)); if (rc) return -EFAULT; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("wait_events(%s,%d)\n", info->device_name, mask); @@ -2062,24 +2062,24 @@ static int wait_events(MGSLPC_INFO * info, int __user *mask_ptr) /* save current irq counts */ cprev = info->icount; oldsigs = info->input_signal_events; - + if ((info->params.mode == MGSL_MODE_HDLC) && (mask & MgslEvent_ExitHuntMode)) irq_enable(info, CHA, IRQ_EXITHUNT); - + set_current_state(TASK_INTERRUPTIBLE); add_wait_queue(&info->event_wait_q, &wait); - + spin_unlock_irqrestore(&info->lock,flags); - - + + for(;;) { schedule(); if (signal_pending(current)) { rc = -ERESTARTSYS; break; } - + /* get current irq counts */ spin_lock_irqsave(&info->lock,flags); cnow = info->icount; @@ -2115,11 +2115,11 @@ static int wait_events(MGSLPC_INFO * info, int __user *mask_ptr) (cnow.rxidle != cprev.rxidle ? MgslEvent_IdleReceived:0) ); if (events) break; - + cprev = cnow; oldsigs = newsigs; } - + remove_wait_queue(&info->event_wait_q, &wait); set_current_state(TASK_RUNNING); @@ -2247,42 +2247,42 @@ static void mgslpc_break(struct tty_struct *tty, int break_state) { MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; unsigned long flags; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):mgslpc_break(%s,%d)\n", __FILE__,__LINE__, info->device_name, break_state); - + if (mgslpc_paranoia_check(info, tty->name, "mgslpc_break")) return; spin_lock_irqsave(&info->lock,flags); if (break_state == -1) set_reg_bits(info, CHA+DAFO, BIT6); - else + else clear_reg_bits(info, CHA+DAFO, BIT6); spin_unlock_irqrestore(&info->lock,flags); } /* Service an IOCTL request - * + * * Arguments: - * + * * tty pointer to tty instance data * file pointer to associated file object for device * cmd IOCTL command code * arg command argument/context - * + * * Return Value: 0 if success, otherwise error code */ static int mgslpc_ioctl(struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg) { MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):mgslpc_ioctl %s cmd=%08X\n", __FILE__,__LINE__, info->device_name, cmd ); - + if (mgslpc_paranoia_check(info, tty->name, "mgslpc_ioctl")) return -ENODEV; @@ -2302,7 +2302,7 @@ static int ioctl_common(MGSLPC_INFO *info, unsigned int cmd, unsigned long arg) struct serial_icounter_struct __user *p_cuser; /* user space */ void __user *argp = (void __user *)arg; unsigned long flags; - + switch (cmd) { case MGSL_IOCGPARAMS: return get_params(info, argp); @@ -2363,9 +2363,9 @@ static int ioctl_common(MGSLPC_INFO *info, unsigned int cmd, unsigned long arg) } /* Set new termios settings - * + * * Arguments: - * + * * tty pointer to tty structure * termios pointer to buffer to hold returned old termios */ @@ -2373,14 +2373,14 @@ static void mgslpc_set_termios(struct tty_struct *tty, struct ktermios *old_term { MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; unsigned long flags; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):mgslpc_set_termios %s\n", __FILE__,__LINE__, tty->driver->name ); - + /* just return if nothing has changed */ if ((tty->termios->c_cflag == old_termios->c_cflag) - && (RELEVANT_IFLAG(tty->termios->c_iflag) + && (RELEVANT_IFLAG(tty->termios->c_iflag) == RELEVANT_IFLAG(old_termios->c_iflag))) return; @@ -2394,12 +2394,12 @@ static void mgslpc_set_termios(struct tty_struct *tty, struct ktermios *old_term set_signals(info); spin_unlock_irqrestore(&info->lock,flags); } - + /* Handle transition away from B0 status */ if (!(old_termios->c_cflag & CBAUD) && tty->termios->c_cflag & CBAUD) { info->serial_signals |= SerialSignal_DTR; - if (!(tty->termios->c_cflag & CRTSCTS) || + if (!(tty->termios->c_cflag & CRTSCTS) || !test_bit(TTY_THROTTLED, &tty->flags)) { info->serial_signals |= SerialSignal_RTS; } @@ -2407,7 +2407,7 @@ static void mgslpc_set_termios(struct tty_struct *tty, struct ktermios *old_term set_signals(info); spin_unlock_irqrestore(&info->lock,flags); } - + /* Handle turning off CRTSCTS */ if (old_termios->c_cflag & CRTSCTS && !(tty->termios->c_cflag & CRTSCTS)) { @@ -2422,17 +2422,17 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp) if (mgslpc_paranoia_check(info, tty->name, "mgslpc_close")) return; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):mgslpc_close(%s) entry, count=%d\n", __FILE__,__LINE__, info->device_name, info->count); - + if (!info->count) return; if (tty_hung_up_p(filp)) goto cleanup; - + if ((tty->count == 1) && (info->count != 1)) { /* * tty->count is 1 and the tty structure will be freed. @@ -2443,30 +2443,30 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp) "info->count is %d\n", info->count); info->count = 1; } - + info->count--; - + /* if at least one open remaining, leave hardware active */ if (info->count) goto cleanup; - + info->flags |= ASYNC_CLOSING; - - /* set tty->closing to notify line discipline to + + /* set tty->closing to notify line discipline to * only process XON/XOFF characters. Only the N_TTY * discipline appears to use this (ppp does not). */ tty->closing = 1; - + /* wait for transmit data to clear all layers */ - + if (info->closing_wait != ASYNC_CLOSING_WAIT_NONE) { if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):mgslpc_close(%s) calling tty_wait_until_sent\n", __FILE__,__LINE__, info->device_name ); tty_wait_until_sent(tty, info->closing_wait); } - + if (info->flags & ASYNC_INITIALIZED) mgslpc_wait_until_sent(tty, info->timeout); @@ -2474,24 +2474,24 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp) tty->driver->flush_buffer(tty); ldisc_flush_buffer(tty); - + shutdown(info); - + tty->closing = 0; info->tty = NULL; - + if (info->blocked_open) { if (info->close_delay) { msleep_interruptible(jiffies_to_msecs(info->close_delay)); } wake_up_interruptible(&info->open_wait); } - + info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); - + wake_up_interruptible(&info->close_wait); - -cleanup: + +cleanup: if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__,__LINE__, tty->driver->name, info->count); @@ -2510,31 +2510,31 @@ static void mgslpc_wait_until_sent(struct tty_struct *tty, int timeout) if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):mgslpc_wait_until_sent(%s) entry\n", __FILE__,__LINE__, info->device_name ); - + if (mgslpc_paranoia_check(info, tty->name, "mgslpc_wait_until_sent")) return; if (!(info->flags & ASYNC_INITIALIZED)) goto exit; - + orig_jiffies = jiffies; - + /* Set check interval to 1/5 of estimated time to * send a character, and make it at least 1. The check * interval should also be less than the timeout. * Note: use tight timings here to satisfy the NIST-PCTS. - */ - + */ + if ( info->params.data_rate ) { char_time = info->timeout/(32 * 5); if (!char_time) char_time++; } else char_time = 1; - + if (timeout) char_time = min_t(unsigned long, char_time, timeout); - + if (info->params.mode == MGSL_MODE_HDLC) { while (info->tx_active) { msleep_interruptible(jiffies_to_msecs(char_time)); @@ -2553,7 +2553,7 @@ static void mgslpc_wait_until_sent(struct tty_struct *tty, int timeout) break; } } - + exit: if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):mgslpc_wait_until_sent(%s) exit\n", @@ -2566,18 +2566,18 @@ exit: static void mgslpc_hangup(struct tty_struct *tty) { MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):mgslpc_hangup(%s)\n", __FILE__,__LINE__, info->device_name ); - + if (mgslpc_paranoia_check(info, tty->name, "mgslpc_hangup")) return; mgslpc_flush_buffer(tty); shutdown(info); - - info->count = 0; + + info->count = 0; info->flags &= ~ASYNC_NORMAL_ACTIVE; info->tty = NULL; @@ -2594,7 +2594,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, int retval; int do_clocal = 0, extra_count = 0; unsigned long flags; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):block_til_ready on %s\n", __FILE__,__LINE__, tty->driver->name ); @@ -2615,10 +2615,10 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, * mgslpc_close() knows when to free things. We restore it upon * exit, either normal or abnormal. */ - + retval = 0; add_wait_queue(&info->open_wait, &wait); - + if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):block_til_ready before block on %s count=%d\n", __FILE__,__LINE__, tty->driver->name, info->count ); @@ -2630,7 +2630,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, } spin_unlock_irqrestore(&info->lock, flags); info->blocked_open++; - + while (1) { if ((tty->termios->c_cflag & CBAUD)) { spin_lock_irqsave(&info->lock,flags); @@ -2638,50 +2638,50 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, set_signals(info); spin_unlock_irqrestore(&info->lock,flags); } - + set_current_state(TASK_INTERRUPTIBLE); - + if (tty_hung_up_p(filp) || !(info->flags & ASYNC_INITIALIZED)){ retval = (info->flags & ASYNC_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS; break; } - + spin_lock_irqsave(&info->lock,flags); get_signals(info); spin_unlock_irqrestore(&info->lock,flags); - + if (!(info->flags & ASYNC_CLOSING) && (do_clocal || (info->serial_signals & SerialSignal_DCD)) ) { break; } - + if (signal_pending(current)) { retval = -ERESTARTSYS; break; } - + if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):block_til_ready blocking on %s count=%d\n", __FILE__,__LINE__, tty->driver->name, info->count ); - + schedule(); } - + set_current_state(TASK_RUNNING); remove_wait_queue(&info->open_wait, &wait); - + if (extra_count) info->count++; info->blocked_open--; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):block_til_ready after blocking on %s count=%d\n", __FILE__,__LINE__, tty->driver->name, info->count ); - + if (!retval) info->flags |= ASYNC_NORMAL_ACTIVE; - + return retval; } @@ -2691,7 +2691,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp) int retval, line; unsigned long flags; - /* verify range of specified line number */ + /* verify range of specified line number */ line = tty->index; if ((line < 0) || (line >= mgslpc_device_count)) { printk("%s(%d):mgslpc_open with invalid line #%d.\n", @@ -2705,10 +2705,10 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp) info = info->next_device; if (mgslpc_paranoia_check(info, tty->name, "mgslpc_open")) return -ENODEV; - + tty->driver_data = info; info->tty = tty; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):mgslpc_open(%s), old ref count = %d\n", __FILE__,__LINE__,tty->driver->name, info->count); @@ -2721,7 +2721,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp) -EAGAIN : -ERESTARTSYS); goto cleanup; } - + info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0; spin_lock_irqsave(&info->netlock, flags); @@ -2752,15 +2752,15 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp) printk("%s(%d):mgslpc_open(%s) success\n", __FILE__,__LINE__, info->device_name); retval = 0; - -cleanup: + +cleanup: if (retval) { if (tty->count == 1) info->tty = NULL; /* tty layer will release tty struct */ if(info->count) info->count--; } - + return retval; } @@ -2781,7 +2781,7 @@ static inline int line_info(char *buf, MGSLPC_INFO *info) spin_lock_irqsave(&info->lock,flags); get_signals(info); spin_unlock_irqrestore(&info->lock,flags); - + stat_buf[0] = 0; stat_buf[1] = 0; if (info->serial_signals & SerialSignal_RTS) @@ -2805,7 +2805,7 @@ static inline int line_info(char *buf, MGSLPC_INFO *info) if (info->icount.txabort) ret += sprintf(buf+ret, " txabort:%d", info->icount.txabort); if (info->icount.rxshort) - ret += sprintf(buf+ret, " rxshort:%d", info->icount.rxshort); + ret += sprintf(buf+ret, " rxshort:%d", info->icount.rxshort); if (info->icount.rxlong) ret += sprintf(buf+ret, " rxlong:%d", info->icount.rxlong); if (info->icount.rxover) @@ -2820,18 +2820,18 @@ static inline int line_info(char *buf, MGSLPC_INFO *info) if (info->icount.parity) ret += sprintf(buf+ret, " pe:%d", info->icount.parity); if (info->icount.brk) - ret += sprintf(buf+ret, " brk:%d", info->icount.brk); + ret += sprintf(buf+ret, " brk:%d", info->icount.brk); if (info->icount.overrun) ret += sprintf(buf+ret, " oe:%d", info->icount.overrun); } - + /* Append serial signal status to end */ ret += sprintf(buf+ret, " %s\n", stat_buf+1); - + ret += sprintf(buf+ret, "txactive=%d bh_req=%d bh_run=%d pending_bh=%x\n", info->tx_active,info->bh_requested,info->bh_running, info->pending_bh); - + return ret; } @@ -2843,9 +2843,9 @@ static int mgslpc_read_proc(char *page, char **start, off_t off, int count, int len = 0, l; off_t begin = 0; MGSLPC_INFO *info; - + len += sprintf(page, "synclink driver:%s\n", driver_version); - + info = mgslpc_device_list; while( info ) { l = line_info(page + len, info); @@ -2902,7 +2902,7 @@ static int claim_resources(MGSLPC_INFO *info) printk( "Cant allocate rx buffer %s\n", info->device_name); release_resources(info); return -ENODEV; - } + } return 0; } @@ -2915,7 +2915,7 @@ static void release_resources(MGSLPC_INFO *info) /* Add the specified device instance data structure to the * global linked list of devices and increment the device count. - * + * * Arguments: info pointer to device instance data */ static void mgslpc_add_device(MGSLPC_INFO *info) @@ -2923,7 +2923,7 @@ static void mgslpc_add_device(MGSLPC_INFO *info) info->next_device = NULL; info->line = mgslpc_device_count; sprintf(info->device_name,"ttySLP%d",info->line); - + if (info->line < MAX_DEVICE_COUNT) { if (maxframe[info->line]) info->max_frame_size = maxframe[info->line]; @@ -2931,21 +2931,21 @@ static void mgslpc_add_device(MGSLPC_INFO *info) } mgslpc_device_count++; - + if (!mgslpc_device_list) mgslpc_device_list = info; - else { + else { MGSLPC_INFO *current_dev = mgslpc_device_list; while( current_dev->next_device ) current_dev = current_dev->next_device; current_dev->next_device = info; } - + if (info->max_frame_size < 4096) info->max_frame_size = 4096; else if (info->max_frame_size > 65535) info->max_frame_size = 65535; - + printk( "SyncLink PC Card %s:IO=%04X IRQ=%d\n", info->device_name, info->io_base, info->irq_level); @@ -3060,7 +3060,7 @@ static int __init synclink_cs_init(void) } /* Initialize the tty_driver structure */ - + serial_driver->owner = THIS_MODULE; serial_driver->driver_name = "synclink_cs"; serial_driver->name = "ttySLP"; @@ -3081,11 +3081,11 @@ static int __init synclink_cs_init(void) serial_driver = NULL; goto error; } - + printk("%s %s, tty major#%d\n", driver_name, driver_version, serial_driver->major); - + return 0; error: @@ -3093,7 +3093,7 @@ error: return rc; } -static void __exit synclink_cs_exit(void) +static void __exit synclink_cs_exit(void) { synclink_cs_cleanup(); } @@ -3106,8 +3106,8 @@ static void mgslpc_set_rate(MGSLPC_INFO *info, unsigned char channel, unsigned i unsigned int M, N; unsigned char val; - /* note:standard BRG mode is broken in V3.2 chip - * so enhanced mode is always used + /* note:standard BRG mode is broken in V3.2 chip + * so enhanced mode is always used */ if (rate) { @@ -3126,7 +3126,7 @@ static void mgslpc_set_rate(MGSLPC_INFO *info, unsigned char channel, unsigned i * divisor = (N+1)*2^M * * Note: M *must* not be zero (causes asymetric duty cycle) - */ + */ write_reg(info, (unsigned char) (channel + BGR), (unsigned char) ((M << 6) + N)); val = read_reg(info, (unsigned char) (channel + CCR2)) & 0x3f; @@ -3140,7 +3140,7 @@ static void mgslpc_set_rate(MGSLPC_INFO *info, unsigned char channel, unsigned i static void enable_auxclk(MGSLPC_INFO *info) { unsigned char val; - + /* MODE * * 07..06 MDS[1..0] 10 = transparent HDLC mode @@ -3152,14 +3152,14 @@ static void enable_auxclk(MGSLPC_INFO *info) * 00 TLP Test Loop, 0 = no loop * * 1000 0010 - */ + */ val = 0x82; - - /* channel B RTS is used to enable AUXCLK driver on SP505 */ + + /* channel B RTS is used to enable AUXCLK driver on SP505 */ if (info->params.mode == MGSL_MODE_HDLC && info->params.clock_speed) val |= BIT2; write_reg(info, CHB + MODE, val); - + /* CCR0 * * 07 PU Power Up, 1=active, 0=power down @@ -3169,9 +3169,9 @@ static void enable_auxclk(MGSLPC_INFO *info) * 01..00 SM[1..0] Serial Mode, 00=HDLC * * 11000000 - */ + */ write_reg(info, CHB + CCR0, 0xc0); - + /* CCR1 * * 07 SFLG Shared Flag, 0 = disable shared flags @@ -3182,9 +3182,9 @@ static void enable_auxclk(MGSLPC_INFO *info) * 02..00 CM[2..0] Clock Mode * * 0001 0111 - */ + */ write_reg(info, CHB + CCR1, 0x17); - + /* CCR2 (Channel B) * * 07..06 BGR[9..8] Baud rate bits 9..8 @@ -3196,12 +3196,12 @@ static void enable_auxclk(MGSLPC_INFO *info) * 00 DIV, data inversion 0=disabled, 1=enabled * * 0011 1000 - */ + */ if (info->params.mode == MGSL_MODE_HDLC && info->params.clock_speed) write_reg(info, CHB + CCR2, 0x38); else write_reg(info, CHB + CCR2, 0x30); - + /* CCR4 * * 07 MCK4 Master Clock Divide by 4, 1=enabled @@ -3212,37 +3212,37 @@ static void enable_auxclk(MGSLPC_INFO *info) * 01..00 RFT[1..0] RxFIFO Threshold 00=32 bytes * * 0101 0000 - */ + */ write_reg(info, CHB + CCR4, 0x50); - + /* if auxclk not enabled, set internal BRG so * CTS transitions can be detected (requires TxC) - */ + */ if (info->params.mode == MGSL_MODE_HDLC && info->params.clock_speed) mgslpc_set_rate(info, CHB, info->params.clock_speed); else mgslpc_set_rate(info, CHB, 921600); } -static void loopback_enable(MGSLPC_INFO *info) +static void loopback_enable(MGSLPC_INFO *info) { unsigned char val; - - /* CCR1:02..00 CM[2..0] Clock Mode = 111 (clock mode 7) */ + + /* CCR1:02..00 CM[2..0] Clock Mode = 111 (clock mode 7) */ val = read_reg(info, CHA + CCR1) | (BIT2 + BIT1 + BIT0); write_reg(info, CHA + CCR1, val); - - /* CCR2:04 SSEL Clock source select, 1=submode b */ + + /* CCR2:04 SSEL Clock source select, 1=submode b */ val = read_reg(info, CHA + CCR2) | (BIT4 + BIT5); write_reg(info, CHA + CCR2, val); - - /* set LinkSpeed if available, otherwise default to 2Mbps */ + + /* set LinkSpeed if available, otherwise default to 2Mbps */ if (info->params.clock_speed) mgslpc_set_rate(info, CHA, info->params.clock_speed); else mgslpc_set_rate(info, CHA, 1843200); - - /* MODE:00 TLP Test Loop, 1=loopback enabled */ + + /* MODE:00 TLP Test Loop, 1=loopback enabled */ val = read_reg(info, CHA + MODE) | BIT0; write_reg(info, CHA + MODE, val); } @@ -3252,36 +3252,36 @@ static void hdlc_mode(MGSLPC_INFO *info) unsigned char val; unsigned char clkmode, clksubmode; - /* disable all interrupts */ + /* disable all interrupts */ irq_disable(info, CHA, 0xffff); irq_disable(info, CHB, 0xffff); port_irq_disable(info, 0xff); - - /* assume clock mode 0a, rcv=RxC xmt=TxC */ + + /* assume clock mode 0a, rcv=RxC xmt=TxC */ clkmode = clksubmode = 0; if (info->params.flags & HDLC_FLAG_RXC_DPLL && info->params.flags & HDLC_FLAG_TXC_DPLL) { - /* clock mode 7a, rcv = DPLL, xmt = DPLL */ + /* clock mode 7a, rcv = DPLL, xmt = DPLL */ clkmode = 7; } else if (info->params.flags & HDLC_FLAG_RXC_BRG && info->params.flags & HDLC_FLAG_TXC_BRG) { - /* clock mode 7b, rcv = BRG, xmt = BRG */ + /* clock mode 7b, rcv = BRG, xmt = BRG */ clkmode = 7; clksubmode = 1; } else if (info->params.flags & HDLC_FLAG_RXC_DPLL) { if (info->params.flags & HDLC_FLAG_TXC_BRG) { - /* clock mode 6b, rcv = DPLL, xmt = BRG/16 */ + /* clock mode 6b, rcv = DPLL, xmt = BRG/16 */ clkmode = 6; clksubmode = 1; } else { - /* clock mode 6a, rcv = DPLL, xmt = TxC */ + /* clock mode 6a, rcv = DPLL, xmt = TxC */ clkmode = 6; } } else if (info->params.flags & HDLC_FLAG_TXC_BRG) { - /* clock mode 0b, rcv = RxC, xmt = BRG */ + /* clock mode 0b, rcv = RxC, xmt = BRG */ clksubmode = 1; } - + /* MODE * * 07..06 MDS[1..0] 10 = transparent HDLC mode @@ -3293,16 +3293,16 @@ static void hdlc_mode(MGSLPC_INFO *info) * 00 TLP Test Loop, 0 = no loop * * 1000 0010 - */ + */ val = 0x82; if (info->params.loopback) val |= BIT0; - - /* preserve RTS state */ + + /* preserve RTS state */ if (info->serial_signals & SerialSignal_RTS) val |= BIT2; write_reg(info, CHA + MODE, val); - + /* CCR0 * * 07 PU Power Up, 1=active, 0=power down @@ -3312,7 +3312,7 @@ static void hdlc_mode(MGSLPC_INFO *info) * 01..00 SM[1..0] Serial Mode, 00=HDLC * * 11000000 - */ + */ val = 0xc0; switch (info->params.encoding) { @@ -3330,7 +3330,7 @@ static void hdlc_mode(MGSLPC_INFO *info) break; // Manchester } write_reg(info, CHA + CCR0, val); - + /* CCR1 * * 07 SFLG Shared Flag, 0 = disable shared flags @@ -3341,10 +3341,10 @@ static void hdlc_mode(MGSLPC_INFO *info) * 02..00 CM[2..0] Clock Mode * * 0001 0000 - */ + */ val = 0x10 + clkmode; write_reg(info, CHA + CCR1, val); - + /* CCR2 * * 07..06 BGR[9..8] Baud rate bits 9..8 @@ -3356,7 +3356,7 @@ static void hdlc_mode(MGSLPC_INFO *info) * 00 DIV, data inversion 0=disabled, 1=enabled * * 0000 0000 - */ + */ val = 0x00; if (clkmode == 2 || clkmode == 3 || clkmode == 6 || clkmode == 7 || (clkmode == 0 && clksubmode == 1)) @@ -3368,7 +3368,7 @@ static void hdlc_mode(MGSLPC_INFO *info) if (info->params.encoding == HDLC_ENCODING_NRZB) val |= BIT0; write_reg(info, CHA + CCR2, val); - + /* CCR3 * * 07..06 PRE[1..0] Preamble count 00=1, 01=2, 10=4, 11=8 @@ -3380,7 +3380,7 @@ static void hdlc_mode(MGSLPC_INFO *info) * 00 PSD DPLL Phase Shift Disable * * 0000 0000 - */ + */ val = 0x00; if (info->params.crc_type == HDLC_CRC_NONE) val |= BIT2 + BIT1; @@ -3399,8 +3399,8 @@ static void hdlc_mode(MGSLPC_INFO *info) break; } write_reg(info, CHA + CCR3, val); - - /* PRE - Preamble pattern */ + + /* PRE - Preamble pattern */ val = 0; switch (info->params.preamble) { @@ -3410,7 +3410,7 @@ static void hdlc_mode(MGSLPC_INFO *info) case HDLC_PREAMBLE_PATTERN_ONES: val = 0xff; break; } write_reg(info, CHA + PRE, val); - + /* CCR4 * * 07 MCK4 Master Clock Divide by 4, 1=enabled @@ -3421,21 +3421,21 @@ static void hdlc_mode(MGSLPC_INFO *info) * 01..00 RFT[1..0] RxFIFO Threshold 00=32 bytes * * 0101 0000 - */ + */ val = 0x50; write_reg(info, CHA + CCR4, val); if (info->params.flags & HDLC_FLAG_RXC_DPLL) mgslpc_set_rate(info, CHA, info->params.clock_speed * 16); else mgslpc_set_rate(info, CHA, info->params.clock_speed); - + /* RLCR Receive length check register * * 7 1=enable receive length check * 6..0 Max frame length = (RL + 1) * 32 - */ + */ write_reg(info, CHA + RLCR, 0); - + /* XBCH Transmit Byte Count High * * 07 DMA mode, 0 = interrupt driven @@ -3445,7 +3445,7 @@ static void hdlc_mode(MGSLPC_INFO *info) * 03..00 XBC[10..8] Transmit byte count bits 10..8 * * 0000 0000 - */ + */ val = 0x00; if (info->params.flags & HDLC_FLAG_AUTO_DCD) val |= BIT5; @@ -3456,7 +3456,7 @@ static void hdlc_mode(MGSLPC_INFO *info) if (info->params.flags & HDLC_FLAG_AUTO_CTS) { irq_enable(info, CHB, IRQ_CTS); - /* PVR[3] 1=AUTO CTS active */ + /* PVR[3] 1=AUTO CTS active */ set_reg_bits(info, CHA + PVR, BIT3); } else clear_reg_bits(info, CHA + PVR, BIT3); @@ -3467,7 +3467,7 @@ static void hdlc_mode(MGSLPC_INFO *info) issue_command(info, CHA, CMD_TXRESET + CMD_RXRESET); wait_command_complete(info, CHA); read_reg16(info, CHA + ISR); /* clear pending IRQs */ - + /* Master clock mode enabled above to allow reset commands * to complete even if no data clocks are present. * @@ -3477,7 +3477,7 @@ static void hdlc_mode(MGSLPC_INFO *info) * * Leave master clock mode enabled for IRQ test because the * timer IRQ used by the test can only happen in master clock mode. - */ + */ if (!info->testing_irq) clear_reg_bits(info, CHA + CCR0, BIT6); @@ -3492,8 +3492,8 @@ static void rx_stop(MGSLPC_INFO *info) if (debug_level >= DEBUG_LEVEL_ISR) printk("%s(%d):rx_stop(%s)\n", __FILE__,__LINE__, info->device_name ); - - /* MODE:03 RAC Receiver Active, 0=inactive */ + + /* MODE:03 RAC Receiver Active, 0=inactive */ clear_reg_bits(info, CHA + MODE, BIT3); info->rx_enabled = 0; @@ -3510,7 +3510,7 @@ static void rx_start(MGSLPC_INFO *info) info->rx_enabled = 0; info->rx_overflow = 0; - /* MODE:03 RAC Receiver Active, 1=active */ + /* MODE:03 RAC Receiver Active, 1=active */ set_reg_bits(info, CHA + MODE, BIT3); info->rx_enabled = 1; @@ -3521,7 +3521,7 @@ static void tx_start(MGSLPC_INFO *info) if (debug_level >= DEBUG_LEVEL_ISR) printk("%s(%d):tx_start(%s)\n", __FILE__,__LINE__, info->device_name ); - + if (info->tx_count) { /* If auto RTS enabled and RTS is inactive, then assert */ /* RTS and set a flag indicating that the driver should */ @@ -3559,8 +3559,8 @@ static void tx_stop(MGSLPC_INFO *info) if (debug_level >= DEBUG_LEVEL_ISR) printk("%s(%d):tx_stop(%s)\n", __FILE__,__LINE__, info->device_name ); - - del_timer(&info->tx_timer); + + del_timer(&info->tx_timer); info->tx_enabled = 0; info->tx_active = 0; @@ -3570,17 +3570,17 @@ static void tx_stop(MGSLPC_INFO *info) */ static void reset_device(MGSLPC_INFO *info) { - /* power up both channels (set BIT7) */ + /* power up both channels (set BIT7) */ write_reg(info, CHA + CCR0, 0x80); write_reg(info, CHB + CCR0, 0x80); write_reg(info, CHA + MODE, 0); write_reg(info, CHB + MODE, 0); - - /* disable all interrupts */ + + /* disable all interrupts */ irq_disable(info, CHA, 0xffff); irq_disable(info, CHB, 0xffff); port_irq_disable(info, 0xff); - + /* PCR Port Configuration Register * * 07..04 DEC[3..0] Serial I/F select outputs @@ -3590,9 +3590,9 @@ static void reset_device(MGSLPC_INFO *info) * 00 DTR output 0=active * * 0000 0110 - */ + */ write_reg(info, PCR, 0x06); - + /* PVR Port Value Register * * 07..04 DEC[3..0] Serial I/F select (0000=disabled) @@ -3604,7 +3604,7 @@ static void reset_device(MGSLPC_INFO *info) * 0000 0001 */ // write_reg(info, PVR, PVR_DTR); - + /* IPC Interrupt Port Configuration * * 07 VIS 1=Masked interrupts visible @@ -3614,7 +3614,7 @@ static void reset_device(MGSLPC_INFO *info) * 01..00 IC[1..0] Interrupt Config, 01=push-pull output, active low * * 0000 0101 - */ + */ write_reg(info, IPC, 0x05); } @@ -3622,11 +3622,11 @@ static void async_mode(MGSLPC_INFO *info) { unsigned char val; - /* disable all interrupts */ + /* disable all interrupts */ irq_disable(info, CHA, 0xffff); irq_disable(info, CHB, 0xffff); port_irq_disable(info, 0xff); - + /* MODE * * 07 Reserved, 0 @@ -3639,16 +3639,16 @@ static void async_mode(MGSLPC_INFO *info) * 00 TLP Test Loop, 0 = no loop * * 0000 0110 - */ + */ val = 0x06; if (info->params.loopback) val |= BIT0; - - /* preserve RTS state */ + + /* preserve RTS state */ if (!(info->serial_signals & SerialSignal_RTS)) val |= BIT6; write_reg(info, CHA + MODE, val); - + /* CCR0 * * 07 PU Power Up, 1=active, 0=power down @@ -3658,9 +3658,9 @@ static void async_mode(MGSLPC_INFO *info) * 01..00 SM[1..0] Serial Mode, 11=Async * * 1000 0011 - */ + */ write_reg(info, CHA + CCR0, 0x83); - + /* CCR1 * * 07..05 Reserved, 0 @@ -3669,9 +3669,9 @@ static void async_mode(MGSLPC_INFO *info) * 02..00 CM[2..0] Clock Mode, 111=BRG * * 0001 1111 - */ + */ write_reg(info, CHA + CCR1, 0x1f); - + /* CCR2 (channel A) * * 07..06 BGR[9..8] Baud rate bits 9..8 @@ -3683,18 +3683,18 @@ static void async_mode(MGSLPC_INFO *info) * 00 DIV, data inversion 0=disabled, 1=enabled * * 0001 0000 - */ + */ write_reg(info, CHA + CCR2, 0x10); - + /* CCR3 * * 07..01 Reserved, 0 * 00 PSD DPLL Phase Shift Disable * * 0000 0000 - */ + */ write_reg(info, CHA + CCR3, 0); - + /* CCR4 * * 07 MCK4 Master Clock Divide by 4, 1=enabled @@ -3704,10 +3704,10 @@ static void async_mode(MGSLPC_INFO *info) * 03..00 Reserved, must be 0 * * 0101 0000 - */ + */ write_reg(info, CHA + CCR4, 0x50); mgslpc_set_rate(info, CHA, info->params.data_rate * 16); - + /* DAFO Data Format * * 07 Reserved, 0 @@ -3717,7 +3717,7 @@ static void async_mode(MGSLPC_INFO *info) * 02 PAREN Parity Enable * 01..00 CHL[1..0] Character Length (00=8, 01=7) * - */ + */ val = 0x00; if (info->params.data_bits != 8) val |= BIT0; /* 7 bits */ @@ -3732,7 +3732,7 @@ static void async_mode(MGSLPC_INFO *info) val |= BIT4; } write_reg(info, CHA + DAFO, val); - + /* RFC Rx FIFO Control * * 07 Reserved, 0 @@ -3744,15 +3744,15 @@ static void async_mode(MGSLPC_INFO *info) * 00 TCDE Terminate Char Detect Enable, 0=disabled * * 0101 1100 - */ + */ write_reg(info, CHA + RFC, 0x5c); - + /* RLCR Receive length check register * * Max frame length = (RL + 1) * 32 - */ + */ write_reg(info, CHA + RLCR, 0); - + /* XBCH Transmit Byte Count High * * 07 DMA mode, 0 = interrupt driven @@ -3762,20 +3762,20 @@ static void async_mode(MGSLPC_INFO *info) * 03..00 XBC[10..8] Transmit byte count bits 10..8 * * 0000 0000 - */ + */ val = 0x00; if (info->params.flags & HDLC_FLAG_AUTO_DCD) val |= BIT5; write_reg(info, CHA + XBCH, val); if (info->params.flags & HDLC_FLAG_AUTO_CTS) irq_enable(info, CHA, IRQ_CTS); - - /* MODE:03 RAC Receiver Active, 1=active */ + + /* MODE:03 RAC Receiver Active, 1=active */ set_reg_bits(info, CHA + MODE, BIT3); enable_auxclk(info); if (info->params.flags & HDLC_FLAG_AUTO_CTS) { irq_enable(info, CHB, IRQ_CTS); - /* PVR[3] 1=AUTO CTS active */ + /* PVR[3] 1=AUTO CTS active */ set_reg_bits(info, CHA + PVR, BIT3); } else clear_reg_bits(info, CHA + PVR, BIT3); @@ -3791,7 +3791,7 @@ static void async_mode(MGSLPC_INFO *info) */ static void tx_set_idle(MGSLPC_INFO *info) { - /* Note: ESCC2 only supports flags and one idle modes */ + /* Note: ESCC2 only supports flags and one idle modes */ if (info->idle_mode == HDLC_TXIDLE_FLAGS) set_reg_bits(info, CHA + CCR1, BIT3); else @@ -3803,8 +3803,8 @@ static void tx_set_idle(MGSLPC_INFO *info) static void get_signals(MGSLPC_INFO *info) { unsigned char status = 0; - - /* preserve DTR and RTS */ + + /* preserve DTR and RTS */ info->serial_signals &= SerialSignal_DTR + SerialSignal_RTS; if (read_reg(info, CHB + VSTR) & BIT7) @@ -3873,7 +3873,7 @@ static int rx_get_frame(MGSLPC_INFO *info) unsigned long flags; struct tty_struct *tty = info->tty; int return_frame = 0; - + if (info->rx_frame_count == 0) return 0; @@ -3913,10 +3913,10 @@ static int rx_get_frame(MGSLPC_INFO *info) if (debug_level >= DEBUG_LEVEL_BH) printk("%s(%d):rx_get_frame(%s) status=%04X size=%d\n", __FILE__,__LINE__,info->device_name,status,framesize); - + if (debug_level >= DEBUG_LEVEL_DATA) - trace_block(info, buf->data, framesize, 0); - + trace_block(info, buf->data, framesize, 0); + if (framesize) { if ((info->params.crc_type & HDLC_CRC_RETURN_EX && framesize+1 > info->max_frame_size) || @@ -3953,7 +3953,7 @@ static int rx_get_frame(MGSLPC_INFO *info) static BOOLEAN register_test(MGSLPC_INFO *info) { - static unsigned char patterns[] = + static unsigned char patterns[] = { 0x00, 0xff, 0xaa, 0x55, 0x69, 0x96, 0x0f }; static unsigned int count = ARRAY_SIZE(patterns); unsigned int i; @@ -4002,13 +4002,13 @@ static BOOLEAN irq_test(MGSLPC_INFO *info) while(end_time-- && !info->irq_occurred) { msleep_interruptible(10); } - + info->testing_irq = FALSE; spin_lock_irqsave(&info->lock,flags); reset_device(info); spin_unlock_irqrestore(&info->lock,flags); - + return info->irq_occurred ? TRUE : FALSE; } @@ -4042,13 +4042,13 @@ static void trace_block(MGSLPC_INFO *info,const char* data, int count, int xmit) printk("%s tx data:\n",info->device_name); else printk("%s rx data:\n",info->device_name); - + while(count) { if (count > 16) linecount = 16; else linecount = count; - + for(i=0;i<linecount;i++) printk("%02X ",(unsigned char)data[i]); for(;i<17;i++) @@ -4060,7 +4060,7 @@ static void trace_block(MGSLPC_INFO *info,const char* data, int count, int xmit) printk("."); } printk("\n"); - + data += linecount; count -= linecount; } @@ -4073,7 +4073,7 @@ static void tx_timeout(unsigned long context) { MGSLPC_INFO *info = (MGSLPC_INFO*)context; unsigned long flags; - + if ( debug_level >= DEBUG_LEVEL_INFO ) printk( "%s(%d):tx_timeout(%s)\n", __FILE__,__LINE__,info->device_name); @@ -4086,7 +4086,7 @@ static void tx_timeout(unsigned long context) info->tx_count = info->tx_put = info->tx_get = 0; spin_unlock_irqrestore(&info->lock,flags); - + #if SYNCLINK_GENERIC_HDLC if (info->netcount) hdlcdev_tx_done(info); ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 5/17] drivers/char/pcmcia/synclink_cs.c: irq handler cleanups 2007-10-21 7:52 [PATCH 0/17] various irq handler cleanups Jeff Garzik ` (3 preceding siblings ...) 2007-10-21 7:52 ` [PATCH 4/17] char/pcmcia/synclink_cs: trim trailing whitespace Jeff Garzik @ 2007-10-21 7:52 ` Jeff Garzik 2007-10-21 7:52 ` [PATCH 6/17] drivers/char/riscom8: " Jeff Garzik ` (11 subsequent siblings) 16 siblings, 0 replies; 24+ messages in thread From: Jeff Garzik @ 2007-10-21 7:52 UTC (permalink / raw) To: LKML; +Cc: paulkf commit 1c354fd1d5dd786a19d30ba4e2ae664be8f348ff Author: Jeff Garzik <jeff@garzik.org> Date: Fri Oct 19 16:39:55 2007 -0400 drivers/char/pcmcia/synclink_cs.c: irq handler cleanups No need to reference 'irq' function arg. Remove pointless test. Signed-off-by: Jeff Garzik <jgarzik@redhat.com> drivers/char/pcmcia/synclink_cs.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 1c354fd1d5dd786a19d30ba4e2ae664be8f348ff diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index 8caff0c..8f3a123 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c @@ -1226,17 +1226,15 @@ static void ri_change(MGSLPC_INFO *info) * irq interrupt number that caused interrupt * dev_id device ID supplied during interrupt registration */ -static irqreturn_t mgslpc_isr(int irq, void *dev_id) +static irqreturn_t mgslpc_isr(int dummy, void *dev_id) { - MGSLPC_INFO * info = (MGSLPC_INFO *)dev_id; + MGSLPC_INFO *info = dev_id; unsigned short isr; unsigned char gis, pis; int count=0; if (debug_level >= DEBUG_LEVEL_ISR) - printk("mgslpc_isr(%d) entry.\n", irq); - if (!info) - return IRQ_NONE; + printk("mgslpc_isr(%d) entry.\n", info->irq_level); if (!(info->p_dev->_locked)) return IRQ_HANDLED; @@ -1328,7 +1326,7 @@ static irqreturn_t mgslpc_isr(int irq, void *dev_id) if (debug_level >= DEBUG_LEVEL_ISR) printk("%s(%d):mgslpc_isr(%d)exit.\n", - __FILE__,__LINE__,irq); + __FILE__, __LINE__, info->irq_level); return IRQ_HANDLED; } ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 6/17] drivers/char/riscom8: irq handler cleanups 2007-10-21 7:52 [PATCH 0/17] various irq handler cleanups Jeff Garzik ` (4 preceding siblings ...) 2007-10-21 7:52 ` [PATCH 5/17] drivers/char/pcmcia/synclink_cs.c: irq handler cleanups Jeff Garzik @ 2007-10-21 7:52 ` Jeff Garzik 2007-10-21 9:01 ` Jiri Slaby 2007-10-21 7:52 ` [PATCH 7/17] drivers/char/{rio,specialix,sx}: " Jeff Garzik ` (10 subsequent siblings) 16 siblings, 1 reply; 24+ messages in thread From: Jeff Garzik @ 2007-10-21 7:52 UTC (permalink / raw) To: LKML commit 93ea6d56f83b7b614c103222fa098cb30d26f608 Author: Jeff Garzik <jeff@garzik.org> Date: Fri Oct 19 16:41:23 2007 -0400 drivers/char/riscom8: irq handler cleanups No need to lookup board ptr, we already have it. Also, remove a few 'inline' markers and let the compiler make that decision. Signed-off-by: Jeff Garzik <jgarzik@redhat.com> drivers/char/riscom8.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) 93ea6d56f83b7b614c103222fa098cb30d26f608 diff --git a/drivers/char/riscom8.c b/drivers/char/riscom8.c index b37e626..d307320 100644 --- a/drivers/char/riscom8.c +++ b/drivers/char/riscom8.c @@ -537,16 +537,14 @@ static inline void rc_check_modem(struct riscom_board const * bp) } /* The main interrupt processing routine */ -static irqreturn_t rc_interrupt(int irq, void * dev_id) +static irqreturn_t rc_interrupt(int dummy, void * dev_id) { unsigned char status; unsigned char ack; - struct riscom_board *bp; + struct riscom_board *bp = dev_id; unsigned long loop = 0; int handled = 0; - bp = IRQ_to_board[irq]; - if (!(bp->flags & RC_BOARD_ACTIVE)) return IRQ_NONE; @@ -603,7 +601,7 @@ static irqreturn_t rc_interrupt(int irq, void * dev_id) */ /* Called with disabled interrupts */ -static inline int rc_setup_board(struct riscom_board * bp) +static int rc_setup_board(struct riscom_board * bp) { int error; @@ -611,7 +609,7 @@ static inline int rc_setup_board(struct riscom_board * bp) return 0; error = request_irq(bp->irq, rc_interrupt, IRQF_DISABLED, - "RISCom/8", NULL); + "RISCom/8", bp); if (error) return error; @@ -626,7 +624,7 @@ static inline int rc_setup_board(struct riscom_board * bp) } /* Called with disabled interrupts */ -static inline void rc_shutdown_board(struct riscom_board *bp) +static void rc_shutdown_board(struct riscom_board *bp) { if (!(bp->flags & RC_BOARD_ACTIVE)) return; ^ permalink raw reply related [flat|nested] 24+ messages in thread
* Re: [PATCH 6/17] drivers/char/riscom8: irq handler cleanups 2007-10-21 7:52 ` [PATCH 6/17] drivers/char/riscom8: " Jeff Garzik @ 2007-10-21 9:01 ` Jiri Slaby 2007-10-21 9:06 ` Jeff Garzik 0 siblings, 1 reply; 24+ messages in thread From: Jiri Slaby @ 2007-10-21 9:01 UTC (permalink / raw) To: Jeff Garzik; +Cc: LKML On 10/21/2007 09:52 AM, Jeff Garzik wrote: > commit 93ea6d56f83b7b614c103222fa098cb30d26f608 > Author: Jeff Garzik <jeff@garzik.org> > Date: Fri Oct 19 16:41:23 2007 -0400 > > drivers/char/riscom8: irq handler cleanups > > No need to lookup board ptr, we already have it. > > Also, remove a few 'inline' markers and let the compiler make that > decision. > > Signed-off-by: Jeff Garzik <jgarzik@redhat.com> Acked-by: Jiri Slaby <jirislaby@gmail.com> > > drivers/char/riscom8.c | 12 +++++------- > 1 file changed, 5 insertions(+), 7 deletions(-) > > 93ea6d56f83b7b614c103222fa098cb30d26f608 > diff --git a/drivers/char/riscom8.c b/drivers/char/riscom8.c > index b37e626..d307320 100644 > --- a/drivers/char/riscom8.c > +++ b/drivers/char/riscom8.c > @@ -537,16 +537,14 @@ static inline void rc_check_modem(struct riscom_board const * bp) > } > > /* The main interrupt processing routine */ > -static irqreturn_t rc_interrupt(int irq, void * dev_id) > +static irqreturn_t rc_interrupt(int dummy, void * dev_id) > { > unsigned char status; > unsigned char ack; > - struct riscom_board *bp; > + struct riscom_board *bp = dev_id; > unsigned long loop = 0; > int handled = 0; > > - bp = IRQ_to_board[irq]; > - Remove the declaration of the IRQ_to_board too, since we don't reference it anymore, we only set it up. regards, -- Jiri Slaby (jirislaby@gmail.com) Faculty of Informatics, Masaryk University ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 6/17] drivers/char/riscom8: irq handler cleanups 2007-10-21 9:01 ` Jiri Slaby @ 2007-10-21 9:06 ` Jeff Garzik 0 siblings, 0 replies; 24+ messages in thread From: Jeff Garzik @ 2007-10-21 9:06 UTC (permalink / raw) To: Jiri Slaby; +Cc: LKML Jiri Slaby wrote: >> -static irqreturn_t rc_interrupt(int irq, void * dev_id) >> +static irqreturn_t rc_interrupt(int dummy, void * dev_id) >> { >> unsigned char status; >> unsigned char ack; >> - struct riscom_board *bp; >> + struct riscom_board *bp = dev_id; >> unsigned long loop = 0; >> int handled = 0; >> >> - bp = IRQ_to_board[irq]; >> - > > Remove the declaration of the IRQ_to_board too, since we don't reference it > anymore, we only set it up. done, thanks ^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 7/17] drivers/char/{rio,specialix,sx}: irq handler cleanups 2007-10-21 7:52 [PATCH 0/17] various irq handler cleanups Jeff Garzik ` (5 preceding siblings ...) 2007-10-21 7:52 ` [PATCH 6/17] drivers/char/riscom8: " Jeff Garzik @ 2007-10-21 7:52 ` Jeff Garzik 2007-10-21 7:52 ` [PATCH 8/17] arch/x86/kernel/vm86_32.c: irq handler cleanup Jeff Garzik ` (9 subsequent siblings) 16 siblings, 0 replies; 24+ messages in thread From: Jeff Garzik @ 2007-10-21 7:52 UTC (permalink / raw) To: LKML; +Cc: R.E.Wolff commit ac608e65f5c2a99affced5f02eefe24125f9c5bd Author: Jeff Garzik <jeff@garzik.org> Date: Fri Oct 19 16:43:21 2007 -0400 drivers/char/{rio,specialix,sx}: irq handler cleanups * explicitly separate polled and irq-driven modes of operation * no need to reference 'irq' function arg * mark a free_irq() -in-irq-handler use with a FIXME (ugh!) Signed-off-by: Jeff Garzik <jgarzik@redhat.com> drivers/char/rio/rio_linux.c | 23 +++++++++++++---------- drivers/char/specialix.c | 10 ++++------ drivers/char/sx.c | 22 ++++++++++++++-------- 3 files changed, 31 insertions(+), 24 deletions(-) ac608e65f5c2a99affced5f02eefe24125f9c5bd diff --git a/drivers/char/rio/rio_linux.c b/drivers/char/rio/rio_linux.c index 0ce9667..fb06665 100644 --- a/drivers/char/rio/rio_linux.c +++ b/drivers/char/rio/rio_linux.c @@ -362,14 +362,11 @@ static void rio_reset_interrupt(struct Host *HostP) func_exit(); } - -static irqreturn_t rio_interrupt(int irq, void *ptr) +static irqreturn_t __rio_interrupt(struct Host *HostP, bool polled) { - struct Host *HostP; func_enter(); - HostP = ptr; /* &p->RIOHosts[(long)ptr]; */ - rio_dprintk(RIO_DEBUG_IFLOW, "rio: enter rio_interrupt (%d/%d)\n", irq, HostP->Ivec); + rio_dprintk(RIO_DEBUG_IFLOW, "rio: enter rio_interrupt (%d)\n", HostP->Ivec); /* AAargh! The order in which to do these things is essential and not trivial. @@ -389,7 +386,7 @@ static irqreturn_t rio_interrupt(int irq, void *ptr) */ rio_dprintk(RIO_DEBUG_IFLOW, "rio: We've have noticed the interrupt\n"); - if (HostP->Ivec == irq) { + if (!polled) { /* Tell the card we've noticed the interrupt. */ rio_reset_interrupt(HostP); } @@ -398,26 +395,32 @@ static irqreturn_t rio_interrupt(int irq, void *ptr) return IRQ_HANDLED; if (test_and_set_bit(RIO_BOARD_INTR_LOCK, &HostP->locks)) { - printk(KERN_ERR "Recursive interrupt! (host %p/irq%d)\n", ptr, HostP->Ivec); + printk(KERN_ERR "Recursive interrupt! (host %p/irq%d)\n", + HostP, HostP->Ivec); return IRQ_HANDLED; } RIOServiceHost(p, HostP); - rio_dprintk(RIO_DEBUG_IFLOW, "riointr() doing host %p type %d\n", ptr, HostP->Type); + rio_dprintk(RIO_DEBUG_IFLOW, "riointr() doing host %p type %d\n", + HostP, HostP->Type); clear_bit(RIO_BOARD_INTR_LOCK, &HostP->locks); - rio_dprintk(RIO_DEBUG_IFLOW, "rio: exit rio_interrupt (%d/%d)\n", irq, HostP->Ivec); + rio_dprintk(RIO_DEBUG_IFLOW, "rio: exit rio_interrupt (%d)\n", HostP->Ivec); func_exit(); return IRQ_HANDLED; } +static irqreturn_t rio_interrupt(int dummy, void *ptr) +{ + return __rio_interrupt(ptr, false); +} static void rio_pollfunc(unsigned long data) { func_enter(); - rio_interrupt(0, &p->RIOHosts[data]); + __rio_interrupt(&p->RIOHosts[data], true); mod_timer(&p->RIOHosts[data].timer, jiffies + rio_poll); func_exit(); diff --git a/drivers/char/specialix.c b/drivers/char/specialix.c index 4558556..706e74f 100644 --- a/drivers/char/specialix.c +++ b/drivers/char/specialix.c @@ -446,8 +446,7 @@ void missed_irq (unsigned long data) spin_unlock_irqrestore(&bp->lock, flags); if (irq) { printk (KERN_INFO "Missed interrupt... Calling int from timer. \n"); - sx_interrupt (((struct specialix_board *)data)->irq, - (void*)data); + sx_interrupt (-1, bp); } mod_timer(&missed_irq_timer, jiffies + sx_poll); } @@ -876,23 +875,22 @@ static inline void sx_check_modem(struct specialix_board * bp) /* The main interrupt processing routine */ -static irqreturn_t sx_interrupt(int irq, void *dev_id) +static irqreturn_t sx_interrupt(int dummy, void *dev_id) { unsigned char status; unsigned char ack; - struct specialix_board *bp; + struct specialix_board *bp = dev_id; unsigned long loop = 0; int saved_reg; unsigned long flags; func_enter(); - bp = dev_id; spin_lock_irqsave(&bp->lock, flags); dprintk (SX_DEBUG_FLOW, "enter %s port %d room: %ld\n", __FUNCTION__, port_No(sx_get_port(bp, "INT")), SERIAL_XMIT_SIZE - sx_get_port(bp, "ITN")->xmit_cnt - 1); if (!(bp->flags & SX_BOARD_ACTIVE)) { - dprintk (SX_DEBUG_IRQ, "sx: False interrupt. irq %d.\n", irq); + dprintk (SX_DEBUG_IRQ, "sx: False interrupt. irq %d.\n", bp->irq); spin_unlock_irqrestore(&bp->lock, flags); func_exit(); return IRQ_NONE; diff --git a/drivers/char/sx.c b/drivers/char/sx.c index a6e1c9b..ae9e973 100644 --- a/drivers/char/sx.c +++ b/drivers/char/sx.c @@ -1241,15 +1241,13 @@ static inline void sx_check_modem_signals(struct sx_port *port) * Small, elegant, clear. */ -static irqreturn_t sx_interrupt(int irq, void *ptr) +static irqreturn_t __sx_interrupt(struct sx_board *board, bool polled) { - struct sx_board *board = ptr; struct sx_port *port; int i; func_enter(); - sx_dprintk(SX_DEBUG_FLOW, "sx: enter sx_interrupt (%d/%d)\n", irq, - board->irq); + sx_dprintk(SX_DEBUG_FLOW, "sx: enter sx_interrupt (%d)\n", board->irq); /* AAargh! The order in which to do these things is essential and not trivial. @@ -1281,6 +1279,10 @@ static irqreturn_t sx_interrupt(int irq, void *ptr) if (lastjif == jiffies) { if (++nintr > IRQ_RATE_LIMIT) { + /* + * FIXME: free_irq() inside irq handler + * is unwise + */ free_irq(board->irq, board); printk(KERN_ERR "sx: Too many interrupts. " "Turning off interrupt %d.\n", @@ -1293,7 +1295,7 @@ static irqreturn_t sx_interrupt(int irq, void *ptr) } #endif - if (board->irq == irq) { + if (!polled) { /* Tell the card we've noticed the interrupt. */ sx_write_board_word(board, cc_int_pending, 0); @@ -1339,19 +1341,23 @@ static irqreturn_t sx_interrupt(int irq, void *ptr) clear_bit(SX_BOARD_INTR_LOCK, &board->locks); - sx_dprintk(SX_DEBUG_FLOW, "sx: exit sx_interrupt (%d/%d)\n", irq, - board->irq); + sx_dprintk(SX_DEBUG_FLOW, "sx: exit sx_interrupt (%d)\n", board->irq); func_exit(); return IRQ_HANDLED; } +static irqreturn_t sx_interrupt(int dummy, void *data) +{ + return __sx_interrupt(data, false); +} + static void sx_pollfunc(unsigned long data) { struct sx_board *board = (struct sx_board *)data; func_enter(); - sx_interrupt(0, board); + __sx_interrupt(board, true); mod_timer(&board->timer, jiffies + sx_poll); func_exit(); ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 8/17] arch/x86/kernel/vm86_32.c: irq handler cleanup 2007-10-21 7:52 [PATCH 0/17] various irq handler cleanups Jeff Garzik ` (6 preceding siblings ...) 2007-10-21 7:52 ` [PATCH 7/17] drivers/char/{rio,specialix,sx}: " Jeff Garzik @ 2007-10-21 7:52 ` Jeff Garzik 2007-10-21 9:21 ` Thomas Gleixner 2007-10-21 7:52 ` [PATCH 9/17] drivers/char/{synclink,tpm}: irq handler cleanups Jeff Garzik ` (8 subsequent siblings) 16 siblings, 1 reply; 24+ messages in thread From: Jeff Garzik @ 2007-10-21 7:52 UTC (permalink / raw) To: LKML; +Cc: tglx commit f57c82aa01f4387c8400acb43afa7fc580635e16 Author: Jeff Garzik <jeff@garzik.org> Date: Fri Oct 19 19:25:42 2007 -0400 arch/x86/kernel/vm86_32.c: irq handler cleanup Obtain the data we want (irq number) via dev_id. Signed-off-by: Jeff Garzik <jgarzik@redhat.com> arch/x86/kernel/vm86_32.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) f57c82aa01f4387c8400acb43afa7fc580635e16 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c index 157e4be..336618b 100644 --- a/arch/x86/kernel/vm86_32.c +++ b/arch/x86/kernel/vm86_32.c @@ -739,8 +739,9 @@ static int irqbits; | (1 << SIGUSR1) | (1 << SIGUSR2) | (1 << SIGIO) | (1 << SIGURG) \ | (1 << SIGUNUSED) ) -static irqreturn_t irq_handler(int intno, void *dev_id) +static irqreturn_t irq_handler(int dummy, void *dev_id) { + int intno = (int)(unsigned long) dev_id; int irq_bit; unsigned long flags; @@ -822,7 +823,8 @@ static int do_vm86_irq_handling(int subfunction, int irqnumber) if (!((1 << sig) & ALLOWED_SIGS)) return -EPERM; if (invalid_vm86_irq(irq)) return -EPERM; if (vm86_irqs[irq].tsk) return -EPERM; - ret = request_irq(irq, &irq_handler, 0, VM86_IRQNAME, NULL); + ret = request_irq(irq, irq_handler, 0, VM86_IRQNAME, + (void *)(unsigned long) irq); if (ret) return ret; vm86_irqs[irq].sig = sig; vm86_irqs[irq].tsk = current; ^ permalink raw reply related [flat|nested] 24+ messages in thread
* Re: [PATCH 8/17] arch/x86/kernel/vm86_32.c: irq handler cleanup 2007-10-21 7:52 ` [PATCH 8/17] arch/x86/kernel/vm86_32.c: irq handler cleanup Jeff Garzik @ 2007-10-21 9:21 ` Thomas Gleixner 0 siblings, 0 replies; 24+ messages in thread From: Thomas Gleixner @ 2007-10-21 9:21 UTC (permalink / raw) To: Jeff Garzik; +Cc: LKML On Sun, 21 Oct 2007, Jeff Garzik wrote: > commit f57c82aa01f4387c8400acb43afa7fc580635e16 > Author: Jeff Garzik <jeff@garzik.org> > Date: Fri Oct 19 19:25:42 2007 -0400 > > arch/x86/kernel/vm86_32.c: irq handler cleanup > > Obtain the data we want (irq number) via dev_id. > > Signed-off-by: Jeff Garzik <jgarzik@redhat.com> > > arch/x86/kernel/vm86_32.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > f57c82aa01f4387c8400acb43afa7fc580635e16 > diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c > index 157e4be..336618b 100644 > --- a/arch/x86/kernel/vm86_32.c > +++ b/arch/x86/kernel/vm86_32.c > @@ -739,8 +739,9 @@ static int irqbits; > | (1 << SIGUSR1) | (1 << SIGUSR2) | (1 << SIGIO) | (1 << SIGURG) \ > | (1 << SIGUNUSED) ) > > -static irqreturn_t irq_handler(int intno, void *dev_id) > +static irqreturn_t irq_handler(int dummy, void *dev_id) > { > + int intno = (int)(unsigned long) dev_id; > int irq_bit; can we put the two ints into one line please. The typecast is ugly, but looking into the file itself it does not really increase the existing ugliness much. Acked-by: Thomas Gleixner <tglx@linutronix.de> ^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 9/17] drivers/char/{synclink,tpm}: irq handler cleanups 2007-10-21 7:52 [PATCH 0/17] various irq handler cleanups Jeff Garzik ` (7 preceding siblings ...) 2007-10-21 7:52 ` [PATCH 8/17] arch/x86/kernel/vm86_32.c: irq handler cleanup Jeff Garzik @ 2007-10-21 7:52 ` Jeff Garzik 2007-10-21 7:52 ` [PATCH 10/17] drivers/input/serio/i8042.c: irq handler clean Jeff Garzik ` (7 subsequent siblings) 16 siblings, 0 replies; 24+ messages in thread From: Jeff Garzik @ 2007-10-21 7:52 UTC (permalink / raw) To: LKML; +Cc: paulkf commit 81ccec23142e4fe42b3f72faecccb7b64f84007e Author: Jeff Garzik <jeff@garzik.org> Date: Fri Oct 19 19:27:19 2007 -0400 drivers/char/{synclink,tpm}: irq handler cleanups * no need to use 'irq' function arg * delete pointless test, pointless casts * add KERN_xxx prefixes where appropriate Signed-off-by: Jeff Garzik <jgarzik@redhat.com> drivers/char/synclink.c | 21 +++++++++------------ drivers/char/synclink_gt.c | 13 ++++--------- drivers/char/synclinkmp.c | 22 +++++++++------------- drivers/char/tpm/tpm_tis.c | 2 +- 4 files changed, 23 insertions(+), 35 deletions(-) 81ccec23142e4fe42b3f72faecccb7b64f84007e diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c index 905d1f5..aa09909 100644 --- a/drivers/char/synclink.c +++ b/drivers/char/synclink.c @@ -1696,20 +1696,16 @@ static void mgsl_isr_transmit_dma( struct mgsl_struct *info ) * * Return Value: None */ -static irqreturn_t mgsl_interrupt(int irq, void *dev_id) +static irqreturn_t mgsl_interrupt(int dummy, void *dev_id) { - struct mgsl_struct * info; + struct mgsl_struct *info = dev_id; u16 UscVector; u16 DmaVector; if ( debug_level >= DEBUG_LEVEL_ISR ) - printk("%s(%d):mgsl_interrupt(%d)entry.\n", - __FILE__,__LINE__,irq); + printk(KERN_DEBUG "%s(%d):mgsl_interrupt(%d)entry.\n", + __FILE__, __LINE__, info->irq_level); - info = (struct mgsl_struct *)dev_id; - if (!info) - return IRQ_NONE; - spin_lock(&info->irq_spinlock); for(;;) { @@ -1733,8 +1729,8 @@ static irqreturn_t mgsl_interrupt(int irq, void *dev_id) mgsl_isr_receive_dma(info); if ( info->isr_overflow ) { - printk(KERN_ERR"%s(%d):%s isr overflow irq=%d\n", - __FILE__,__LINE__,info->device_name, irq); + printk(KERN_ERR "%s(%d):%s isr overflow irq=%d\n", + __FILE__, __LINE__, info->device_name, info->irq_level); usc_DisableMasterIrqBit(info); usc_DisableDmaInterrupts(info,DICR_MASTER); break; @@ -1756,8 +1752,9 @@ static irqreturn_t mgsl_interrupt(int irq, void *dev_id) spin_unlock(&info->irq_spinlock); if ( debug_level >= DEBUG_LEVEL_ISR ) - printk("%s(%d):mgsl_interrupt(%d)exit.\n", - __FILE__,__LINE__,irq); + printk(KERN_DEBUG "%s(%d):mgsl_interrupt(%d)exit.\n", + __FILE__, __LINE__, info->irq_level); + return IRQ_HANDLED; } /* end of mgsl_interrupt() */ diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c index 64e835f..468dae1 100644 --- a/drivers/char/synclink_gt.c +++ b/drivers/char/synclink_gt.c @@ -492,7 +492,6 @@ static void isr_serial(struct slgt_info *info); static void isr_rdma(struct slgt_info *info); static void isr_txeom(struct slgt_info *info, unsigned short status); static void isr_tdma(struct slgt_info *info); -static irqreturn_t slgt_interrupt(int irq, void *dev_id); static int alloc_dma_bufs(struct slgt_info *info); static void free_dma_bufs(struct slgt_info *info); @@ -2321,17 +2320,13 @@ static void isr_gpio(struct slgt_info *info, unsigned int changed, unsigned int * irq interrupt number * dev_id device ID supplied during interrupt registration */ -static irqreturn_t slgt_interrupt(int irq, void *dev_id) +static irqreturn_t slgt_interrupt(int dummy, void *dev_id) { - struct slgt_info *info; + struct slgt_info *info = dev_id; unsigned int gsr; unsigned int i; - DBGISR(("slgt_interrupt irq=%d entry\n", irq)); - - info = dev_id; - if (!info) - return IRQ_NONE; + DBGISR(("slgt_interrupt irq=%d entry\n", info->irq_level)); spin_lock(&info->lock); @@ -2380,7 +2375,7 @@ static irqreturn_t slgt_interrupt(int irq, void *dev_id) spin_unlock(&info->lock); - DBGISR(("slgt_interrupt irq=%d exit\n", irq)); + DBGISR(("slgt_interrupt irq=%d exit\n", info->irq_level)); return IRQ_HANDLED; } diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c index c63013b..f79c8b2 100644 --- a/drivers/char/synclinkmp.c +++ b/drivers/char/synclinkmp.c @@ -2587,9 +2587,9 @@ void isr_io_pin( SLMP_INFO *info, u16 status ) * dev_id device ID supplied during interrupt registration * regs interrupted processor context */ -static irqreturn_t synclinkmp_interrupt(int irq, void *dev_id) +static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id) { - SLMP_INFO * info; + SLMP_INFO *info = dev_id; unsigned char status, status0, status1=0; unsigned char dmastatus, dmastatus0, dmastatus1=0; unsigned char timerstatus0, timerstatus1=0; @@ -2598,12 +2598,8 @@ static irqreturn_t synclinkmp_interrupt(int irq, void *dev_id) unsigned short tmp; if ( debug_level >= DEBUG_LEVEL_ISR ) - printk("%s(%d): synclinkmp_interrupt(%d)entry.\n", - __FILE__,__LINE__,irq); - - info = (SLMP_INFO *)dev_id; - if (!info) - return IRQ_NONE; + printk(KERN_DEBUG "%s(%d): synclinkmp_interrupt(%d)entry.\n", + __FILE__, __LINE__, info->irq_level); spin_lock(&info->lock); @@ -2616,9 +2612,9 @@ static irqreturn_t synclinkmp_interrupt(int irq, void *dev_id) timerstatus0 = read_reg(info, ISR2); if ( debug_level >= DEBUG_LEVEL_ISR ) - printk("%s(%d):%s status0=%02x, dmastatus0=%02x, timerstatus0=%02x\n", - __FILE__,__LINE__,info->device_name, - status0,dmastatus0,timerstatus0); + printk(KERN_DEBUG "%s(%d):%s status0=%02x, dmastatus0=%02x, timerstatus0=%02x\n", + __FILE__, __LINE__, info->device_name, + status0, dmastatus0, timerstatus0); if (info->port_count == 4) { /* get status for SCA1 (ports 2-3) */ @@ -2703,8 +2699,8 @@ static irqreturn_t synclinkmp_interrupt(int irq, void *dev_id) spin_unlock(&info->lock); if ( debug_level >= DEBUG_LEVEL_ISR ) - printk("%s(%d):synclinkmp_interrupt(%d)exit.\n", - __FILE__,__LINE__,irq); + printk(KERN_DEBUG "%s(%d):synclinkmp_interrupt(%d)exit.\n", + __FILE__, __LINE__, info->irq_level); return IRQ_HANDLED; } diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c index fd771a4..9e12638 100644 --- a/drivers/char/tpm/tpm_tis.c +++ b/drivers/char/tpm/tpm_tis.c @@ -399,7 +399,7 @@ static irqreturn_t tis_int_probe(int irq, void *dev_id) return IRQ_HANDLED; } -static irqreturn_t tis_int_handler(int irq, void *dev_id) +static irqreturn_t tis_int_handler(int dummy, void *dev_id) { struct tpm_chip *chip = dev_id; u32 interrupt; ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 10/17] drivers/input/serio/i8042.c: irq handler clean 2007-10-21 7:52 [PATCH 0/17] various irq handler cleanups Jeff Garzik ` (8 preceding siblings ...) 2007-10-21 7:52 ` [PATCH 9/17] drivers/char/{synclink,tpm}: irq handler cleanups Jeff Garzik @ 2007-10-21 7:52 ` Jeff Garzik 2007-10-21 17:57 ` Dmitry Torokhov 2007-10-21 7:52 ` [PATCH 11/17] isdn/act2000: fix major bug. clean irq handler Jeff Garzik ` (6 subsequent siblings) 16 siblings, 1 reply; 24+ messages in thread From: Jeff Garzik @ 2007-10-21 7:52 UTC (permalink / raw) To: LKML; +Cc: dtor commit bdf311215ef8dbae0254c092deaed1d5928b013e Author: Jeff Garzik <jeff@garzik.org> Date: Fri Oct 19 19:28:54 2007 -0400 drivers/input/serio/i8042.c: irq handler clean * remove unnecessary prototype * distinguish between polled and irq-driven event handling * don't bother worrying about 'irq' function arg * dev_id passed to irq handlers is unused, to change the request_irq() argument to NULL Signed-off-by: Jeff Garzik <jgarzik@redhat.com> drivers/input/serio/i8042.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) bdf311215ef8dbae0254c092deaed1d5928b013e diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c index 11dafc0..51c57f0 100644 --- a/drivers/input/serio/i8042.c +++ b/drivers/input/serio/i8042.c @@ -102,8 +102,6 @@ static unsigned char i8042_aux_irq_registered; static unsigned char i8042_suppress_kbd_ack; static struct platform_device *i8042_platform_device; -static irqreturn_t i8042_interrupt(int irq, void *dev_id); - /* * The i8042_wait_read() and i8042_wait_write functions wait for the i8042 to * be ready for reading values from it / writing values to it. @@ -288,7 +286,7 @@ static void i8042_stop(struct serio *serio) * to the upper layers. */ -static irqreturn_t i8042_interrupt(int irq, void *dev_id) +static irqreturn_t __i8042_interrupt(bool polled) { struct i8042_port *port; unsigned long flags; @@ -301,7 +299,7 @@ static irqreturn_t i8042_interrupt(int irq, void *dev_id) str = i8042_read_status(); if (unlikely(~str & I8042_STR_OBF)) { spin_unlock_irqrestore(&i8042_lock, flags); - if (irq) dbg("Interrupt %d, without any data", irq); + if (!polled) dbg("Interrupt without any data"); ret = 0; goto out; } @@ -356,8 +354,8 @@ static irqreturn_t i8042_interrupt(int irq, void *dev_id) port = &i8042_ports[port_no]; - dbg("%02x <- i8042 (interrupt, %d, %d%s%s)", - data, port_no, irq, + dbg("%02x <- i8042 (interrupt, %d, %s%s)", + data, port_no, dfl & SERIO_PARITY ? ", bad parity" : "", dfl & SERIO_TIMEOUT ? ", timeout" : ""); @@ -375,6 +373,11 @@ static irqreturn_t i8042_interrupt(int irq, void *dev_id) return IRQ_RETVAL(ret); } +static irqreturn_t i8042_interrupt(int dummy, void *dev_id) +{ + return __i8042_interrupt(false); +} + /* * i8042_enable_kbd_port enables keybaord port on chip */ @@ -636,7 +639,7 @@ static int __devinit i8042_check_aux(void) } if (request_irq(I8042_AUX_IRQ, i8042_aux_test_irq, IRQF_SHARED, - "i8042", i8042_platform_device)) + "i8042", NULL)) goto out; irq_registered = 1; @@ -939,7 +942,7 @@ static int i8042_resume(struct platform_device *dev) if (i8042_ports[I8042_KBD_PORT_NO].serio) i8042_enable_kbd_port(); - i8042_interrupt(0, NULL); + __i8042_interrupt(true); dev->dev.power.power_state = PMSG_ON; @@ -1090,7 +1093,7 @@ static int __devinit i8042_setup_aux(void) } error = request_irq(I8042_AUX_IRQ, i8042_interrupt, IRQF_SHARED, - "i8042", i8042_platform_device); + "i8042", NULL); if (error) goto err_free_ports; @@ -1116,7 +1119,7 @@ static int __devinit i8042_setup_kbd(void) return error; error = request_irq(I8042_KBD_IRQ, i8042_interrupt, IRQF_SHARED, - "i8042", i8042_platform_device); + "i8042", NULL); if (error) goto err_free_port; ^ permalink raw reply related [flat|nested] 24+ messages in thread
* Re: [PATCH 10/17] drivers/input/serio/i8042.c: irq handler clean 2007-10-21 7:52 ` [PATCH 10/17] drivers/input/serio/i8042.c: irq handler clean Jeff Garzik @ 2007-10-21 17:57 ` Dmitry Torokhov 2007-10-30 12:36 ` Jeff Garzik 0 siblings, 1 reply; 24+ messages in thread From: Dmitry Torokhov @ 2007-10-21 17:57 UTC (permalink / raw) To: Jeff Garzik; +Cc: LKML Hi Jeff, On Sunday 21 October 2007, Jeff Garzik wrote: > commit bdf311215ef8dbae0254c092deaed1d5928b013e > Author: Jeff Garzik <jeff@garzik.org> > Date: Fri Oct 19 19:28:54 2007 -0400 > > drivers/input/serio/i8042.c: irq handler clean > > * remove unnecessary prototype > > * distinguish between polled and irq-driven event handling > > * don't bother worrying about 'irq' function arg I don't like these 2 changes. When I ask for debug data I really want to know what interrupt (1 or 12) was raised in response to a command. Your changes remove this visibility. > > * dev_id passed to irq handlers is unused, to change the request_irq() > argument to NULL > Does this really matter? Thanks. -- Dmitry ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 10/17] drivers/input/serio/i8042.c: irq handler clean 2007-10-21 17:57 ` Dmitry Torokhov @ 2007-10-30 12:36 ` Jeff Garzik 0 siblings, 0 replies; 24+ messages in thread From: Jeff Garzik @ 2007-10-30 12:36 UTC (permalink / raw) To: Dmitry Torokhov; +Cc: LKML Dmitry Torokhov wrote: > Hi Jeff, > > On Sunday 21 October 2007, Jeff Garzik wrote: >> commit bdf311215ef8dbae0254c092deaed1d5928b013e >> Author: Jeff Garzik <jeff@garzik.org> >> Date: Fri Oct 19 19:28:54 2007 -0400 >> >> drivers/input/serio/i8042.c: irq handler clean >> >> * remove unnecessary prototype >> >> * distinguish between polled and irq-driven event handling >> >> * don't bother worrying about 'irq' function arg > > I don't like these 2 changes. When I ask for debug data I really > want to know what interrupt (1 or 12) was raised in response to > a command. Your changes remove this visibility. So noted... >> * dev_id passed to irq handlers is unused, to change the request_irq() >> argument to NULL >> > > Does this really matter? Does it has any effect on the computer? No. Does it has any effect on the human reviewer? IMO yes :) But it is a trivial matter. Jeff ^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 11/17] isdn/act2000: fix major bug. clean irq handler 2007-10-21 7:52 [PATCH 0/17] various irq handler cleanups Jeff Garzik ` (9 preceding siblings ...) 2007-10-21 7:52 ` [PATCH 10/17] drivers/input/serio/i8042.c: irq handler clean Jeff Garzik @ 2007-10-21 7:52 ` Jeff Garzik 2007-10-21 7:52 ` [PATCH 12/17] isdn/sc: irq handler clean Jeff Garzik ` (5 subsequent siblings) 16 siblings, 0 replies; 24+ messages in thread From: Jeff Garzik @ 2007-10-21 7:52 UTC (permalink / raw) To: LKML; +Cc: akpm, kkeil commit e295b1287f0f559f4795ae75acb793b480594a04 Author: Jeff Garzik <jeff@garzik.org> Date: Fri Oct 19 19:30:28 2007 -0400 isdn/act2000: fix major bug. clean irq handler. * invert sense of request_irq() test. otherwise we will always fail, when IRQ is available. * no need to use 'irq' function arg, its stored in a data struct already Signed-off-by: Jeff Garzik <jgarzik@redhat.com> drivers/isdn/act2000/act2000_isa.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) e295b1287f0f559f4795ae75acb793b480594a04 diff --git a/drivers/isdn/act2000/act2000_isa.c b/drivers/isdn/act2000/act2000_isa.c index 819ea85..1bd8960 100644 --- a/drivers/isdn/act2000/act2000_isa.c +++ b/drivers/isdn/act2000/act2000_isa.c @@ -61,7 +61,7 @@ act2000_isa_detect(unsigned short portbase) } static irqreturn_t -act2000_isa_interrupt(int irq, void *dev_id) +act2000_isa_interrupt(int dummy, void *dev_id) { act2000_card *card = dev_id; u_char istatus; @@ -80,7 +80,7 @@ act2000_isa_interrupt(int irq, void *dev_id) printk(KERN_WARNING "act2000: errIRQ\n"); } if (istatus) - printk(KERN_DEBUG "act2000: ?IRQ %d %02x\n", irq, istatus); + printk(KERN_DEBUG "act2000: ?IRQ %d %02x\n", card->irq, istatus); return IRQ_HANDLED; } @@ -131,6 +131,8 @@ act2000_isa_enable_irq(act2000_card * card) int act2000_isa_config_irq(act2000_card * card, short irq) { + int old_irq; + if (card->flags & ACT2000_FLAGS_IVALID) { free_irq(card->irq, card); } @@ -139,8 +141,10 @@ act2000_isa_config_irq(act2000_card * card, short irq) if (!irq) return 0; - if (!request_irq(irq, &act2000_isa_interrupt, 0, card->regname, card)) { - card->irq = irq; + old_irq = card->irq; + card->irq = irq; + if (request_irq(irq, &act2000_isa_interrupt, 0, card->regname, card)) { + card->irq = old_irq; card->flags |= ACT2000_FLAGS_IVALID; printk(KERN_WARNING "act2000: Could not request irq %d\n",irq); ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 12/17] isdn/sc: irq handler clean 2007-10-21 7:52 [PATCH 0/17] various irq handler cleanups Jeff Garzik ` (10 preceding siblings ...) 2007-10-21 7:52 ` [PATCH 11/17] isdn/act2000: fix major bug. clean irq handler Jeff Garzik @ 2007-10-21 7:52 ` Jeff Garzik 2007-10-21 7:52 ` [PATCH 13/17] netdrvr irq handler cleanups Jeff Garzik ` (4 subsequent siblings) 16 siblings, 0 replies; 24+ messages in thread From: Jeff Garzik @ 2007-10-21 7:52 UTC (permalink / raw) To: LKML; +Cc: kkeil, akpm commit ebf0fb18d5c19bb0201912850d14a9fda292ee0e Author: Jeff Garzik <jeff@garzik.org> Date: Fri Oct 19 19:31:27 2007 -0400 isdn/sc: irq handler clean * pass card number to irq handler * use card number in irq handler to avoid looping through each adapter Signed-off-by: Jeff Garzik <jgarzik@redhat.com> drivers/isdn/sc/init.c | 3 ++- drivers/isdn/sc/interrupt.c | 17 ++--------------- 2 files changed, 4 insertions(+), 16 deletions(-) ebf0fb18d5c19bb0201912850d14a9fda292ee0e diff --git a/drivers/isdn/sc/init.c b/drivers/isdn/sc/init.c index d09c854..dd0acd0 100644 --- a/drivers/isdn/sc/init.c +++ b/drivers/isdn/sc/init.c @@ -334,7 +334,8 @@ static int __init sc_init(void) */ sc_adapter[cinst]->interrupt = irq[b]; if (request_irq(sc_adapter[cinst]->interrupt, interrupt_handler, - IRQF_DISABLED, interface->id, NULL)) + IRQF_DISABLED, interface->id, + (void *)(unsigned long) cinst)) { kfree(sc_adapter[cinst]->channel); indicate_status(cinst, ISDN_STAT_UNLOAD, 0, NULL); /* Fix me */ diff --git a/drivers/isdn/sc/interrupt.c b/drivers/isdn/sc/interrupt.c index bef7963..485be8b 100644 --- a/drivers/isdn/sc/interrupt.c +++ b/drivers/isdn/sc/interrupt.c @@ -21,28 +21,15 @@ #include "card.h" #include <linux/interrupt.h> -static int get_card_from_irq(int irq) -{ - int i; - - for(i = 0 ; i < cinst ; i++) { - if(sc_adapter[i]->interrupt == irq) - return i; - } - return -1; -} - /* * */ -irqreturn_t interrupt_handler(int interrupt, void *cardptr) +irqreturn_t interrupt_handler(int dummy, void *card_inst) { RspMessage rcvmsg; int channel; - int card; - - card = get_card_from_irq(interrupt); + int card = (int)(unsigned long) card_inst; if(!IS_VALID_CARD(card)) { pr_debug("Invalid param: %d is not a valid card id\n", card); ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 13/17] netdrvr irq handler cleanups 2007-10-21 7:52 [PATCH 0/17] various irq handler cleanups Jeff Garzik ` (11 preceding siblings ...) 2007-10-21 7:52 ` [PATCH 12/17] isdn/sc: irq handler clean Jeff Garzik @ 2007-10-21 7:52 ` Jeff Garzik 2007-10-21 7:52 ` [PATCH 14/17] pcmcia/i82365: " Jeff Garzik ` (3 subsequent siblings) 16 siblings, 0 replies; 24+ messages in thread From: Jeff Garzik @ 2007-10-21 7:52 UTC (permalink / raw) To: LKML; +Cc: netdev commit a9f06dc9fb3caea2c4e9b387974c9f4956434e28 Author: Jeff Garzik <jeff@garzik.org> Date: Fri Oct 19 19:33:31 2007 -0400 [netdrvr] driver irq handler cleanups * no need to use 'irq' function arg, its already stored in a data struct * whitespace cleanups * delete tests for impossible conditions * remove pointless casts from void* Signed-off-by: Jeff Garzik <jgarzik@redhat.com> drivers/net/eexpress.c | 11 ++++++----- drivers/net/irda/smsc-ircc2.c | 17 ++++------------- drivers/net/irda/via-ircc.c | 12 +++--------- drivers/net/pcmcia/fmvj18x_cs.c | 7 +------ drivers/net/wan/sdla.c | 5 +++-- 5 files changed, 17 insertions(+), 35 deletions(-) a9f06dc9fb3caea2c4e9b387974c9f4956434e28 diff --git a/drivers/net/eexpress.c b/drivers/net/eexpress.c index 9c85e50..007de3b 100644 --- a/drivers/net/eexpress.c +++ b/drivers/net/eexpress.c @@ -456,8 +456,9 @@ static int eexp_open(struct net_device *dev) if (!dev->irq || !irqrmap[dev->irq]) return -ENXIO; - ret = request_irq(dev->irq,&eexp_irq,0,dev->name,dev); - if (ret) return ret; + ret = request_irq(dev->irq, &eexp_irq, 0, dev->name, dev); + if (ret) + return ret; if (!request_region(ioaddr, EEXP_IO_EXTENT, "EtherExpress")) { printk(KERN_WARNING "EtherExpress io port %x, is busy.\n" @@ -768,7 +769,7 @@ static void eexp_cmd_clear(struct net_device *dev) } } -static irqreturn_t eexp_irq(int irq, void *dev_info) +static irqreturn_t eexp_irq(int dummy, void *dev_info) { struct net_device *dev = dev_info; struct net_local *lp; @@ -783,7 +784,7 @@ static irqreturn_t eexp_irq(int irq, void *dev_info) old_read_ptr = inw(ioaddr+READ_PTR); old_write_ptr = inw(ioaddr+WRITE_PTR); - outb(SIRQ_dis|irqrmap[irq],ioaddr+SET_IRQ); + outb(SIRQ_dis|irqrmap[dev->irq],ioaddr+SET_IRQ); status = scb_status(dev); @@ -851,7 +852,7 @@ static irqreturn_t eexp_irq(int irq, void *dev_info) eexp_cmd_clear(dev); - outb(SIRQ_en|irqrmap[irq],ioaddr+SET_IRQ); + outb(SIRQ_en|irqrmap[dev->irq],ioaddr+SET_IRQ); #if NET_DEBUG > 6 printk("%s: leaving eexp_irq()\n", dev->name); diff --git a/drivers/net/irda/smsc-ircc2.c b/drivers/net/irda/smsc-ircc2.c index 7e7b582..1f26da7 100644 --- a/drivers/net/irda/smsc-ircc2.c +++ b/drivers/net/irda/smsc-ircc2.c @@ -1505,22 +1505,13 @@ static void smsc_ircc_sir_receive(struct smsc_ircc_cb *self) * An interrupt from the chip has arrived. Time to do some work * */ -static irqreturn_t smsc_ircc_interrupt(int irq, void *dev_id) +static irqreturn_t smsc_ircc_interrupt(int dummy, void *dev_id) { - struct net_device *dev = (struct net_device *) dev_id; - struct smsc_ircc_cb *self; + struct net_device *dev = dev_id; + struct smsc_ircc_cb *self = netdev_priv(dev); int iobase, iir, lcra, lsr; irqreturn_t ret = IRQ_NONE; - if (dev == NULL) { - printk(KERN_WARNING "%s: irq %d for unknown device.\n", - driver_name, irq); - goto irq_ret; - } - - self = netdev_priv(dev); - IRDA_ASSERT(self != NULL, return IRQ_NONE;); - /* Serialise the interrupt handler in various CPUs, stop Tx path */ spin_lock(&self->lock); @@ -1565,7 +1556,7 @@ static irqreturn_t smsc_ircc_interrupt(int irq, void *dev_id) irq_ret_unlock: spin_unlock(&self->lock); - irq_ret: + return ret; } diff --git a/drivers/net/irda/via-ircc.c b/drivers/net/irda/via-ircc.c index 126ec7c..58e1287 100644 --- a/drivers/net/irda/via-ircc.c +++ b/drivers/net/irda/via-ircc.c @@ -1346,19 +1346,13 @@ static int RxTimerHandler(struct via_ircc_cb *self, int iobase) * An interrupt from the chip has arrived. Time to do some work * */ -static irqreturn_t via_ircc_interrupt(int irq, void *dev_id) +static irqreturn_t via_ircc_interrupt(int dummy, void *dev_id) { - struct net_device *dev = (struct net_device *) dev_id; - struct via_ircc_cb *self; + struct net_device *dev = dev_id; + struct via_ircc_cb *self = dev->priv; int iobase; u8 iHostIntType, iRxIntType, iTxIntType; - if (!dev) { - IRDA_WARNING("%s: irq %d for unknown device.\n", driver_name, - irq); - return IRQ_NONE; - } - self = (struct via_ircc_cb *) dev->priv; iobase = self->io.fir_base; spin_lock(&self->lock); iHostIntType = GetHostStatus(iobase); diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c index 6284467..d251bd1 100644 --- a/drivers/net/pcmcia/fmvj18x_cs.c +++ b/drivers/net/pcmcia/fmvj18x_cs.c @@ -731,18 +731,13 @@ module_exit(exit_fmvj18x_cs); /*====================================================================*/ -static irqreturn_t fjn_interrupt(int irq, void *dev_id) +static irqreturn_t fjn_interrupt(int dummy, void *dev_id) { struct net_device *dev = dev_id; local_info_t *lp = netdev_priv(dev); kio_addr_t ioaddr; unsigned short tx_stat, rx_stat; - if (lp == NULL) { - printk(KERN_NOTICE "fjn_interrupt(): irq %d for " - "unknown device.\n", irq); - return IRQ_NONE; - } ioaddr = dev->base_addr; /* avoid multiple interrupts */ diff --git a/drivers/net/wan/sdla.c b/drivers/net/wan/sdla.c index 05df0a3..73e2f27 100644 --- a/drivers/net/wan/sdla.c +++ b/drivers/net/wan/sdla.c @@ -867,7 +867,7 @@ static void sdla_receive(struct net_device *dev) spin_unlock_irqrestore(&sdla_lock, flags); } -static irqreturn_t sdla_isr(int irq, void *dev_id) +static irqreturn_t sdla_isr(int dummy, void *dev_id) { struct net_device *dev; struct frad_local *flp; @@ -879,7 +879,8 @@ static irqreturn_t sdla_isr(int irq, void *dev_id) if (!flp->initialized) { - printk(KERN_WARNING "%s: irq %d for uninitialized device.\n", dev->name, irq); + printk(KERN_WARNING "%s: irq %d for uninitialized device.\n", + dev->name, dev->irq); return IRQ_NONE; } ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 14/17] pcmcia/i82365: irq handler cleanups 2007-10-21 7:52 [PATCH 0/17] various irq handler cleanups Jeff Garzik ` (12 preceding siblings ...) 2007-10-21 7:52 ` [PATCH 13/17] netdrvr irq handler cleanups Jeff Garzik @ 2007-10-21 7:52 ` Jeff Garzik 2007-10-21 7:52 ` [PATCH 15/17] serial, rtc/ds1374: " Jeff Garzik ` (2 subsequent siblings) 16 siblings, 0 replies; 24+ messages in thread From: Jeff Garzik @ 2007-10-21 7:52 UTC (permalink / raw) To: LKML; +Cc: linux-pcmcia commit c94109209f6d3aa2ff8c6c458552775f693ad7ee Author: Jeff Garzik <jeff@garzik.org> Date: Fri Oct 19 19:34:33 2007 -0400 pcmcia/i82365: irq handler cleanups * pass irq number to irq handler via dev_id Signed-off-by: Jeff Garzik <jgarzik@redhat.com> drivers/pcmcia/i82365.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) c94109209f6d3aa2ff8c6c458552775f693ad7ee diff --git a/drivers/pcmcia/i82365.c b/drivers/pcmcia/i82365.c index 839bb1c..330150e 100644 --- a/drivers/pcmcia/i82365.c +++ b/drivers/pcmcia/i82365.c @@ -82,7 +82,8 @@ module_param(pc_debug, int, 0644); static irqreturn_t i365_count_irq(int, void *); static inline int _check_irq(int irq, int flags) { - if (request_irq(irq, i365_count_irq, flags, "x", i365_count_irq) != 0) + if (request_irq(irq, i365_count_irq, flags, "x", + (void *)(unsigned long) irq) != 0) return -1; free_irq(irq, i365_count_irq); return 0; @@ -497,8 +498,10 @@ static u_int __init set_bridge_opts(u_short s, u_short ns) static volatile u_int irq_hits; static u_short irq_sock; -static irqreturn_t i365_count_irq(int irq, void *dev) +static irqreturn_t i365_count_irq(int dummy, void *dev_id) { + int irq = (int)(unsigned long) dev_id; + i365_get(irq_sock, I365_CSC); irq_hits++; debug(2, "-> hit on irq %d\n", irq); @@ -509,7 +512,7 @@ static u_int __init test_irq(u_short sock, int irq) { debug(2, " testing ISA irq %d\n", irq); if (request_irq(irq, i365_count_irq, IRQF_PROBE_SHARED, "scan", - i365_count_irq) != 0) + (void *)(unsigned long) irq) != 0) return 1; irq_hits = 0; irq_sock = sock; msleep(10); @@ -847,8 +850,9 @@ static void __init isa_probe(void) /*====================================================================*/ -static irqreturn_t pcic_interrupt(int irq, void *dev) +static irqreturn_t pcic_interrupt(int dummy, void *dev_id) { + int irq = (int)(unsigned long) dev_id; int i, j, csc; u_int events, active; u_long flags = 0; @@ -1293,7 +1297,8 @@ static int __init init_i82365(void) /* Set up interrupt handler(s) */ if (grab_irq != 0) - request_irq(cs_irq, pcic_interrupt, 0, "i82365", pcic_interrupt); + request_irq(cs_irq, pcic_interrupt, 0, "i82365", + (void *)(unsigned long) cs_irq); /* register sockets with the pcmcia core */ for (i = 0; i < sockets; i++) { ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 15/17] serial, rtc/ds1374: irq handler cleanups 2007-10-21 7:52 [PATCH 0/17] various irq handler cleanups Jeff Garzik ` (13 preceding siblings ...) 2007-10-21 7:52 ` [PATCH 14/17] pcmcia/i82365: " Jeff Garzik @ 2007-10-21 7:52 ` Jeff Garzik 2007-10-21 7:52 ` [PATCH 16/17] SCSI: driver " Jeff Garzik 2007-10-21 7:52 ` [PATCH 17/17] RTC interrupt handling cleanups Jeff Garzik 16 siblings, 0 replies; 24+ messages in thread From: Jeff Garzik @ 2007-10-21 7:52 UTC (permalink / raw) To: LKML; +Cc: a.zummo, linux-serial commit 9f306bb4ff39adbd2ce83491c202f5fb87baaa45 Author: Jeff Garzik <jeff@garzik.org> Date: Fri Oct 19 19:35:26 2007 -0400 serial, rtc/ds1374: irq handler cleanups * no need to use 'irq' function argument Signed-off-by: Jeff Garzik <jgarzik@redhat.com> drivers/rtc/rtc-ds1374.c | 4 ++-- drivers/serial/8250.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 9f306bb4ff39adbd2ce83491c202f5fb87baaa45 diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c index 45bda18..06017e1 100644 --- a/drivers/rtc/rtc-ds1374.c +++ b/drivers/rtc/rtc-ds1374.c @@ -257,12 +257,12 @@ out: return ret; } -static irqreturn_t ds1374_irq(int irq, void *dev_id) +static irqreturn_t ds1374_irq(int dummy, void *dev_id) { struct i2c_client *client = dev_id; struct ds1374 *ds1374 = i2c_get_clientdata(client); - disable_irq_nosync(irq); + disable_irq_nosync(client->irq); schedule_work(&ds1374->work); return IRQ_HANDLED; } diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c index 0d661ba..9c0f82e 100644 --- a/drivers/serial/8250.c +++ b/drivers/serial/8250.c @@ -1458,7 +1458,7 @@ static irqreturn_t serial8250_interrupt(int irq, void *dev_id) struct list_head *l, *end = NULL; int pass_counter = 0, handled = 0; - DEBUG_INTR("serial8250_interrupt(%d)...", irq); + DEBUG_INTR("serial8250_interrupt..."); spin_lock(&i->lock); @@ -1497,7 +1497,7 @@ static irqreturn_t serial8250_interrupt(int irq, void *dev_id) if (l == i->head && pass_counter++ > PASS_LIMIT) { /* If we hit this, we're dead. */ printk(KERN_ERR "serial8250: too much work for " - "irq%d\n", irq); + "irq%d\n", up->port.irq); break; } } while (l != end); ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 16/17] SCSI: driver irq handler cleanups 2007-10-21 7:52 [PATCH 0/17] various irq handler cleanups Jeff Garzik ` (14 preceding siblings ...) 2007-10-21 7:52 ` [PATCH 15/17] serial, rtc/ds1374: " Jeff Garzik @ 2007-10-21 7:52 ` Jeff Garzik 2007-10-21 7:52 ` [PATCH 17/17] RTC interrupt handling cleanups Jeff Garzik 16 siblings, 0 replies; 24+ messages in thread From: Jeff Garzik @ 2007-10-21 7:52 UTC (permalink / raw) To: LKML; +Cc: linux-scsi commit c0847f02496b1b8feb64637fc8609500ff69b3f2 Author: Jeff Garzik <jeff@garzik.org> Date: Fri Oct 19 19:37:20 2007 -0400 [SCSI] driver irq handler cleanups Avoid the need to use 'irq' function arg to look up data (data we already had, in every case). This permits the removal of arrays in some drivers that existed for the sole purpose of looking up data we already knew. Signed-off-by: Jeff Garzik <jgarzik@redhat.com> drivers/scsi/aha1542.c | 22 ++++++++-------------- drivers/scsi/eata.c | 11 ++++------- drivers/scsi/psi240i.c | 14 ++++---------- drivers/scsi/u14-34f.c | 9 ++++----- 4 files changed, 20 insertions(+), 36 deletions(-) c0847f02496b1b8feb64637fc8609500ff69b3f2 diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index 961a188..97c660e 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -163,8 +163,6 @@ struct aha1542_hostdata { #define HOSTDATA(host) ((struct aha1542_hostdata *) &host->hostdata) -static struct Scsi_Host *aha_host[7]; /* One for each IRQ level (9-15) */ - static DEFINE_SPINLOCK(aha1542_lock); @@ -173,8 +171,7 @@ static DEFINE_SPINLOCK(aha1542_lock); static void setup_mailboxes(int base_io, struct Scsi_Host *shpnt); static int aha1542_restart(struct Scsi_Host *shost); -static void aha1542_intr_handle(struct Scsi_Host *shost, void *dev_id); -static irqreturn_t do_aha1542_intr_handle(int irq, void *dev_id); +static void aha1542_intr_handle(struct Scsi_Host *shost); #define aha1542_intr_reset(base) outb(IRST, CONTROL(base)) @@ -414,23 +411,19 @@ fail: } /* A quick wrapper for do_aha1542_intr_handle to grab the spin lock */ -static irqreturn_t do_aha1542_intr_handle(int irq, void *dev_id) +static irqreturn_t do_aha1542_intr_handle(int dummy, void *dev_id) { unsigned long flags; - struct Scsi_Host *shost; - - shost = aha_host[irq - 9]; - if (!shost) - panic("Splunge!"); + struct Scsi_Host *shost = dev_id; spin_lock_irqsave(shost->host_lock, flags); - aha1542_intr_handle(shost, dev_id); + aha1542_intr_handle(shost); spin_unlock_irqrestore(shost->host_lock, flags); return IRQ_HANDLED; } /* A "high" level interrupt handler */ -static void aha1542_intr_handle(struct Scsi_Host *shost, void *dev_id) +static void aha1542_intr_handle(struct Scsi_Host *shost) { void (*my_done) (Scsi_Cmnd *) = NULL; int errstatus, mbi, mbo, mbistatus; @@ -1224,7 +1217,8 @@ fail: DEB(printk("aha1542_detect: enable interrupt channel %d\n", irq_level)); spin_lock_irqsave(&aha1542_lock, flags); - if (request_irq(irq_level, do_aha1542_intr_handle, 0, "aha1542", NULL)) { + if (request_irq(irq_level, do_aha1542_intr_handle, 0, + "aha1542", shpnt)) { printk(KERN_ERR "Unable to allocate IRQ for adaptec controller.\n"); spin_unlock_irqrestore(&aha1542_lock, flags); goto unregister; @@ -1241,7 +1235,7 @@ fail: enable_dma(dma_chan); } } - aha_host[irq_level - 9] = shpnt; + shpnt->this_id = scsi_id; shpnt->unique_id = base_io; shpnt->io_port = base_io; diff --git a/drivers/scsi/eata.c b/drivers/scsi/eata.c index 7ead521..302793d 100644 --- a/drivers/scsi/eata.c +++ b/drivers/scsi/eata.c @@ -2287,17 +2287,14 @@ static void flush_dev(struct scsi_device *dev, unsigned long cursec, } } -static irqreturn_t ihdlr(int irq, struct Scsi_Host *shost) +static irqreturn_t ihdlr(struct Scsi_Host *shost) { struct scsi_cmnd *SCpnt; unsigned int i, k, c, status, tstatus, reg; struct mssp *spp; struct mscp *cpp; struct hostdata *ha = (struct hostdata *)shost->hostdata; - - if (shost->irq != irq) - panic("%s: ihdlr, irq %d, shost->irq %d.\n", ha->board_name, irq, - shost->irq); + int irq = shost->irq; /* Check if this board need to be serviced */ if (!(inb(shost->io_port + REG_AUX_STATUS) & IRQ_ASSERTED)) @@ -2536,7 +2533,7 @@ static irqreturn_t ihdlr(int irq, struct Scsi_Host *shost) return IRQ_NONE; } -static irqreturn_t do_interrupt_handler(int irq, void *shap) +static irqreturn_t do_interrupt_handler(int dummy, void *shap) { struct Scsi_Host *shost; unsigned int j; @@ -2549,7 +2546,7 @@ static irqreturn_t do_interrupt_handler(int irq, void *shap) shost = sh[j]; spin_lock_irqsave(shost->host_lock, spin_flags); - ret = ihdlr(irq, shost); + ret = ihdlr(shost); spin_unlock_irqrestore(shost->host_lock, spin_flags); return ret; } diff --git a/drivers/scsi/psi240i.c b/drivers/scsi/psi240i.c index 899e89d..300ac9e 100644 --- a/drivers/scsi/psi240i.c +++ b/drivers/scsi/psi240i.c @@ -98,7 +98,6 @@ typedef struct #define HOSTDATA(host) ((PADAPTER240I)&host->hostdata) -static struct Scsi_Host *PsiHost[6] = {NULL,}; /* One for each IRQ level (10-15) */ static IDENTIFY_DATA identifyData; static SETUP ChipSetup; @@ -251,9 +250,9 @@ static ULONG DecodeError (struct Scsi_Host *pshost, UCHAR status) * Returns: TRUE if drive is not ready in time. * ****************************************************************/ -static void Irq_Handler (int irq, void *dev_id) +static void Irq_Handler (struct Scsi_Host *shost_in) { - struct Scsi_Host *shost; // Pointer to host data block + struct Scsi_Host *shost = shost_in; // Pointer to host data block PADAPTER240I padapter; // Pointer to adapter control structure USHORT *pports; // I/O port array struct scsi_cmnd *SCpnt; @@ -262,10 +261,6 @@ static void Irq_Handler (int irq, void *dev_id) DEB(printk ("\npsi240i received interrupt\n")); - shost = PsiHost[irq - 10]; - if ( !shost ) - panic ("Splunge!"); - padapter = HOSTDATA(shost); pports = padapter->ports; SCpnt = padapter->SCpnt; @@ -367,13 +362,13 @@ irqerror:; SCpnt->scsi_done (SCpnt); } -static irqreturn_t do_Irq_Handler (int irq, void *dev_id) +static irqreturn_t do_Irq_Handler (int dummy, void *dev_id) { unsigned long flags; struct Scsi_Host *dev = dev_id; spin_lock_irqsave(dev->host_lock, flags); - Irq_Handler(irq, dev_id); + Irq_Handler(dev); spin_unlock_irqrestore(dev->host_lock, flags); return IRQ_HANDLED; } @@ -583,7 +578,6 @@ static int Psi240i_Detect (struct scsi_host_template *tpnt) if(pshost == NULL) goto host_init_failure; - PsiHost[chipConfig.irq - 10] = pshost; pshost->unique_id = port; pshost->io_port = port; pshost->n_io_port = 16; /* Number of bytes of I/O space used */ diff --git a/drivers/scsi/u14-34f.c b/drivers/scsi/u14-34f.c index 7edd6ce..a2d704b 100644 --- a/drivers/scsi/u14-34f.c +++ b/drivers/scsi/u14-34f.c @@ -1716,13 +1716,12 @@ static void flush_dev(struct scsi_device *dev, unsigned long cursec, unsigned in } -static irqreturn_t ihdlr(int irq, unsigned int j) { +static irqreturn_t ihdlr(unsigned int j) +{ struct scsi_cmnd *SCpnt; unsigned int i, k, c, status, tstatus, reg, ret; struct mscp *spp, *cpp; - - if (sh[j]->irq != irq) - panic("%s: ihdlr, irq %d, sh[j]->irq %d.\n", BN(j), irq, sh[j]->irq); + int irq = sh[j]->irq; /* Check if this board need to be serviced */ if (!((reg = inb(sh[j]->io_port + REG_SYS_INTR)) & IRQ_ASSERTED)) goto none; @@ -1936,7 +1935,7 @@ static irqreturn_t do_interrupt_handler(int irq, void *shap) { if ((j = (unsigned int)((char *)shap - sha)) >= num_boards) return IRQ_NONE; spin_lock_irqsave(sh[j]->host_lock, spin_flags); - ret = ihdlr(irq, j); + ret = ihdlr(j); spin_unlock_irqrestore(sh[j]->host_lock, spin_flags); return ret; } ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 17/17] RTC interrupt handling cleanups 2007-10-21 7:52 [PATCH 0/17] various irq handler cleanups Jeff Garzik ` (15 preceding siblings ...) 2007-10-21 7:52 ` [PATCH 16/17] SCSI: driver " Jeff Garzik @ 2007-10-21 7:52 ` Jeff Garzik 2007-10-21 16:40 ` Mike Frysinger 16 siblings, 1 reply; 24+ messages in thread From: Jeff Garzik @ 2007-10-21 7:52 UTC (permalink / raw) To: LKML; +Cc: a.zummo commit f94d41db30d6430bc6d3e53602258d3933f93103 Author: Jeff Garzik <jeff@garzik.org> Date: Sun Oct 21 01:51:50 2007 -0400 RTC interrupt handling cleanups arm/mach-integrator/time: arm_rtc_interrupt() never uses its arguments, so pass NULL to make this explicit and potentially reduce future confusion. hpet.c and rtc.c: pass rtc_int_flag through the standard data-passing mechanism, dev_id (2nd arg). rtc-at32ap700x, rtc-m48t59.c: delete pointless cast from void* rtc-bfin: calling spin_lock_irq() in interrupt handler marked IRQF_DISABLED is unwise. Use safer spin_lock_irqsave() instead. Signed-off-by: Jeff Garzik <jgarzik@redhat.com> arch/arm/mach-integrator/time.c | 2 +- arch/x86/kernel/hpet.c | 4 ++-- drivers/char/rtc.c | 7 ++++--- drivers/rtc/rtc-at32ap700x.c | 2 +- drivers/rtc/rtc-bfin.c | 5 +++-- drivers/rtc/rtc-m48t59.c | 2 +- 6 files changed, 12 insertions(+), 10 deletions(-) f94d41db30d6430bc6d3e53602258d3933f93103 diff --git a/arch/arm/mach-integrator/time.c b/arch/arm/mach-integrator/time.c index 5278f58..5235f64 100644 --- a/arch/arm/mach-integrator/time.c +++ b/arch/arm/mach-integrator/time.c @@ -125,7 +125,7 @@ static int rtc_probe(struct amba_device *dev, void *id) xtime.tv_sec = __raw_readl(rtc_base + RTC_DR); ret = request_irq(dev->irq[0], arm_rtc_interrupt, IRQF_DISABLED, - "rtc-pl030", dev); + "rtc-pl030", NULL); if (ret) goto map_out; diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c index 53303f2..7c07653 100644 --- a/arch/x86/kernel/hpet.c +++ b/arch/x86/kernel/hpet.c @@ -621,7 +621,7 @@ static void hpet_rtc_timer_reinit(void) } } -irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id) +irqreturn_t hpet_rtc_interrupt(int dummy, void *dev_id) { struct rtc_time curr_time; unsigned long rtc_int_flag = 0; @@ -651,7 +651,7 @@ irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id) if (rtc_int_flag) { rtc_int_flag |= (RTC_IRQF | (RTC_NUM_INTS << 8)); - rtc_interrupt(rtc_int_flag, dev_id); + rtc_interrupt(-1, (void *) rtc_int_flag); } return IRQ_HANDLED; } diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c index ec6b65e..533328b 100644 --- a/drivers/char/rtc.c +++ b/drivers/char/rtc.c @@ -233,7 +233,7 @@ static inline unsigned char rtc_is_updating(void) * (See ./arch/XXXX/kernel/time.c for the set_rtc_mmss() function.) */ -irqreturn_t rtc_interrupt(int irq, void *dev_id) +irqreturn_t rtc_interrupt(int dummy, void *dev_id) { /* * Can be an alarm interrupt, update complete interrupt, @@ -246,12 +246,13 @@ irqreturn_t rtc_interrupt(int irq, void *dev_id) rtc_irq_data += 0x100; rtc_irq_data &= ~0xff; if (is_hpet_enabled()) { + unsigned long val = (unsigned long) dev_id; /* * In this case it is HPET RTC interrupt handler * calling us, with the interrupt information - * passed as arg1, instead of irq. + * passed as arg2 (dev_id) */ - rtc_irq_data |= (unsigned long)irq & 0xF0; + rtc_irq_data |= val & 0xF0; } else { rtc_irq_data |= (CMOS_READ(RTC_INTR_FLAGS) & 0xF0); } diff --git a/drivers/rtc/rtc-at32ap700x.c b/drivers/rtc/rtc-at32ap700x.c index 2999214..2c1890f 100644 --- a/drivers/rtc/rtc-at32ap700x.c +++ b/drivers/rtc/rtc-at32ap700x.c @@ -167,7 +167,7 @@ static int at32_rtc_ioctl(struct device *dev, unsigned int cmd, static irqreturn_t at32_rtc_interrupt(int irq, void *dev_id) { - struct rtc_at32ap700x *rtc = (struct rtc_at32ap700x *)dev_id; + struct rtc_at32ap700x *rtc = dev_id; unsigned long isr = rtc_readl(rtc, ISR); unsigned long events = 0; int ret = IRQ_NONE; diff --git a/drivers/rtc/rtc-bfin.c b/drivers/rtc/rtc-bfin.c index 1aa709d..5afd24c 100644 --- a/drivers/rtc/rtc-bfin.c +++ b/drivers/rtc/rtc-bfin.c @@ -143,10 +143,11 @@ static irqreturn_t bfin_rtc_interrupt(int irq, void *dev_id) struct bfin_rtc *rtc = platform_get_drvdata(pdev); unsigned long events = 0; u16 rtc_istat; + unsigned long flags; stampit(); - spin_lock_irq(&rtc->lock); + spin_lock_irqsave(&rtc->lock, flags); rtc_istat = bfin_read_RTC_ISTAT(); @@ -168,7 +169,7 @@ static irqreturn_t bfin_rtc_interrupt(int irq, void *dev_id) rtc_update_irq(rtc->rtc_dev, 1, events); - spin_unlock_irq(&rtc->lock); + spin_unlock_irqrestore(&rtc->lock, flags); return IRQ_HANDLED; } diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c index bf60d35..934405d 100644 --- a/drivers/rtc/rtc-m48t59.c +++ b/drivers/rtc/rtc-m48t59.c @@ -283,7 +283,7 @@ static int m48t59_rtc_proc(struct device *dev, struct seq_file *seq) */ static irqreturn_t m48t59_rtc_interrupt(int irq, void *dev_id) { - struct device *dev = (struct device *)dev_id; + struct device *dev = dev_id; struct platform_device *pdev = to_platform_device(dev); struct m48t59_plat_data *pdata = pdev->dev.platform_data; struct m48t59_private *m48t59 = platform_get_drvdata(pdev); ^ permalink raw reply related [flat|nested] 24+ messages in thread
* Re: [PATCH 17/17] RTC interrupt handling cleanups 2007-10-21 7:52 ` [PATCH 17/17] RTC interrupt handling cleanups Jeff Garzik @ 2007-10-21 16:40 ` Mike Frysinger 0 siblings, 0 replies; 24+ messages in thread From: Mike Frysinger @ 2007-10-21 16:40 UTC (permalink / raw) To: Jeff Garzik; +Cc: LKML, a.zummo On 10/21/07, Jeff Garzik <jeff@garzik.org> wrote: > commit f94d41db30d6430bc6d3e53602258d3933f93103 > Author: Jeff Garzik <jeff@garzik.org> > Date: Sun Oct 21 01:51:50 2007 -0400 > > RTC interrupt handling cleanups > > rtc-bfin: calling spin_lock_irq() in interrupt handler marked > IRQF_DISABLED is unwise. Use safer spin_lock_irqsave() instead. Signed-off-by: Mike Frysinger <vapier@gentoo.org> thanks :) -mike ^ permalink raw reply [flat|nested] 24+ messages in thread
end of thread, other threads:[~2007-10-30 12:36 UTC | newest]
Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-21 7:52 [PATCH 0/17] various irq handler cleanups Jeff Garzik
2007-10-21 7:52 ` [PATCH 1/17] " Jeff Garzik
2007-10-21 7:52 ` [PATCH 2/17] drivers/char/ip2: split out irq core logic into separate function Jeff Garzik
2007-10-21 7:52 ` [PATCH 3/17] drivers/char/ip2: separate polling and irq-driven work entry points Jeff Garzik
2007-10-21 7:52 ` [PATCH 4/17] char/pcmcia/synclink_cs: trim trailing whitespace Jeff Garzik
2007-10-21 7:52 ` [PATCH 5/17] drivers/char/pcmcia/synclink_cs.c: irq handler cleanups Jeff Garzik
2007-10-21 7:52 ` [PATCH 6/17] drivers/char/riscom8: " Jeff Garzik
2007-10-21 9:01 ` Jiri Slaby
2007-10-21 9:06 ` Jeff Garzik
2007-10-21 7:52 ` [PATCH 7/17] drivers/char/{rio,specialix,sx}: " Jeff Garzik
2007-10-21 7:52 ` [PATCH 8/17] arch/x86/kernel/vm86_32.c: irq handler cleanup Jeff Garzik
2007-10-21 9:21 ` Thomas Gleixner
2007-10-21 7:52 ` [PATCH 9/17] drivers/char/{synclink,tpm}: irq handler cleanups Jeff Garzik
2007-10-21 7:52 ` [PATCH 10/17] drivers/input/serio/i8042.c: irq handler clean Jeff Garzik
2007-10-21 17:57 ` Dmitry Torokhov
2007-10-30 12:36 ` Jeff Garzik
2007-10-21 7:52 ` [PATCH 11/17] isdn/act2000: fix major bug. clean irq handler Jeff Garzik
2007-10-21 7:52 ` [PATCH 12/17] isdn/sc: irq handler clean Jeff Garzik
2007-10-21 7:52 ` [PATCH 13/17] netdrvr irq handler cleanups Jeff Garzik
2007-10-21 7:52 ` [PATCH 14/17] pcmcia/i82365: " Jeff Garzik
2007-10-21 7:52 ` [PATCH 15/17] serial, rtc/ds1374: " Jeff Garzik
2007-10-21 7:52 ` [PATCH 16/17] SCSI: driver " Jeff Garzik
2007-10-21 7:52 ` [PATCH 17/17] RTC interrupt handling cleanups Jeff Garzik
2007-10-21 16:40 ` Mike Frysinger
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox