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

📄 linit.c

📁 linux-2.6.15.6
💻 C
📖 第 1 页 / 共 3 页
字号:
	if (!buf)		return 0;	if(*(__le16 *)(buf + 0x40) == cpu_to_le16(0xaa55)) {		struct partition *first = (struct partition * )buf;		struct partition *entry = first;		int saved_cylinders = param->cylinders;		int num;		unsigned char end_head, end_sec;		for(num = 0; num < 4; num++) {			end_head = entry->end_head;			end_sec = entry->end_sector & 0x3f;			if(end_head == 63) {				param->heads = 64;				param->sectors = 32;				break;			} else if(end_head == 127) {				param->heads = 128;				param->sectors = 32;				break;			} else if(end_head == 254) {				param->heads = 255;				param->sectors = 63;				break;			}			entry++;		}		if (num == 4) {			end_head = first->end_head;			end_sec = first->end_sector & 0x3f;		}		param->cylinders = cap_to_cyls(capacity, param->heads * param->sectors);		if (num < 4 && end_sec == param->sectors) {			if (param->cylinders != saved_cylinders)				dprintk((KERN_DEBUG "Adopting geometry: heads=%d, sectors=%d from partition table %d.\n",					param->heads, param->sectors, num));		} else if (end_head > 0 || end_sec > 0) {			dprintk((KERN_DEBUG "Strange geometry: heads=%d, sectors=%d in partition table %d.\n",				end_head + 1, end_sec, num));			dprintk((KERN_DEBUG "Using geometry: heads=%d, sectors=%d.\n",					param->heads, param->sectors));		}	}	kfree(buf);	return 0;}/** *	aac_slave_configure		-	compute queue depths *	@sdev:	SCSI device we are considering * *	Selects queue depths for each target device based on the host adapter's *	total capacity and the queue depth supported by the target device. *	A queue depth of one automatically disables tagged queueing. */static int aac_slave_configure(struct scsi_device *sdev){	struct Scsi_Host *host = sdev->host;	if (sdev->tagged_supported)		scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, 128);	else		scsi_adjust_queue_depth(sdev, 0, 1);	if (!(((struct aac_dev *)host->hostdata)->adapter_info.options	  & AAC_OPT_NEW_COMM))		blk_queue_max_segment_size(sdev->request_queue, 65536);	return 0;}static int aac_ioctl(struct scsi_device *sdev, int cmd, void __user * arg){	struct aac_dev *dev = (struct aac_dev *)sdev->host->hostdata;	return aac_do_ioctl(dev, cmd, arg);}/* *	aac_eh_reset	- Reset command handling *	@scsi_cmd:	SCSI command block causing the reset * */static int aac_eh_reset(struct scsi_cmnd* cmd){	struct scsi_device * dev = cmd->device;	struct Scsi_Host * host = dev->host;	struct scsi_cmnd * command;	int count;	struct aac_dev * aac;	unsigned long flags;	printk(KERN_ERR "%s: Host adapter reset request. SCSI hang ?\n", 					AAC_DRIVERNAME);	spin_lock_irq(host->host_lock);	aac = (struct aac_dev *)host->hostdata;	if (aac_adapter_check_health(aac)) {		printk(KERN_ERR "%s: Host adapter appears dead\n", 				AAC_DRIVERNAME);		spin_unlock_irq(host->host_lock);		return -ENODEV;	}	/*	 * Wait for all commands to complete to this specific	 * target (block maximum 60 seconds).	 */	for (count = 60; count; --count) {		int active = 0;		__shost_for_each_device(dev, host) {			spin_lock_irqsave(&dev->list_lock, flags);			list_for_each_entry(command, &dev->cmd_list, list) {				if (command->serial_number) {					active++;					break;				}			}			spin_unlock_irqrestore(&dev->list_lock, flags);			if (active)				break;		}		/*		 * We can exit If all the commands are complete		 */		spin_unlock_irq(host->host_lock);		if (active == 0)			return SUCCESS;		ssleep(1);		spin_lock_irq(host->host_lock);	}	spin_unlock_irq(host->host_lock);	printk(KERN_ERR "%s: SCSI bus appears hung\n", AAC_DRIVERNAME);	return -ETIMEDOUT;}/** *	aac_cfg_open		-	open a configuration file *	@inode: inode being opened *	@file: file handle attached * *	Called when the configuration device is opened. Does the needed *	set up on the handle and then returns * *	Bugs: This needs extending to check a given adapter is present *	so we can support hot plugging, and to ref count adapters. */static int aac_cfg_open(struct inode *inode, struct file *file){	struct aac_dev *aac;	unsigned minor_number = iminor(inode);	int err = -ENODEV;	list_for_each_entry(aac, &aac_devices, entry) {		if (aac->id == minor_number) {			file->private_data = aac;			err = 0;			break;		}	}	return err;}/** *	aac_cfg_ioctl		-	AAC configuration request *	@inode: inode of device *	@file: file handle *	@cmd: ioctl command code *	@arg: argument * *	Handles a configuration ioctl. Currently this involves wrapping it *	up and feeding it into the nasty windowsalike glue layer. * *	Bugs: Needs locking against parallel ioctls lower down *	Bugs: Needs to handle hot plugging */ static int aac_cfg_ioctl(struct inode *inode,  struct file *file,		unsigned int cmd, unsigned long arg){	return aac_do_ioctl(file->private_data, cmd, (void __user *)arg);}#ifdef CONFIG_COMPATstatic long aac_compat_do_ioctl(struct aac_dev *dev, unsigned cmd, unsigned long arg){	long ret;	lock_kernel();	switch (cmd) { 	case FSACTL_MINIPORT_REV_CHECK:	case FSACTL_SENDFIB:	case FSACTL_OPEN_GET_ADAPTER_FIB:	case FSACTL_CLOSE_GET_ADAPTER_FIB:	case FSACTL_SEND_RAW_SRB:	case FSACTL_GET_PCI_INFO:	case FSACTL_QUERY_DISK:	case FSACTL_DELETE_DISK:	case FSACTL_FORCE_DELETE_DISK:	case FSACTL_GET_CONTAINERS: 	case FSACTL_SEND_LARGE_FIB:		ret = aac_do_ioctl(dev, cmd, (void __user *)arg);		break;	case FSACTL_GET_NEXT_ADAPTER_FIB: {		struct fib_ioctl __user *f;				f = compat_alloc_user_space(sizeof(*f));		ret = 0;		if (clear_user(f, sizeof(*f) != sizeof(*f)))			ret = -EFAULT;		if (copy_in_user(f, (void __user *)arg, sizeof(struct fib_ioctl) - sizeof(u32)))			ret = -EFAULT;		if (!ret)			ret = aac_do_ioctl(dev, cmd, (void __user *)arg);		break;	}	default:		ret = -ENOIOCTLCMD; 		break;	} 	unlock_kernel();	return ret;}static int aac_compat_ioctl(struct scsi_device *sdev, int cmd, void __user *arg){	struct aac_dev *dev = (struct aac_dev *)sdev->host->hostdata;	return aac_compat_do_ioctl(dev, cmd, (unsigned long)arg);}static long aac_compat_cfg_ioctl(struct file *file, unsigned cmd, unsigned long arg){	return aac_compat_do_ioctl((struct aac_dev *)file->private_data, cmd, arg);}#endifstatic ssize_t aac_show_model(struct class_device *class_dev,		char *buf){	struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata;	int len;	len = snprintf(buf, PAGE_SIZE, "%s\n",		  aac_drivers[dev->cardtype].model);	return len;}static ssize_t aac_show_vendor(struct class_device *class_dev,		char *buf){	struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata;	int len;	len = snprintf(buf, PAGE_SIZE, "%s\n",		  aac_drivers[dev->cardtype].vname);	return len;}static ssize_t aac_show_kernel_version(struct class_device *class_dev,		char *buf){	struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata;	int len, tmp;	tmp = le32_to_cpu(dev->adapter_info.kernelrev);	len = snprintf(buf, PAGE_SIZE, "%d.%d-%d[%d]\n", 	  tmp >> 24, (tmp >> 16) & 0xff, tmp & 0xff,	  le32_to_cpu(dev->adapter_info.kernelbuild));	return len;}static ssize_t aac_show_monitor_version(struct class_device *class_dev,		char *buf){	struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata;	int len, tmp;	tmp = le32_to_cpu(dev->adapter_info.monitorrev);	len = snprintf(buf, PAGE_SIZE, "%d.%d-%d[%d]\n", 	  tmp >> 24, (tmp >> 16) & 0xff, tmp & 0xff,	  le32_to_cpu(dev->adapter_info.monitorbuild));	return len;}static ssize_t aac_show_bios_version(struct class_device *class_dev,		char *buf){	struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata;	int len, tmp;	tmp = le32_to_cpu(dev->adapter_info.biosrev);	len = snprintf(buf, PAGE_SIZE, "%d.%d-%d[%d]\n", 	  tmp >> 24, (tmp >> 16) & 0xff, tmp & 0xff,	  le32_to_cpu(dev->adapter_info.biosbuild));	return len;}static ssize_t aac_show_serial_number(struct class_device *class_dev,		char *buf){	struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata;	int len = 0;	if (le32_to_cpu(dev->adapter_info.serial[0]) != 0xBAD0)		len = snprintf(buf, PAGE_SIZE, "%x\n",		  le32_to_cpu(dev->adapter_info.serial[0]));	return len;}static struct class_device_attribute aac_model = {	.attr = {		.name = "model",		.mode = S_IRUGO,	},	.show = aac_show_model,};static struct class_device_attribute aac_vendor = {	.attr = {

⌨️ 快捷键说明

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