All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Slaby <jirislaby@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: <linux-kernel@vger.kernel.org>
Subject: [PATCH 5/11] Char: cyclades, move card entries init into function
Date: Wed, 18 Apr 2007 12:05:17 +0200 (CEST)	[thread overview]
Message-ID: <3210010229950231391@karneval.cz> (raw)
In-Reply-To: <2428225437641930190@karneval.cz>

cyclades, move card entries init into function

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>

---
commit de8850dd6c04762688b19609b13cb16a1e6399a9
tree 288721fb454613ce1d3bdd6ec10ca6e01c3059c7
parent 07df3f0fcb1cad6a274d5b7b32d65df54c3f4fb4
author Jiri Slaby <jirislaby@gmail.com> Mon, 02 Apr 2007 12:07:20 +0200
committer Jiri Slaby <jirislaby@gmail.com> Tue, 10 Apr 2007 10:48:02 +0200

 drivers/char/cyclades.c |  311 ++++++++++++++++++++++++-----------------------
 1 files changed, 156 insertions(+), 155 deletions(-)

diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index adf993a..fe967be 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -4503,6 +4503,159 @@ static void cy_hangup(struct tty_struct *tty)
  * ---------------------------------------------------------------------
  */
 
+static void __devinit cy_init_card(struct cyclades_card *cinfo,
+		const unsigned int board)
+{
+	struct cyclades_port *info;
+	u32 mailbox;
+	unsigned int nports;
+	unsigned short chip_number;
+	int index, port;
+
+	if (cinfo->num_chips == -1) {	/* Cyclades-Z */
+		mailbox = readl(&((struct RUNTIME_9060 __iomem *)
+				     cinfo->ctl_addr)->mail_box_0);
+		nports = (mailbox == ZE_V1) ? ZE_V1_NPORTS : 8;
+		cinfo->intr_enabled = 0;
+		cinfo->nports = 0;	/* Will be correctly set later, after 
+					   Z FW is loaded */
+		spin_lock_init(&cinfo->card_lock);
+		for (port = cinfo->first_line;
+		     port < cinfo->first_line + nports; port++) {
+			info = &cy_port[port];
+			info->magic = CYCLADES_MAGIC;
+			info->type = PORT_STARTECH;
+			info->card = board;
+			info->line = port;
+			info->chip_rev = 0;
+			info->flags = STD_COM_FLAGS;
+			info->tty = NULL;
+			if (mailbox == ZO_V1)
+				info->xmit_fifo_size = CYZ_FIFO_SIZE;
+			else
+				info->xmit_fifo_size =
+				    4 * CYZ_FIFO_SIZE;
+			info->cor1 = 0;
+			info->cor2 = 0;
+			info->cor3 = 0;
+			info->cor4 = 0;
+			info->cor5 = 0;
+			info->tbpr = 0;
+			info->tco = 0;
+			info->rbpr = 0;
+			info->rco = 0;
+			info->custom_divisor = 0;
+			info->close_delay = 5 * HZ / 10;
+			info->closing_wait = CLOSING_WAIT_DELAY;
+			info->icount.cts = info->icount.dsr =
+			    info->icount.rng = info->icount.dcd = 0;
+			info->icount.rx = info->icount.tx = 0;
+			info->icount.frame = info->icount.parity = 0;
+			info->icount.overrun = info->icount.brk = 0;
+			info->x_char = 0;
+			info->event = 0;
+			info->count = 0;
+			info->blocked_open = 0;
+			info->default_threshold = 0;
+			info->default_timeout = 0;
+			INIT_WORK(&info->tqueue, do_softint);
+			init_waitqueue_head(&info->open_wait);
+			init_waitqueue_head(&info->close_wait);
+			init_waitqueue_head(&info->shutdown_wait);
+			init_waitqueue_head(&info->delta_msr_wait);
+			/* info->session */
+			/* info->pgrp */
+			info->read_status_mask = 0;
+			/* info->timeout */
+			/* Bentson's vars */
+			info->jiffies[0] = 0;
+			info->jiffies[1] = 0;
+			info->jiffies[2] = 0;
+			info->rflush_count = 0;
+#ifdef CONFIG_CYZ_INTR
+			init_timer(&cyz_rx_full_timer[port]);
+			cyz_rx_full_timer[port].function = NULL;
+#endif
+		}
+#ifndef CONFIG_CYZ_INTR
+		if (!timer_pending(&cyz_timerlist)) {
+			mod_timer(&cyz_timerlist, jiffies + 1);
+#ifdef CY_PCI_DEBUG
+			printk("Cyclades-Z polling initialized\n");
+#endif
+		}
+#endif				/* CONFIG_CYZ_INTR */
+
+	} else {	/* Cyclom-Y of some kind */
+		index = cinfo->bus_index;
+		spin_lock_init(&cinfo->card_lock);
+		cinfo->nports = CyPORTS_PER_CHIP * cinfo->num_chips;
+		for (port = cinfo->first_line;
+		     port < cinfo->first_line + cinfo->nports; port++) {
+			info = &cy_port[port];
+			info->magic = CYCLADES_MAGIC;
+			info->type = PORT_CIRRUS;
+			info->card = board;
+			info->line = port;
+			info->flags = STD_COM_FLAGS;
+			info->tty = NULL;
+			info->xmit_fifo_size = CyMAX_CHAR_FIFO;
+			info->cor1 =
+			    CyPARITY_NONE | Cy_1_STOP | Cy_8_BITS;
+			info->cor2 = CyETC;
+			info->cor3 = 0x08;	/* _very_ small rcv threshold */
+			info->cor4 = 0;
+			info->cor5 = 0;
+			info->custom_divisor = 0;
+			info->close_delay = 5 * HZ / 10;
+			info->closing_wait = CLOSING_WAIT_DELAY;
+			info->icount.cts = info->icount.dsr =
+			    info->icount.rng = info->icount.dcd = 0;
+			info->icount.rx = info->icount.tx = 0;
+			info->icount.frame = info->icount.parity = 0;
+			info->icount.overrun = info->icount.brk = 0;
+			chip_number = (port - cinfo->first_line) / 4;
+			if ((info->chip_rev =
+			     readb(cinfo->base_addr +
+				      (cy_chip_offset[chip_number] <<
+				       index) + (CyGFRCR << index))) >=
+			    CD1400_REV_J) {
+				/* It is a CD1400 rev. J or later */
+				info->tbpr = baud_bpr_60[13];	/* Tx BPR */
+				info->tco = baud_co_60[13];	/* Tx CO */
+				info->rbpr = baud_bpr_60[13];	/* Rx BPR */
+				info->rco = baud_co_60[13];	/* Rx CO */
+				info->rflow = 0;
+				info->rtsdtr_inv = 1;
+			} else {
+				info->tbpr = baud_bpr_25[13];	/* Tx BPR */
+				info->tco = baud_co_25[13];	/* Tx CO */
+				info->rbpr = baud_bpr_25[13];	/* Rx BPR */
+				info->rco = baud_co_25[13];	/* Rx CO */
+				info->rflow = 0;
+				info->rtsdtr_inv = 0;
+			}
+			info->x_char = 0;
+			info->event = 0;
+			info->count = 0;
+			info->blocked_open = 0;
+			info->default_threshold = 0;
+			info->default_timeout = 0;
+			INIT_WORK(&info->tqueue, do_softint);
+			init_waitqueue_head(&info->open_wait);
+			init_waitqueue_head(&info->close_wait);
+			init_waitqueue_head(&info->shutdown_wait);
+			init_waitqueue_head(&info->delta_msr_wait);
+			/* info->session */
+			/* info->pgrp */
+			info->read_status_mask =
+			    CyTIMEOUT | CySPECHAR | CyBREAK
+			    | CyPARITY | CyFRAME | CyOVERRUN;
+			/* info->timeout */
+		}
+	}
+}
+
 /* initialize chips on Cyclom-Y card -- return number of valid
    chips (which is number of ports/4) */
 static unsigned short __init
