/* We have 4 ports per PCI function */ k2_sata_setup_port(&probe_ent->port[0], base + 0 * K2_SATA_PORT_OFFSET); k2_sata_setup_port(&probe_ent->port[1], base + 1 * K2_SATA_PORT_OFFSET); k2_sata_setup_port(&probe_ent->port[2], base + 2 * K2_SATA_PORT_OFFSET); k2_sata_setup_port(&probe_ent->port[3], base + 3 * K2_SATA_PORT_OFFSET); 
/* different controllers have different number of ports - currently 4 or 8 */ /* All ports are on the same function. Multi-function device is no * longer available. This should not be seen in any system. */ for (i = 0; i < ent->driver_data; i++) k2_sata_setup_port(&probe_ent->port[i], base + i * K2_SATA_PORT_OFFSET); 
static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent){	static int printed_version;	struct ata_probe_ent *probe_ent = NULL;	unsigned long base;	void *mmio_base;	int pci_dev_busy = 0;	int rc;	if (!printed_version++)		printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n");	/*	 * If this driver happens to only be useful on Apple's K2, then	 * we should check that here as it has a normal Serverworks ID	 */	rc = pci_enable_device(pdev);	if (rc)		return rc;	/*	 * Check if we have resources mapped at all (second function may	 * have been disabled by firmware)	 */	if (pci_resource_len(pdev, 5) == 0)		return -ENODEV;	/* Request PCI regions */	rc = pci_request_regions(pdev, DRV_NAME);	if (rc) {		pci_dev_busy = 1;		goto err_out;	}	rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);	if (rc)		goto err_out_regions;	rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK);	if (rc)		goto err_out_regions;	probe_ent = kmalloc(sizeof(*probe_ent), GFP_KERNEL);	if (probe_ent == NULL) {		rc = -ENOMEM;		goto err_out_regions;	}	memset(probe_ent, 0, sizeof(*probe_ent));	probe_ent->dev = pci_dev_to_dev(pdev);	INIT_LIST_HEAD(&probe_ent->node);	mmio_base = ioremap(pci_resource_start(pdev, 5),		            pci_resource_len(pdev, 5));	if (mmio_base == NULL) {		rc = -ENOMEM;		goto err_out_free_ent;	}	base = (unsigned long) mmio_base;	/* Clear a magic bit in SCR1 according to Darwin, those help	 * some funky seagate drives (though so far, those were already	 * set by the firmware on the machines I had access to)	 */	writel(readl(mmio_base + K2_SATA_SICR1_OFFSET) & ~0x00040000,	       mmio_base + K2_SATA_SICR1_OFFSET);	/* Clear SATA error & interrupts we don't use */	writel(0xffffffff, mmio_base + K2_SATA_SCR_ERROR_OFFSET);	writel(0x0, mmio_base + K2_SATA_SIM_OFFSET);	probe_ent->sht = &k2_sata_sht;	probe_ent->host_flags = ATA_FLAG_SATA | ATA_FLAG_SATA_RESET |				ATA_FLAG_NO_LEGACY | ATA_FLAG_MMIO;	probe_ent->port_ops = &k2_sata_ops;	probe_ent->n_ports = 4;	probe_ent->irq = pdev->irq;	probe_ent->irq_flags = SA_SHIRQ;	probe_ent->mmio_base = mmio_base;	/* We don't care much about the PIO/UDMA masks, but the core won't like us	 * if we don't fill these	 */	probe_ent->pio_mask = 0x1f;	probe_ent->mwdma_mask = 0x7;	probe_ent->udma_mask = 0x7f;	/* We have 4 ports per PCI function */	k2_sata_setup_port(&probe_ent->port[0], base + 0 * K2_SATA_PORT_OFFSET);	k2_sata_setup_port(&probe_ent->port[1], base + 1 * K2_SATA_PORT_OFFSET);	k2_sata_setup_port(&probe_ent->port[2], base + 2 * K2_SATA_PORT_OFFSET);	k2_sata_setup_port(&probe_ent->port[3], base + 3 * K2_SATA_PORT_OFFSET);	pci_set_master(pdev);	/* FIXME: check ata_device_add return value */	ata_device_add(probe_ent);	kfree(probe_ent);	return 0;err_out_free_ent:	kfree(probe_ent);err_out_regions:	pci_release_regions(pdev);err_out:	if (!pci_dev_busy)		pci_disable_device(pdev);	return rc;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/60bf09a366c873aab36e3b3110ee9f5bd89a1a6d/sata_svw.c/clean/drivers/scsi/sata_svw.c