⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 linit.c

📁 linux-2.6.15.6
💻 C
📖 第 1 页 / 共 3 页
字号:
		.name = "vendor",		.mode = S_IRUGO,	},	.show = aac_show_vendor,};static struct class_device_attribute aac_kernel_version = {	.attr = {		.name = "hba_kernel_version",		.mode = S_IRUGO,	},	.show = aac_show_kernel_version,};static struct class_device_attribute aac_monitor_version = {	.attr = {		.name = "hba_monitor_version",		.mode = S_IRUGO,	},	.show = aac_show_monitor_version,};static struct class_device_attribute aac_bios_version = {	.attr = {		.name = "hba_bios_version",		.mode = S_IRUGO,	},	.show = aac_show_bios_version,};static struct class_device_attribute aac_serial_number = {	.attr = {		.name = "serial_number",		.mode = S_IRUGO,	},	.show = aac_show_serial_number,};static struct class_device_attribute *aac_attrs[] = {	&aac_model,	&aac_vendor,	&aac_kernel_version,	&aac_monitor_version,	&aac_bios_version,	&aac_serial_number,	NULL};static struct file_operations aac_cfg_fops = {	.owner		= THIS_MODULE,	.ioctl		= aac_cfg_ioctl,#ifdef CONFIG_COMPAT	.compat_ioctl   = aac_compat_cfg_ioctl,#endif	.open		= aac_cfg_open,};static struct scsi_host_template aac_driver_template = {	.module				= THIS_MODULE,	.name           		= "AAC",	.proc_name			= AAC_DRIVERNAME,	.info           		= aac_info,	.ioctl          		= aac_ioctl,#ifdef CONFIG_COMPAT	.compat_ioctl			= aac_compat_ioctl,#endif	.queuecommand   		= aac_queuecommand,	.bios_param     		= aac_biosparm,		.shost_attrs			= aac_attrs,	.slave_configure		= aac_slave_configure,	.eh_host_reset_handler		= aac_eh_reset,	.can_queue      		= AAC_NUM_IO_FIB,		.this_id        		= MAXIMUM_NUM_CONTAINERS,	.sg_tablesize   		= 16,	.max_sectors    		= 128,#if (AAC_NUM_IO_FIB > 256)	.cmd_per_lun			= 256,#else			.cmd_per_lun    		= AAC_NUM_IO_FIB, #endif		.use_clustering			= ENABLE_CLUSTERING,};static int __devinit aac_probe_one(struct pci_dev *pdev,		const struct pci_device_id *id){	unsigned index = id->driver_data;	struct Scsi_Host *shost;	struct aac_dev *aac;	struct list_head *insert = &aac_devices;	int error = -ENODEV;	int unique_id = 0;	list_for_each_entry(aac, &aac_devices, entry) {		if (aac->id > unique_id)			break;		insert = &aac->entry;		unique_id++;	}	error = pci_enable_device(pdev);	if (error)		goto out;	if (pci_set_dma_mask(pdev, DMA_32BIT_MASK) || 			pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK))		goto out;	/*	 * If the quirk31 bit is set, the adapter needs adapter	 * to driver communication memory to be allocated below 2gig	 */	if (aac_drivers[index].quirks & AAC_QUIRK_31BIT) 		if (pci_set_dma_mask(pdev, 0x7FFFFFFFULL) ||				pci_set_consistent_dma_mask(pdev, 0x7FFFFFFFULL))			goto out;		pci_set_master(pdev);	shost = scsi_host_alloc(&aac_driver_template, sizeof(struct aac_dev));	if (!shost)		goto out_disable_pdev;	shost->irq = pdev->irq;	shost->base = pci_resource_start(pdev, 0);	shost->unique_id = unique_id;	shost->max_cmd_len = 16;	aac = (struct aac_dev *)shost->hostdata;	aac->scsi_host_ptr = shost;		aac->pdev = pdev;	aac->name = aac_driver_template.name;	aac->id = shost->unique_id;	aac->cardtype =  index;	INIT_LIST_HEAD(&aac->entry);	aac->fibs = kmalloc(sizeof(struct fib) * (shost->can_queue + AAC_NUM_MGT_FIB), GFP_KERNEL);	if (!aac->fibs)		goto out_free_host;	spin_lock_init(&aac->fib_lock);	/*	 *	Map in the registers from the adapter.	 */	aac->base_size = AAC_MIN_FOOTPRINT_SIZE;	if ((aac->regs.sa = ioremap(	  (unsigned long)aac->scsi_host_ptr->base, AAC_MIN_FOOTPRINT_SIZE))	  == NULL) {			printk(KERN_WARNING "%s: unable to map adapter.\n",		  AAC_DRIVERNAME);		goto out_free_fibs;	}	if ((*aac_drivers[index].init)(aac))		goto out_unmap;	/*	 *	Start any kernel threads needed	 */	aac->thread_pid = kernel_thread((int (*)(void *))aac_command_thread,	  aac, 0);	if (aac->thread_pid < 0) {		printk(KERN_ERR "aacraid: Unable to create command thread.\n");		goto out_deinit;	}	/*	 * If we had set a smaller DMA mask earlier, set it to 4gig	 * now since the adapter can dma data to at least a 4gig	 * address space.	 */	if (aac_drivers[index].quirks & AAC_QUIRK_31BIT)		if (pci_set_dma_mask(pdev, DMA_32BIT_MASK))			goto out_deinit; 	aac->maximum_num_channels = aac_drivers[index].channels;	error = aac_get_adapter_info(aac);	if (error < 0)		goto out_deinit;	/* 	 * Lets override negotiations and drop the maximum SG limit to 34 	 */ 	if ((aac_drivers[index].quirks & AAC_QUIRK_34SG) && 			(aac->scsi_host_ptr->sg_tablesize > 34)) { 		aac->scsi_host_ptr->sg_tablesize = 34; 		aac->scsi_host_ptr->max_sectors 		  = (aac->scsi_host_ptr->sg_tablesize * 8) + 112; 	}	/*	 * Firware printf works only with older firmware.	 */	if (aac_drivers[index].quirks & AAC_QUIRK_34SG) 		aac->printf_enabled = 1;	else		aac->printf_enabled = 0;  	/*	 * max channel will be the physical channels plus 1 virtual channel	 * all containers are on the virtual channel 0	 * physical channels are address by their actual physical number+1	 */	if (aac->nondasd_support == 1)		shost->max_channel = aac->maximum_num_channels + 1;	else		shost->max_channel = 1;	aac_get_config_status(aac);	aac_get_containers(aac);	list_add(&aac->entry, insert);	shost->max_id = aac->maximum_num_containers;	if (shost->max_id < aac->maximum_num_physicals)		shost->max_id = aac->maximum_num_physicals;	if (shost->max_id < MAXIMUM_NUM_CONTAINERS)		shost->max_id = MAXIMUM_NUM_CONTAINERS;	else		shost->this_id = shost->max_id;	/*	 * dmb - we may need to move the setting of these parms somewhere else once	 * we get a fib that can report the actual numbers	 */	shost->max_lun = AAC_MAX_LUN;	pci_set_drvdata(pdev, shost);	error = scsi_add_host(shost, &pdev->dev);	if (error)		goto out_deinit;	scsi_scan_host(shost);	return 0; out_deinit:	kill_proc(aac->thread_pid, SIGKILL, 0);	wait_for_completion(&aac->aif_completion);	aac_send_shutdown(aac);	aac_adapter_disable_int(aac);	free_irq(pdev->irq, aac); out_unmap:	fib_map_free(aac);	pci_free_consistent(aac->pdev, aac->comm_size, aac->comm_addr, aac->comm_phys);	kfree(aac->queues);	iounmap(aac->regs.sa); out_free_fibs:	kfree(aac->fibs);	kfree(aac->fsa_dev); out_free_host:	scsi_host_put(shost); out_disable_pdev:	pci_disable_device(pdev); out:	return error;}static void aac_shutdown(struct pci_dev *dev){	struct Scsi_Host *shost = pci_get_drvdata(dev);	struct aac_dev *aac = (struct aac_dev *)shost->hostdata;	aac_send_shutdown(aac);}static void __devexit aac_remove_one(struct pci_dev *pdev){	struct Scsi_Host *shost = pci_get_drvdata(pdev);	struct aac_dev *aac = (struct aac_dev *)shost->hostdata;	scsi_remove_host(shost);	kill_proc(aac->thread_pid, SIGKILL, 0);	wait_for_completion(&aac->aif_completion);	aac_send_shutdown(aac);	aac_adapter_disable_int(aac);	fib_map_free(aac);	pci_free_consistent(aac->pdev, aac->comm_size, aac->comm_addr,			aac->comm_phys);	kfree(aac->queues);	free_irq(pdev->irq, aac);	iounmap(aac->regs.sa);		kfree(aac->fibs);	kfree(aac->fsa_dev);		list_del(&aac->entry);	scsi_host_put(shost);	pci_disable_device(pdev);}static struct pci_driver aac_pci_driver = {	.name		= AAC_DRIVERNAME,	.id_table	= aac_pci_tbl,	.probe		= aac_probe_one,	.remove		= __devexit_p(aac_remove_one),	.shutdown 	= aac_shutdown,};static int __init aac_init(void){	int error;		printk(KERN_INFO "Adaptec %s driver (%s)\n",	  AAC_DRIVERNAME, aac_driver_version);	error = pci_register_driver(&aac_pci_driver);	if (error < 0)		return error;	aac_cfg_major = register_chrdev( 0, "aac", &aac_cfg_fops);	if (aac_cfg_major < 0) {		printk(KERN_WARNING		       "aacraid: unable to register \"aac\" device.\n");	}	return 0;}static void __exit aac_exit(void){	unregister_chrdev(aac_cfg_major, "aac");	pci_unregister_driver(&aac_pci_driver);}module_init(aac_init);module_exit(aac_exit);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -