#endif /* CONFIG_PARPORT_PC_FIFO */ 
#endif #endif 
struct parport *parport_pc_probe_port (unsigned long int base,				       unsigned long int base_hi,				       int irq, int dma,				       struct pci_dev *dev){	struct parport_pc_private *priv;	struct parport_operations *ops;	struct parport *p;	int probedirq = PARPORT_IRQ_NONE;	struct resource *base_res;	struct resource	*ECR_res = NULL;	struct resource	*EPP_res = NULL;	ops = kmalloc(sizeof (struct parport_operations), GFP_KERNEL);	if (!ops)		goto out1;	priv = kmalloc (sizeof (struct parport_pc_private), GFP_KERNEL);	if (!priv)		goto out2;	/* a misnomer, actually - it's allocate and reserve parport number */	p = parport_register_port(base, irq, dma, ops);	if (!p)		goto out3;	base_res = request_region(base, 3, p->name);	if (!base_res)		goto out4;	memcpy(ops, &parport_pc_ops, sizeof (struct parport_operations));	priv->ctr = 0xc;	priv->ctr_writable = ~0x10;	priv->ecr = 0;	priv->fifo_depth = 0;	priv->dma_buf = NULL;	priv->dma_handle = 0;	priv->dev = dev;	INIT_LIST_HEAD(&priv->list);	priv->port = p;	p->base_hi = base_hi;	p->modes = PARPORT_MODE_PCSPP | PARPORT_MODE_SAFEININT;	p->private_data = priv;	if (base_hi) {		ECR_res = request_region(base_hi, 3, p->name);		if (ECR_res)			parport_ECR_present(p);	}	if (base != 0x3bc) {		EPP_res = request_region(base+0x3, 5, p->name);		if (EPP_res)			if (!parport_EPP_supported(p))				parport_ECPEPP_supported(p);	}	if (!parport_SPP_supported (p))		/* No port. */		goto out5;	if (priv->ecr)		parport_ECPPS2_supported(p);	else		parport_PS2_supported(p);	p->size = (p->modes & PARPORT_MODE_EPP)?8:3;	printk(KERN_INFO "%s: PC-style at 0x%lx", p->name, p->base);	if (p->base_hi && priv->ecr)		printk(" (0x%lx)", p->base_hi);	if (p->irq == PARPORT_IRQ_AUTO) {		p->irq = PARPORT_IRQ_NONE;		parport_irq_probe(p);	} else if (p->irq == PARPORT_IRQ_PROBEONLY) {		p->irq = PARPORT_IRQ_NONE;		parport_irq_probe(p);		probedirq = p->irq;		p->irq = PARPORT_IRQ_NONE;	}	if (p->irq != PARPORT_IRQ_NONE) {		printk(", irq %d", p->irq);		priv->ctr_writable |= 0x10;		if (p->dma == PARPORT_DMA_AUTO) {			p->dma = PARPORT_DMA_NONE;			parport_dma_probe(p);		}	}	if (p->dma == PARPORT_DMA_AUTO) /* To use DMA, giving the irq                                           is mandatory (see above) */		p->dma = PARPORT_DMA_NONE;#ifdef CONFIG_PARPORT_PC_FIFO	if (parport_ECP_supported(p) &&	    p->dma != PARPORT_DMA_NOFIFO &&	    priv->fifo_depth > 0 && p->irq != PARPORT_IRQ_NONE) {		p->modes |= PARPORT_MODE_ECP | PARPORT_MODE_COMPAT;		p->ops->compat_write_data = parport_pc_compat_write_block_pio;#ifdef CONFIG_PARPORT_1284		p->ops->ecp_write_data = parport_pc_ecp_write_block_pio;		/* currently broken, but working on it.. (FB) */		/* p->ops->ecp_read_data = parport_pc_ecp_read_block_pio; */#endif /* IEEE 1284 support */		if (p->dma != PARPORT_DMA_NONE) {			printk(", dma %d", p->dma);			p->modes |= PARPORT_MODE_DMA;		}		else printk(", using FIFO");	}	else		/* We can't use the DMA channel after all. */		p->dma = PARPORT_DMA_NONE;#endif /* Allowed to use FIFO/DMA */	printk(" [");#define printmode(x) {if(p->modes&PARPORT_MODE_##x){printk("%s%s",f?",":"",#x);f++;}}	{		int f = 0;		printmode(PCSPP);		printmode(TRISTATE);		printmode(COMPAT)		printmode(EPP);		printmode(ECP);		printmode(DMA);	}#undef printmode#ifndef CONFIG_PARPORT_1284	printk ("(,...)");#endif /* CONFIG_PARPORT_1284 */	printk("]\n");	if (probedirq != PARPORT_IRQ_NONE) 		printk(KERN_INFO "%s: irq %d detected\n", p->name, probedirq);	/* If No ECP release the ports grabbed above. */	if (ECR_res && (p->modes & PARPORT_MODE_ECP) == 0) {		release_region(base_hi, 3);		ECR_res = NULL;	}	/* Likewise for EEP ports */	if (EPP_res && (p->modes & PARPORT_MODE_EPP) == 0) {		release_region(base+3, 5);		EPP_res = NULL;	}	if (p->irq != PARPORT_IRQ_NONE) {		if (request_irq (p->irq, parport_pc_interrupt,				 0, p->name, p)) {			printk (KERN_WARNING "%s: irq %d in use, "				"resorting to polled operation\n",				p->name, p->irq);			p->irq = PARPORT_IRQ_NONE;			p->dma = PARPORT_DMA_NONE;		}#ifdef CONFIG_PARPORT_PC_FIFO		if (p->dma != PARPORT_DMA_NONE) {			if (request_dma (p->dma, p->name)) {				printk (KERN_WARNING "%s: dma %d in use, "					"resorting to PIO operation\n",					p->name, p->dma);				p->dma = PARPORT_DMA_NONE;			} else {				priv->dma_buf =				  pci_alloc_consistent(priv->dev,						       PAGE_SIZE,						       &priv->dma_handle);				if (! priv->dma_buf) {					printk (KERN_WARNING "%s: "						"cannot get buffer for DMA, "						"resorting to PIO operation\n",						p->name);					free_dma(p->dma);					p->dma = PARPORT_DMA_NONE;				}			}		}#endif /* CONFIG_PARPORT_PC_FIFO */	}	/* Done probing.  Now put the port into a sensible start-up state. */	if (priv->ecr)		/*		 * Put the ECP detected port in PS2 mode.		 * Do this also for ports that have ECR but don't do ECP.		 */		ECR_WRITE (p, 0x34);	parport_pc_write_data(p, 0);	parport_pc_data_forward (p);	/* Now that we've told the sharing engine about the port, and	   found out its characteristics, let the high-level drivers	   know about it. */	spin_lock(&ports_lock);	list_add(&priv->list, &ports_list);	spin_unlock(&ports_lock);	parport_announce_port (p);	return p;out5:	if (ECR_res)		release_region(base_hi, 3);	if (EPP_res)		release_region(base+0x3, 5);	release_region(base, 3);out4:	parport_put_port(p);out3:	kfree (priv);out2:	kfree (ops);out1:	return NULL;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/7fbacd5213a03b262bb17a826b166900e8b168ac/parport_pc.c/buggy/drivers/parport/parport_pc.c