From: Jiri Slaby <jirislaby@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: <linux-kernel@vger.kernel.org>
Subject: [PATCH 17/21] Char: cyclades, conditions cleanup
Date: Sun, 29 Apr 2007 23:04:45 +0200 (CEST) [thread overview]
Message-ID: <49901838060939918@wsc.cz> (raw)
In-Reply-To: <1726067771982725064@wsc.cz>
cyclades, conditions cleanup
- 0 is not NULL
- use unlikely to hit the icache in isr more likely
- remove or comment empty if/else paths
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
---
commit fb2b658e64e69e56c52b1242b9957e9d96f28ade
tree b7f1629c12b53a56bd5b3149ceba3830dbfc028f
parent c2e132ebb19f9f8b3d4aee5cd4f755cd7588d49f
author Jiri Slaby <jirislaby@gmail.com> Fri, 27 Apr 2007 18:03:37 +0200
committer Jiri Slaby <jirislaby@gmail.com> Sat, 28 Apr 2007 23:48:36 +0200
drivers/char/cyclades.c | 60 ++++++++++++++++-------------------------------
1 files changed, 21 insertions(+), 39 deletions(-)
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index 6e5fca9..620e17c 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -1043,7 +1043,7 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
cy_writeb(base_addr + (CyCAR << index), save_xir);
/* if there is nowhere to put the data, discard it */
- if (info->tty == 0) {
+ if (info->tty == NULL) {
j = (readb(base_addr + (CyRIVR << index)) &
CyIVRMask);
if (j == CyIVRRxEx) { /* exception */
@@ -1214,7 +1214,7 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
goto txend;
}
info = &cy_port[i];
- if (info->tty == 0) {
+ if (info->tty == NULL) {
cy_writeb(base_addr + (CySRER << index),
readb(base_addr + (CySRER << index)) &
~CyTxRdy);
@@ -1263,7 +1263,7 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
}
goto txdone;
}
- if (info->xmit_buf == 0) {
+ if (info->xmit_buf == NULL) {
cy_writeb(base_addr + (CySRER << index),
readb(base_addr + (CySRER << index)) &
~CyTxRdy);
@@ -1304,7 +1304,6 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
0);
info->icount.tx++;
char_count--;
- } else {
}
}
}
@@ -1333,9 +1332,7 @@ txend:
mdm_change = readb(base_addr + (CyMISR << index));
mdm_status = readb(base_addr + (CyMSVR1 << index));
- if (info->tty == 0) { /* no place for data, ignore it */
- ;
- } else {
+ if (info->tty) {
if (mdm_change & CyANY_DELTA) {
/* For statistics only */
if (mdm_change & CyDCD)
@@ -1389,10 +1386,10 @@ txend:
}
}
}
- if (mdm_change & CyDSR) {
+/* if (mdm_change & CyDSR) {
}
if (mdm_change & CyRI) {
- }
+ }*/
}
/* end of service */
cy_writeb(base_addr + (CyMIR << index), (save_xir & 0x3f));
@@ -1408,14 +1405,14 @@ txend:
static irqreturn_t cyy_interrupt(int irq, void *dev_id)
{
int status;
- struct cyclades_card *cinfo;
+ struct cyclades_card *cinfo = dev_id;
void __iomem *base_addr, *card_base_addr;
int chip;
int index;
int too_many;
int had_work;
- if ((cinfo = (struct cyclades_card *)dev_id) == 0) {
+ if (unlikely(cinfo == NULL)) {
#ifdef CY_DEBUG_INTERRUPTS
printk(KERN_DEBUG "cyy_interrupt: spurious interrupt %d\n",irq);
#endif
@@ -1564,7 +1561,7 @@ cyz_handle_rx(struct cyclades_port *info, struct CH_CTRL __iomem *ch_ctrl,
info->mon.char_max = char_count;
info->mon.char_last = char_count;
#endif
- if (tty == 0) {
+ if (tty == NULL) {
/* flush received characters */
new_rx_get = (new_rx_get + char_count) &
(rx_bufsize - 1);
@@ -1650,9 +1647,8 @@ cyz_handle_tx(struct cyclades_port *info, struct CH_CTRL __iomem *ch_ctrl,
if (char_count) {
- if (tty == 0) {
+ if (tty == NULL)
goto ztxdone;
- }
if (info->x_char) { /* send special char */
data = info->x_char;
@@ -1731,9 +1727,9 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo)
special_count = 0;
delta_count = 0;
info = &cy_port[channel + cinfo->first_line];
- if ((tty = info->tty) == 0) {
+ if ((tty = info->tty) == NULL)
continue;
- }
+
ch_ctrl = &(zfw_ctrl->ch_ctrl[channel]);
buf_ctrl = &(zfw_ctrl->buf_ctrl[channel]);
@@ -1822,16 +1818,16 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo)
#ifdef CONFIG_CYZ_INTR
static irqreturn_t cyz_interrupt(int irq, void *dev_id)
{
- struct cyclades_card *cinfo;
+ struct cyclades_card *cinfo = dev_id;
- if ((cinfo = (struct cyclades_card *)dev_id) == 0) {
+ 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 (!ISZLOADED(*cinfo)) {
+ if (unlikely(!ISZLOADED(*cinfo))) {
#ifdef CY_DEBUG_INTERRUPTS
printk(KERN_DEBUG "cyz_interrupt: board not yet loaded "
"(IRQ%d).\n", irq);
@@ -2661,8 +2657,6 @@ static void cy_wait_until_sent(struct tty_struct *tty, int timeout)
timeout))
break;
}
- } else {
- /* Nothing to do! */
}
/* Run one more char cycle */
msleep_interruptible(jiffies_to_msecs(char_time * 5));
@@ -3857,8 +3851,6 @@ static int set_threshold(struct cyclades_port *info, unsigned long value)
cy_writeb(base_addr + (CyCOR3 << index), info->cor3);
cyy_issue_cmd(base_addr, CyCOR_CHANGE | CyCOR3ch, index);
spin_unlock_irqrestore(&card->card_lock, flags);
- } else {
- /* Nothing to do! */
}
return 0;
} /* set_threshold */
@@ -3881,10 +3873,8 @@ get_threshold(struct cyclades_port *info, unsigned long __user * value)
tmp = readb(base_addr + (CyCOR3 << index)) & CyREC_FIFO;
return put_user(tmp, value);
- } else {
- /* Nothing to do! */
- return 0;
}
+ return 0;
} /* get_threshold */
static int
@@ -3918,8 +3908,6 @@ static int set_timeout(struct cyclades_port *info, unsigned long value)
spin_lock_irqsave(&card->card_lock, flags);
cy_writeb(base_addr + (CyRTPR << index), value & 0xff);
spin_unlock_irqrestore(&card->card_lock, flags);
- } else {
- /* Nothing to do! */
}
return 0;
} /* set_timeout */
@@ -3941,10 +3929,8 @@ static int get_timeout(struct cyclades_port *info, unsigned long __user * value)
tmp = readb(base_addr + (CyRTPR << index));
return put_user(tmp, value);
- } else {
- /* Nothing to do! */
- return 0;
}
+ return 0;
} /* get_timeout */
static int set_default_timeout(struct cyclades_port *info, unsigned long value)
@@ -4348,8 +4334,6 @@ static void cy_stop(struct tty_struct *tty)
cy_writeb(base_addr + (CySRER << index),
readb(base_addr + (CySRER << index)) & ~CyTxRdy);
spin_unlock_irqrestore(&cinfo->card_lock, flags);
- } else {
- /* Nothing to do! */
}
} /* cy_stop */
@@ -4381,8 +4365,6 @@ static void cy_start(struct tty_struct *tty)
cy_writeb(base_addr + (CySRER << index),
readb(base_addr + (CySRER << index)) | CyTxRdy);
spin_unlock_irqrestore(&cinfo->card_lock, flags);
- } else {
- /* Nothing to do! */
}
} /* cy_start */
@@ -4694,7 +4676,7 @@ static int __init cy_detect_isa(void)
}
/* fill the next cy_card structure available */
for (j = 0; j < NR_CARDS; j++) {
- if (cy_card[j].base_addr == 0)
+ if (cy_card[j].base_addr == NULL)
break;
}
if (j == NR_CARDS) { /* no more cy_cards available */
@@ -4779,7 +4761,7 @@ static int __devinit cy_init_Ze(struct RUNTIME_9060 __iomem *cy_pci_addr0,
/* fill the next cy_card structure available */
for (j = 0; j < NR_CARDS; j++) {
- if (cy_card[j].base_addr == 0)
+ if (cy_card[j].base_addr == NULL)
break;
}
if (j == NR_CARDS) { /* no more cy_cards available */
@@ -4889,7 +4871,7 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev,
}
/* fill the next cy_card structure available */
for (j = 0; j < NR_CARDS; j++) {
- if (cy_card[j].base_addr == 0)
+ if (cy_card[j].base_addr == NULL)
break;
}
if (j == NR_CARDS) { /* no more cy_cards available */
@@ -5039,7 +5021,7 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev,
/* fill the next cy_card structure available */
for (j = 0; j < NR_CARDS; j++) {
- if (cy_card[j].base_addr == 0)
+ if (cy_card[j].base_addr == NULL)
break;
}
if (j == NR_CARDS) { /* no more cy_cards available */
next prev parent reply other threads:[~2007-04-29 21:05 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-29 20:53 [PATCH 1/21] Char: cyclades, use IS_CYC_Z macro Jiri Slaby
2007-04-29 20:54 ` [PATCH 2/21] Char: cyclades, switch to pci probing Jiri Slaby
2007-04-29 20:54 ` [PATCH 3/21] Char: cyclades, depends on PCI or ISA Jiri Slaby
2007-04-29 20:55 ` [PATCH 4/21] Char: cyclades, unexport struct cyclades_card Jiri Slaby
2007-04-29 20:56 ` [PATCH 5/21] Char: cyclades, remove useless fileds from cyclades_card Jiri Slaby
2007-04-29 20:57 ` [PATCH 6/21] Char: cyclades, irq is int Jiri Slaby
2007-04-29 20:57 ` [PATCH 7/21] Char: cyclades, printk cleanups Jiri Slaby
2007-04-29 20:58 ` [PATCH 8/21] Char: cyclades, mark cyy_init_card as __devinit, not __init Jiri Slaby
2007-04-29 20:59 ` [PATCH 9/21] Char: cyclades, simplify variables initialization Jiri Slaby
2007-04-29 20:59 ` [PATCH 10/21] Char: cyclades, get rid of phys addresses Jiri Slaby
2007-04-29 21:00 ` [PATCH 11/21] Char: cyclades, make info->card a pointer Jiri Slaby
2007-04-29 21:01 ` [PATCH 12/21] Char: cyclades, remove sleep_on Jiri Slaby
2007-04-29 21:01 ` [PATCH 13/21] Char: cyclades, fix blockmove Jiri Slaby
2007-04-29 21:02 ` [PATCH 14/21] Char: cyclades, timers cleanup Jiri Slaby
2007-04-29 21:03 ` [PATCH 15/21] Char: cyclades, remove unused timestamps Jiri Slaby
2007-04-29 21:03 ` [PATCH 16/21] Char: cyclades, remove locking macros Jiri Slaby
2007-04-29 21:04 ` Jiri Slaby [this message]
2007-04-29 21:05 ` [PATCH 18/21] Char: cyclades, fix tty device unregister Jiri Slaby
2007-04-29 21:06 ` [PATCH 19/21] Char: cyclades, dynamic ports Jiri Slaby
2007-04-29 21:06 ` [PATCH 20/21] Char: cyclades, probe cleanup Jiri Slaby
2007-04-29 21:07 ` [PATCH 21/21] Char: cyclades, copyright and version changes Jiri Slaby
2007-05-02 15:57 ` [PATCH 1/21] Char: cyclades, use IS_CYC_Z macro Jiri Slaby
2007-05-02 19:47 ` Andrew Morton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49901838060939918@wsc.cz \
--to=jirislaby@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.