@@ -5300,13 +5453,7 @@ static const struct tty_operations cy_ops = {
 
 static int __init cy_init(void)
 {
-	struct cyclades_port *info;
-	struct cyclades_card *cinfo;
-	int number_z_boards = 0;
-	int board, port, i, index;
-	unsigned long mailbox;
-	unsigned short chip_number;
-	int nports;
+	unsigned int i;
 
 	cy_serial_driver = alloc_tty_driver(NR_PORTS);
 	if (!cy_serial_driver)
@@ -5369,154 +5516,8 @@ static int __init cy_init(void)
 	}
 
 	/* initialize per-port data structures for each valid board found */
-	for (board = 0; board < cy_nboard; board++) {
-		cinfo = &cy_card[board];
-		if (cinfo->num_chips == -1) {	/* Cyclades-Z */
-			number_z_boards++;
-			mailbox = readl(&((struct RUNTIME_9060 __iomem *)
-					     cy_card[board].ctl_addr)->
-					   mail_box_0);
-			nports = (mailbox == ZE_V1) ? ZE_V1_NPORTS : 8;
-			cinfo->intr_enabled = 0;
-			cinfo->nports = 0;	/* Will be correctly set later, after 
-						   Z FW is loaded */
-			spin_lock_init(&cinfo->card_lock);
-			for (port = cinfo->first_line;
-			     port < cinfo->first_line + nports; port++) {
-				info = &cy_port[port];
-				info->magic = CYCLADES_MAGIC;
-				info->type = PORT_STARTECH;
-				info->card = board;
-				info->line = port;
-				info->chip_rev = 0;
-				info->flags = STD_COM_FLAGS;
-				info->tty = NULL;
-				if (mailbox == ZO_V1)
-					info->xmit_fifo_size = CYZ_FIFO_SIZE;
-				else
-					info->xmit_fifo_size =
-					    4 * CYZ_FIFO_SIZE;
-				info->cor1 = 0;
-				info->cor2 = 0;
-				info->cor3 = 0;
-				info->cor4 = 0;
-				info->cor5 = 0;
-				info->tbpr = 0;
-				info->tco = 0;
-				info->rbpr = 0;
-				info->rco = 0;
-				info->custom_divisor = 0;
-				info->close_delay = 5 * HZ / 10;
-				info->closing_wait = CLOSING_WAIT_DELAY;
-				info->icount.cts = info->icount.dsr =
-				    info->icount.rng = info->icount.dcd = 0;
-				info->icount.rx = info->icount.tx = 0;
-				info->icount.frame = info->icount.parity = 0;
-				info->icount.overrun = info->icount.brk = 0;
-				info->x_char = 0;
-				info->event = 0;
-				info->count = 0;
-				info->blocked_open = 0;
-				info->default_threshold = 0;
-				info->default_timeout = 0;
-				INIT_WORK(&info->tqueue, do_softint);
-				init_waitqueue_head(&info->open_wait);
-				init_waitqueue_head(&info->close_wait);
-				init_waitqueue_head(&info->shutdown_wait);
-				init_waitqueue_head(&info->delta_msr_wait);
-				/* info->session */
-				/* info->pgrp */
-				info->read_status_mask = 0;
-				/* info->timeout */
-				/* Bentson's vars */
-				info->jiffies[0] = 0;
-				info->jiffies[1] = 0;
-				info->jiffies[2] = 0;
-				info->rflush_count = 0;
-#ifdef CONFIG_CYZ_INTR
-				init_timer(&cyz_rx_full_timer[port]);
-				cyz_rx_full_timer[port].function = NULL;
-#endif
-			}
-			continue;
-		} else {	/* Cyclom-Y of some kind */
-			index = cinfo->bus_index;
-			spin_lock_init(&cinfo->card_lock);
-			cinfo->nports = CyPORTS_PER_CHIP * cinfo->num_chips;
-			for (port = cinfo->first_line;
-			     port < cinfo->first_line + cinfo->nports; port++) {
-				info = &cy_port[port];
-				info->magic = CYCLADES_MAGIC;
-				info->type = PORT_CIRRUS;
-				info->card = board;
-				info->line = port;
-				info->flags = STD_COM_FLAGS;
-				info->tty = NULL;
-				info->xmit_fifo_size = CyMAX_CHAR_FIFO;
-				info->cor1 =
-				    CyPARITY_NONE | Cy_1_STOP | Cy_8_BITS;
-				info->cor2 = CyETC;
-				info->cor3 = 0x08;	/* _very_ small rcv threshold */
-				info->cor4 = 0;
-				info->cor5 = 0;
-				info->custom_divisor = 0;
-				info->close_delay = 5 * HZ / 10;
-				info->closing_wait = CLOSING_WAIT_DELAY;
-				info->icount.cts = info->icount.dsr =
-				    info->icount.rng = info->icount.dcd = 0;
-				info->icount.rx = info->icount.tx = 0;
-				info->icount.frame = info->icount.parity = 0;
-				info->icount.overrun = info->icount.brk = 0;
-				chip_number = (port - cinfo->first_line) / 4;
-				if ((info->chip_rev =
-				     readb(cinfo->base_addr +
-					      (cy_chip_offset[chip_number] <<
-					       index) + (CyGFRCR << index))) >=
-				    CD1400_REV_J) {
-					/* It is a CD1400 rev. J or later */
-					info->tbpr = baud_bpr_60[13];	/* Tx BPR */
-					info->tco = baud_co_60[13];	/* Tx CO */
-					info->rbpr = baud_bpr_60[13];	/* Rx BPR */
-					info->rco = baud_co_60[13];	/* Rx CO */
-					info->rflow = 0;
-					info->rtsdtr_inv = 1;
-				} else {
-					info->tbpr = baud_bpr_25[13];	/* Tx BPR */
-					info->tco = baud_co_25[13];	/* Tx CO */
-					info->rbpr = baud_bpr_25[13];	/* Rx BPR */
-					info->rco = baud_co_25[13];	/* Rx CO */
-					info->rflow = 0;
-					info->rtsdtr_inv = 0;
-				}
-				info->x_char = 0;
-				info->event = 0;
-				info->count = 0;
-				info->blocked_open = 0;
-				info->default_threshold = 0;
-				info->default_timeout = 0;
-				INIT_WORK(&info->tqueue, do_softint);
-				init_waitqueue_head(&info->open_wait);
-				init_waitqueue_head(&info->close_wait);
-				init_waitqueue_head(&info->shutdown_wait);
-				init_waitqueue_head(&info->delta_msr_wait);
-				/* info->session */
-				/* info->pgrp */
-				info->read_status_mask =
-				    CyTIMEOUT | CySPECHAR | CyBREAK
-				    | CyPARITY | CyFRAME | CyOVERRUN;
-				/* info->timeout */
-			}
-		}
-	}
-
-#ifndef CONFIG_CYZ_INTR
-	if (number_z_boards) {
-		mod_timer(&cyz_timerlist, jiffies + 1);
-#ifdef CY_PCI_DEBUG
-		printk("Cyclades-Z polling initialized\n");
-#endif
-	}
-#endif				/* CONFIG_CYZ_INTR */
+	for (i = 0; i < cy_nboard; i++)
+		cy_init_card(&cy_card[i], i);
 
 	return 0;
 

  parent reply	other threads:[~2007-04-18 10:05 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-18 10:03 [PATCH 1/11] Char: cyclades, create cy_init_Ze Jiri Slaby
2007-04-18 10:03 ` [PATCH 2/11] Char: cyclades, use pci_iomap/unmap Jiri Slaby
2007-04-18 10:04 ` [PATCH 3/11] Char: cyclades, init Ze immediately Jiri Slaby
2007-04-18 10:04 ` [PATCH 4/11] Char: cyclades, create cy_pci_probe Jiri Slaby
2007-04-18 10:05 ` Jiri Slaby [this message]
2007-04-18 10:05 ` [PATCH 6/11] Char: cyclades, init card struct immediately Jiri Slaby
2007-04-18 10:06 ` [PATCH 7/11] Char: cyclades, remove some global vars Jiri Slaby
2007-04-18 10:06 ` [PATCH 8/11] Char: cyclades, cy_init error handling Jiri Slaby
2007-04-18 10:07 ` [PATCH 9/11] Char: cyclades, tty_register_device separately for each device Jiri Slaby
2007-04-18 10:07 ` [PATCH 10/11] Char: cyclades, clear interrupts before releasing Jiri Slaby
2007-04-20  4:51   ` Andrew Morton
2007-04-18 10:08 ` [PATCH 11/11] Char: cyclades, allow DEBUG_SHIRQ Jiri Slaby

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=3210010229950231391@karneval.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.