spin_lock_init(&port->ip_lock); 
static int inline ioc4_attach_local(struct ioc4_driver_data *idd){	struct ioc4_port *port;	struct ioc4_port *ports[IOC4_NUM_SERIAL_PORTS];	int port_number;	uint16_t ioc4_revid_min = 62;	uint16_t ioc4_revid;	struct pci_dev *pdev = idd->idd_pdev;	struct ioc4_control* control = idd->idd_serial_data;	struct ioc4_soft *soft = control->ic_soft;	void __iomem *ioc4_misc = idd->idd_misc_regs;	void __iomem *ioc4_serial = soft->is_ioc4_serial_addr;	/* IOC4 firmware must be at least rev 62 */	pci_read_config_word(pdev, PCI_COMMAND_SPECIAL, &ioc4_revid);	printk(KERN_INFO "IOC4 firmware revision %d\n", ioc4_revid);	if (ioc4_revid < ioc4_revid_min) {		printk(KERN_WARNING		    "IOC4 serial not supported on firmware rev %d, "				"please upgrade to rev %d or higher\n",				ioc4_revid, ioc4_revid_min);		return -EPERM;	}	BUG_ON(ioc4_misc == NULL);	BUG_ON(ioc4_serial == NULL);	/* Create port structures for each port */	for (port_number = 0; port_number < IOC4_NUM_SERIAL_PORTS;							port_number++) {		port = kmalloc(sizeof(struct ioc4_port), GFP_KERNEL);		if (!port) {			printk(KERN_WARNING				"IOC4 serial memory not available for port\n");			return -ENOMEM;		}		memset(port, 0, sizeof(struct ioc4_port));		/* we need to remember the previous ones, to point back to		 * them farther down - setting up the ring buffers.		 */		ports[port_number] = port;		/* Allocate buffers and jumpstart the hardware.  */		control->ic_port[port_number].icp_port = port;		port->ip_ioc4_soft = soft;		port->ip_pdev = pdev;		port->ip_ienb = 0;		/* Use baud rate calculations based on detected PCI		 * bus speed.  Simply test whether the PCI clock is		 * running closer to 66MHz or 33MHz.		 */		if (idd->count_period/IOC4_EXTINT_COUNT_DIVISOR < 20) {			port->ip_pci_bus_speed = IOC4_SER_XIN_CLK_66;		} else {			port->ip_pci_bus_speed = IOC4_SER_XIN_CLK_33;		}		port->ip_baud = 9600;		port->ip_control = control;		port->ip_mem = ioc4_misc;		port->ip_serial = ioc4_serial;		/* point to the right hook */		port->ip_hooks = &hooks_array[port_number];		/* Get direct hooks to the serial regs and uart regs		 * for this port		 */		switch (port_number) {		case 0:			port->ip_serial_regs = &(port->ip_serial->port_0);			port->ip_uart_regs = &(port->ip_serial->uart_0);			break;		case 1:			port->ip_serial_regs = &(port->ip_serial->port_1);			port->ip_uart_regs = &(port->ip_serial->uart_1);			break;		case 2:			port->ip_serial_regs = &(port->ip_serial->port_2);			port->ip_uart_regs = &(port->ip_serial->uart_2);			break;		default:		case 3:			port->ip_serial_regs = &(port->ip_serial->port_3);			port->ip_uart_regs = &(port->ip_serial->uart_3);			break;		}		/* ring buffers are 1 to a pair of ports */		if (port_number && (port_number & 1)) {			/* odd use the evens buffer */			port->ip_dma_ringbuf =					ports[port_number - 1]->ip_dma_ringbuf;			port->ip_cpu_ringbuf =					ports[port_number - 1]->ip_cpu_ringbuf;			port->ip_inring = RING(port, RX_1_OR_3);			port->ip_outring = RING(port, TX_1_OR_3);		} else {			if (port->ip_dma_ringbuf == 0) {				port->ip_cpu_ringbuf = pci_alloc_consistent					(pdev, TOTAL_RING_BUF_SIZE,					&port->ip_dma_ringbuf);			}			BUG_ON(!((((int64_t)port->ip_dma_ringbuf) &				(TOTAL_RING_BUF_SIZE - 1)) == 0));			DPRINT_CONFIG(("%s : ip_cpu_ringbuf 0x%p "						"ip_dma_ringbuf 0x%p\n",					__FUNCTION__,					(void *)port->ip_cpu_ringbuf,					(void *)port->ip_dma_ringbuf));			port->ip_inring = RING(port, RX_0_OR_2);			port->ip_outring = RING(port, TX_0_OR_2);		}		DPRINT_CONFIG(("%s : port %d [addr 0x%p] control 0x%p",				__FUNCTION__,				port_number, (void *)port, (void *)control));		DPRINT_CONFIG((" ip_serial_regs 0x%p ip_uart_regs 0x%p\n",				(void *)port->ip_serial_regs,				(void *)port->ip_uart_regs));		/* Initialize the hardware for IOC4 */		port_init(port);		DPRINT_CONFIG(("%s: port_number %d port 0x%p inring 0x%p "						"outring 0x%p\n",				__FUNCTION__,				port_number, (void *)port,				(void *)port->ip_inring,				(void *)port->ip_outring));		/* Attach interrupt handlers */		intr_connect(soft, IOC4_SIO_INTR_TYPE,				GET_SIO_IR(port_number),				handle_intr, port);		intr_connect(soft, IOC4_OTHER_INTR_TYPE,				GET_OTHER_IR(port_number),				handle_dma_error_intr, port);	}	return 0;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/396dc44bcac58f464b7b23c345052e37881cccea/ioc4_serial.c/buggy/drivers/serial/ioc4_serial.c