View | Details | Raw Unified
Collapse All | Expand All

(-) a/drivers/scsi/constants.c (-122 / +145 lines)
 Lines 202-232   static const char * get_sa_name(const struct value_name_pair * arr, Link Here 
}
}
/* attempt to guess cdb length if cdb_len==0 . No trailing linefeed. */
/* attempt to guess cdb length if cdb_len==0 . No trailing linefeed. */
static void print_opcode_name(unsigned char * cdbp, int cdb_len,
static void print_opcode_name(unsigned char * cdbp, int cdb_len)
			      int start_of_line)
{
{
	int sa, len, cdb0;
	int sa, len, cdb0;
	const char * name;
	const char * name;
	const char * leadin = start_of_line ? KERN_INFO : "";
	cdb0 = cdbp[0];
	cdb0 = cdbp[0];
	switch(cdb0) {
	switch(cdb0) {
	case VARIABLE_LENGTH_CMD:
	case VARIABLE_LENGTH_CMD:
		len = cdbp[7] + 8;
		len = cdbp[7] + 8;
		if (len < 10) {
		if (len < 10) {
			printk("%sshort variable length command, "
			printk("short variable length command, "
			       "len=%d ext_len=%d", leadin, len, cdb_len);
			       "len=%d ext_len=%d", len, cdb_len);
			break;
			break;
		}
		}
		sa = (cdbp[8] << 8) + cdbp[9];
		sa = (cdbp[8] << 8) + cdbp[9];
		name = get_sa_name(maint_in_arr, MAINT_IN_SZ, sa);
		name = get_sa_name(maint_in_arr, MAINT_IN_SZ, sa);
		if (name) {
		if (name) {
			printk("%s%s", leadin, name);
			printk("%s", name);
			if ((cdb_len > 0) && (len != cdb_len))
			if ((cdb_len > 0) && (len != cdb_len))
				printk(", in_cdb_len=%d, ext_len=%d",
				printk(", in_cdb_len=%d, ext_len=%d",
				       len, cdb_len);
				       len, cdb_len);
		} else {
		} else {
			printk("%scdb[0]=0x%x, sa=0x%x", leadin, cdb0, sa);
			printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
			if ((cdb_len > 0) && (len != cdb_len))
			if ((cdb_len > 0) && (len != cdb_len))
				printk(", in_cdb_len=%d, ext_len=%d",
				printk(", in_cdb_len=%d, ext_len=%d",
				       len, cdb_len);
				       len, cdb_len);
 Lines 236-318   static void print_opcode_name(unsigned char * cdbp, int cdb_len, Link Here 
		sa = cdbp[1] & 0x1f;
		sa = cdbp[1] & 0x1f;
		name = get_sa_name(maint_in_arr, MAINT_IN_SZ, sa);
		name = get_sa_name(maint_in_arr, MAINT_IN_SZ, sa);
		if (name)
		if (name)
			printk("%s%s", leadin, name);
			printk("%s", name);
		else
		else
			printk("%scdb[0]=0x%x, sa=0x%x", leadin, cdb0, sa);
			printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
		break;
		break;
	case MAINTENANCE_OUT:
	case MAINTENANCE_OUT:
		sa = cdbp[1] & 0x1f;
		sa = cdbp[1] & 0x1f;
		name = get_sa_name(maint_out_arr, MAINT_OUT_SZ, sa);
		name = get_sa_name(maint_out_arr, MAINT_OUT_SZ, sa);
		if (name)
		if (name)
			printk("%s%s", leadin, name);
			printk("%s", name);
		else
		else
			printk("%scdb[0]=0x%x, sa=0x%x", leadin, cdb0, sa);
			printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
		break;
		break;
	case SERVICE_ACTION_IN_12:
	case SERVICE_ACTION_IN_12:
		sa = cdbp[1] & 0x1f;
		sa = cdbp[1] & 0x1f;
		name = get_sa_name(serv_in12_arr, SERV_IN12_SZ, sa);
		name = get_sa_name(serv_in12_arr, SERV_IN12_SZ, sa);
		if (name)
		if (name)
			printk("%s%s", leadin, name);
			printk("%s", name);
		else
		else
			printk("%scdb[0]=0x%x, sa=0x%x", leadin, cdb0, sa);
			printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
		break;
		break;
	case SERVICE_ACTION_OUT_12:
	case SERVICE_ACTION_OUT_12:
		sa = cdbp[1] & 0x1f;
		sa = cdbp[1] & 0x1f;
		name = get_sa_name(serv_out12_arr, SERV_OUT12_SZ, sa);
		name = get_sa_name(serv_out12_arr, SERV_OUT12_SZ, sa);
		if (name)
		if (name)
			printk("%s%s", leadin, name);
			printk("%s", name);
		else
		else
			printk("%scdb[0]=0x%x, sa=0x%x", leadin, cdb0, sa);
			printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
		break;
		break;
	case SERVICE_ACTION_IN_16:
	case SERVICE_ACTION_IN_16:
		sa = cdbp[1] & 0x1f;
		sa = cdbp[1] & 0x1f;
		name = get_sa_name(serv_in16_arr, SERV_IN16_SZ, sa);
		name = get_sa_name(serv_in16_arr, SERV_IN16_SZ, sa);
		if (name)
		if (name)
			printk("%s%s", leadin, name);
			printk("%s", name);
		else
		else
			printk("%scdb[0]=0x%x, sa=0x%x", leadin, cdb0, sa);
			printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
		break;
		break;
	case SERVICE_ACTION_OUT_16:
	case SERVICE_ACTION_OUT_16:
		sa = cdbp[1] & 0x1f;
		sa = cdbp[1] & 0x1f;
		name = get_sa_name(serv_out16_arr, SERV_OUT16_SZ, sa);
		name = get_sa_name(serv_out16_arr, SERV_OUT16_SZ, sa);
		if (name)
		if (name)
			printk("%s%s", leadin, name);
			printk("%s", name);
		else
		else
			printk("%scdb[0]=0x%x, sa=0x%x", leadin, cdb0, sa);
			printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
		break;
		break;
	default:
	default:
		if (cdb0 < 0xc0) {
		if (cdb0 < 0xc0) {
			name = cdb_byte0_names[cdb0];
			name = cdb_byte0_names[cdb0];
			if (name)
			if (name)
				printk("%s%s", leadin, name);
				printk("%s", name);
			else
			else
				printk("%scdb[0]=0x%x (reserved)",
				printk("cdb[0]=0x%x (reserved)", cdb0);
				       leadin, cdb0);
		} else
		} else
			printk("%scdb[0]=0x%x (vendor)", leadin, cdb0);
			printk("cdb[0]=0x%x (vendor)", cdb0);
		break;
		break;
	}
	}
}
}
#else /* ifndef CONFIG_SCSI_CONSTANTS */
#else /* ifndef CONFIG_SCSI_CONSTANTS */
static void print_opcode_name(unsigned char * cdbp, int cdb_len,
static void print_opcode_name(unsigned char * cdbp, int cdb_len)
			      int start_of_line)
{
{
	int sa, len, cdb0;
	int sa, len, cdb0;
	const char * leadin = start_of_line ? KERN_INFO : "";
	cdb0 = cdbp[0];
	cdb0 = cdbp[0];
	switch(cdb0) {
	switch(cdb0) {
	case VARIABLE_LENGTH_CMD:
	case VARIABLE_LENGTH_CMD:
		len = cdbp[7] + 8;
		len = cdbp[7] + 8;
		if (len < 10) {
		if (len < 10) {
			printk("%sshort opcode=0x%x command, len=%d "
			printk("short opcode=0x%x command, len=%d "
			       "ext_len=%d", leadin, cdb0, len, cdb_len);
			       "ext_len=%d", cdb0, len, cdb_len);
			break;
			break;
		}
		}
		sa = (cdbp[8] << 8) + cdbp[9];
		sa = (cdbp[8] << 8) + cdbp[9];
		printk("%scdb[0]=0x%x, sa=0x%x", leadin, cdb0, sa);
		printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
		if (len != cdb_len)
		if (len != cdb_len)
			printk(", in_cdb_len=%d, ext_len=%d", len, cdb_len);
			printk(", in_cdb_len=%d, ext_len=%d", len, cdb_len);
		break;
		break;
 Lines 323-371   static void print_opcode_name(unsigned char * cdbp, int cdb_len, Link Here 
	case SERVICE_ACTION_IN_16:
	case SERVICE_ACTION_IN_16:
	case SERVICE_ACTION_OUT_16:
	case SERVICE_ACTION_OUT_16:
		sa = cdbp[1] & 0x1f;
		sa = cdbp[1] & 0x1f;
		printk("%scdb[0]=0x%x, sa=0x%x", leadin, cdb0, sa);
		printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
		break;
		break;
	default:
	default:
		if (cdb0 < 0xc0)
		if (cdb0 < 0xc0)
			printk("%scdb[0]=0x%x", leadin, cdb0);
			printk("cdb[0]=0x%x", cdb0);
		else
		else
			printk("%scdb[0]=0x%x (vendor)", leadin, cdb0);
			printk("cdb[0]=0x%x (vendor)", cdb0);
		break;
		break;
	}
	}
}
}
#endif  
#endif  
void __scsi_print_command(unsigned char *command)
void __scsi_print_command(unsigned char *cdb)
{
{
	int k, len;
	int k, len;
	print_opcode_name(command, 0, 1);
	print_opcode_name(cdb, 0);
	if (VARIABLE_LENGTH_CMD == command[0])
	if (VARIABLE_LENGTH_CMD == cdb[0])
		len = command[7] + 8;
		len = cdb[7] + 8;
	else
	else
		len = COMMAND_SIZE(command[0]);
		len = COMMAND_SIZE(cdb[0]);
	/* print out all bytes in cdb */
	/* print out all bytes in cdb */
	for (k = 0; k < len; ++k) 
	for (k = 0; k < len; ++k) 
		printk(" %02x", command[k]);
		printk(" %02x", cdb[k]);
	printk("\n");
	printk("\n");
}
}
EXPORT_SYMBOL(__scsi_print_command);
EXPORT_SYMBOL(__scsi_print_command);
/* This function (perhaps with the addition of peripheral device type)
void scsi_print_command(struct scsi_cmnd *cmd)
 * is more approriate than __scsi_print_command(). Perhaps that static
 * can be dropped later if it replaces the __scsi_print_command version.
 */
static void scsi_print_cdb(unsigned char *cdb, int cdb_len, int start_of_line)
{
{
	int k;
	int k;
	print_opcode_name(cdb, cdb_len, start_of_line);
	scmd_printk(KERN_INFO, cmd, "CDB: ");
	print_opcode_name(cmd->cmnd, cmd->cmd_len);
	/* print out all bytes in cdb */
	/* print out all bytes in cdb */
	printk(":");
	printk(":");
	for (k = 0; k < cdb_len; ++k) 
	for (k = 0; k < cmd->cmd_len; ++k)
		printk(" %02x", cdb[k]);
		printk(" %02x", cmd->cmnd[k]);
	printk("\n");
	printk("\n");
}
}
EXPORT_SYMBOL(scsi_print_command);
/**
/**
 *
 *
 Lines 1176-1242   scsi_extd_sense_format(unsigned char asc, unsigned char ascq) { Link Here 
}
}
EXPORT_SYMBOL(scsi_extd_sense_format);
EXPORT_SYMBOL(scsi_extd_sense_format);
/* Print extended sense information; no leadin, no linefeed */
void
static void
scsi_show_extd_sense(unsigned char asc, unsigned char ascq)
scsi_show_extd_sense(unsigned char asc, unsigned char ascq)
{
{
	const char *extd_sense_fmt = scsi_extd_sense_format(asc, ascq);
        const char *extd_sense_fmt = scsi_extd_sense_format(asc, ascq);
	if (extd_sense_fmt) {
	if (extd_sense_fmt) {
		if (strstr(extd_sense_fmt, "%x")) {
		if (strstr(extd_sense_fmt, "%x")) {
			printk("Additional sense: ");
			printk("Add. Sense: ");
			printk(extd_sense_fmt, ascq);
			printk(extd_sense_fmt, ascq);
		} else
		} else
			printk("Additional sense: %s", extd_sense_fmt);
			printk("Add. Sense: %s", extd_sense_fmt);
	} else {
	} else {
		if (asc >= 0x80)
		if (asc >= 0x80)
			printk("<<vendor>> ASC=0x%x ASCQ=0x%x", asc, ascq);
			printk("<<vendor>> ASC=0x%x ASCQ=0x%x", asc,
			       ascq);
		if (ascq >= 0x80)
		if (ascq >= 0x80)
			printk("ASC=0x%x <<vendor>> ASCQ=0x%x", asc, ascq);
			printk("ASC=0x%x <<vendor>> ASCQ=0x%x", asc,
			       ascq);
		else
		else
			printk("ASC=0x%x ASCQ=0x%x", asc, ascq);
			printk("ASC=0x%x ASCQ=0x%x", asc, ascq);
	}
	}
	printk("\n");
}
}
EXPORT_SYMBOL(scsi_show_extd_sense);
void
void
scsi_print_sense_hdr(const char *name, struct scsi_sense_hdr *sshdr)
scsi_show_sense_hdr(struct scsi_sense_hdr *sshdr)
{
{
	const char *sense_txt;
	const char *sense_txt;
	/* An example of deferred is when an earlier write to disk cache
	 * succeeded, but now the disk discovers that it cannot write the
	 * data to the magnetic media.
	 */
	const char *error = scsi_sense_is_deferred(sshdr) ? 
		"<<DEFERRED>>" : "Current";
	printk(KERN_INFO "%s: %s", name, error);
	if (sshdr->response_code >= 0x72)
		printk(" [descriptor]");
	sense_txt = scsi_sense_key_string(sshdr->sense_key);
	sense_txt = scsi_sense_key_string(sshdr->sense_key);
	if (sense_txt)
	if (sense_txt)
		printk(": sense key: %s\n", sense_txt);
		printk("Sense Key : %s ", sense_txt);
	else
	else
		printk(": sense key=0x%x\n", sshdr->sense_key);
		printk("Sense Key : 0x%x ", sshdr->sense_key);
	printk(KERN_INFO "    ");
	scsi_show_extd_sense(sshdr->asc, sshdr->ascq);
	printk("%s", scsi_sense_is_deferred(sshdr) ? "[deferred] " :
	       "[current] ");
	if (sshdr->response_code >= 0x72)
		printk("[descriptor]");
	printk("\n");
	printk("\n");
}
}
EXPORT_SYMBOL(scsi_show_sense_hdr);
/*
 * Print normalized SCSI sense header with a prefix.
 */
void
scsi_print_sense_hdr(const char *name, struct scsi_sense_hdr *sshdr)
{
	printk(KERN_INFO "%s: ", name);
	scsi_show_sense_hdr(sshdr);
	printk(KERN_INFO "%s: ", name);
	scsi_show_extd_sense(sshdr->asc, sshdr->ascq);
}
EXPORT_SYMBOL(scsi_print_sense_hdr);
EXPORT_SYMBOL(scsi_print_sense_hdr);
/* Print sense information */
void
void
__scsi_print_sense(const char *name, const unsigned char *sense_buffer,
scsi_decode_sense_buffer(const unsigned char *sense_buffer, int sense_len,
		   int sense_len)
		       struct scsi_sense_hdr *sshdr)
{
{
	int k, num, res;
	int k, num, res;
	unsigned int info;
	struct scsi_sense_hdr ssh;
    
    
	res = scsi_normalize_sense(sense_buffer, sense_len, &ssh);
	res = scsi_normalize_sense(sense_buffer, sense_len, sshdr);
	if (0 == res) {
	if (0 == res) {
		/* this may be SCSI-1 sense data */
		/* this may be SCSI-1 sense data */
		num = (sense_len < 32) ? sense_len : 32;
		num = (sense_len < 32) ? sense_len : 32;
		printk(KERN_INFO "Unrecognized sense data (in hex):");
		printk("Unrecognized sense data (in hex):");
		for (k = 0; k < num; ++k) {
		for (k = 0; k < num; ++k) {
			if (0 == (k % 16)) {
			if (0 == (k % 16)) {
				printk("\n");
				printk("\n");
 Lines 1247-1257   __scsi_print_sense(const char *name, const unsigned char *sense_buffer, Link Here 
		printk("\n");
		printk("\n");
		return;
		return;
	}
	}
	scsi_print_sense_hdr(name, &ssh);
}
	if (ssh.response_code < 0x72) {
void
scsi_decode_sense_extras(const unsigned char *sense_buffer, int sense_len,
			 struct scsi_sense_hdr *sshdr)
{
	int k, num, res;
	if (sshdr->response_code < 0x72)
	{
		/* only decode extras for "fixed" format now */
		/* only decode extras for "fixed" format now */
		char buff[80];
		char buff[80];
		int blen, fixed_valid;
		int blen, fixed_valid;
		unsigned int info;
		fixed_valid = sense_buffer[0] & 0x80;
		fixed_valid = sense_buffer[0] & 0x80;
		info = ((sense_buffer[3] << 24) | (sense_buffer[4] << 16) |
		info = ((sense_buffer[3] << 24) | (sense_buffer[4] << 16) |
 Lines 1281-1293   __scsi_print_sense(const char *name, const unsigned char *sense_buffer, Link Here 
			res += snprintf(buff + res, blen - res, "ILI");
			res += snprintf(buff + res, blen - res, "ILI");
		}
		}
		if (res > 0)
		if (res > 0)
			printk(KERN_INFO "%s\n", buff);
			printk("%s\n", buff);
	} else if (ssh.additional_length > 0) {
	} else if (sshdr->additional_length > 0) {
		/* descriptor format with sense descriptors */
		/* descriptor format with sense descriptors */
		num = 8 + ssh.additional_length;
		num = 8 + sshdr->additional_length;
		num = (sense_len < num) ? sense_len : num;
		num = (sense_len < num) ? sense_len : num;
		printk(KERN_INFO "Descriptor sense data with sense "
		printk("Descriptor sense data with sense descriptors "
		       "descriptors (in hex):");
		       "(in hex):");
		for (k = 0; k < num; ++k) {
		for (k = 0; k < num; ++k) {
			if (0 == (k % 16)) {
			if (0 == (k % 16)) {
				printk("\n");
				printk("\n");
 Lines 1295-1323   __scsi_print_sense(const char *name, const unsigned char *sense_buffer, Link Here 
			}
			}
			printk("%02x ", sense_buffer[k]);
			printk("%02x ", sense_buffer[k]);
		}
		}
		printk("\n");
		printk("\n");
	}
	}
}
}
EXPORT_SYMBOL(__scsi_print_sense);
void scsi_print_sense(const char *devclass, struct scsi_cmnd *cmd)
/* Normalize and print sense buffer with name prefix */
void __scsi_print_sense(const char *name, const unsigned char *sense_buffer,
			int sense_len)
{
{
	const char *name = devclass;
	struct scsi_sense_hdr sshdr;
	if (cmd->request->rq_disk)
	printk(KERN_INFO "%s: ", name);
		name = cmd->request->rq_disk->disk_name;
	scsi_decode_sense_buffer(sense_buffer, sense_len, &sshdr);
	__scsi_print_sense(name, cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE);
	scsi_show_sense_hdr(&sshdr);
	scsi_decode_sense_extras(sense_buffer, sense_len, &sshdr);
	printk(KERN_INFO "%s: ", name);
	scsi_show_extd_sense(sshdr.asc, sshdr.ascq);
}
}
EXPORT_SYMBOL(scsi_print_sense);
EXPORT_SYMBOL(__scsi_print_sense);
void scsi_print_command(struct scsi_cmnd *cmd)
/* Normalize and print sense buffer in SCSI command */
void scsi_print_sense(char *name, struct scsi_cmnd *cmd)
{
{
	/* Assume appended output (i.e. not at start of line) */
	struct scsi_sense_hdr sshdr;
	sdev_printk("", cmd->device, "\n");
	printk(KERN_INFO "        command: ");
	scmd_printk(KERN_INFO, cmd, "");
	scsi_print_cdb(cmd->cmnd, cmd->cmd_len, 0);
	scsi_decode_sense_buffer(cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE,
				 &sshdr);
	scsi_show_sense_hdr(&sshdr);
	scsi_decode_sense_extras(cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE,
				 &sshdr);
	scmd_printk(KERN_INFO, cmd, "");
	scsi_show_extd_sense(sshdr.asc, sshdr.ascq);
}
}
EXPORT_SYMBOL(scsi_print_command);
EXPORT_SYMBOL(scsi_print_sense);
#ifdef CONFIG_SCSI_CONSTANTS
#ifdef CONFIG_SCSI_CONSTANTS
 Lines 1327-1351   static const char * const hostbyte_table[]={ Link Here 
"DID_PASSTHROUGH", "DID_SOFT_ERROR", "DID_IMM_RETRY"};
"DID_PASSTHROUGH", "DID_SOFT_ERROR", "DID_IMM_RETRY"};
#define NUM_HOSTBYTE_STRS ARRAY_SIZE(hostbyte_table)
#define NUM_HOSTBYTE_STRS ARRAY_SIZE(hostbyte_table)
void scsi_print_hostbyte(int scsiresult)
{
	int hb = host_byte(scsiresult);
	printk("Hostbyte=0x%02x", hb);
	if (hb < NUM_HOSTBYTE_STRS)
		printk("(%s) ", hostbyte_table[hb]);
	else
		printk("is invalid ");
}
#else
void scsi_print_hostbyte(int scsiresult)
{
	printk("Hostbyte=0x%02x ", host_byte(scsiresult));
}
#endif
#ifdef CONFIG_SCSI_CONSTANTS
static const char * const driverbyte_table[]={
static const char * const driverbyte_table[]={
"DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT",  "DRIVER_MEDIA", "DRIVER_ERROR",
"DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT",  "DRIVER_MEDIA", "DRIVER_ERROR",
"DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD", "DRIVER_SENSE"};
"DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD", "DRIVER_SENSE"};
 Lines 1356-1374   static const char * const driversuggest_table[]={"SUGGEST_OK", Link Here 
"SUGGEST_5", "SUGGEST_6", "SUGGEST_7", "SUGGEST_SENSE"};
"SUGGEST_5", "SUGGEST_6", "SUGGEST_7", "SUGGEST_SENSE"};
#define NUM_SUGGEST_STRS ARRAY_SIZE(driversuggest_table)
#define NUM_SUGGEST_STRS ARRAY_SIZE(driversuggest_table)
void scsi_print_driverbyte(int scsiresult)
void scsi_show_result(int result)
{
{
	int dr = (driver_byte(scsiresult) & DRIVER_MASK);
	int hb = host_byte(result);
	int su = ((driver_byte(scsiresult) & SUGGEST_MASK) >> 4);
	int db = (driver_byte(result) & DRIVER_MASK);
	int su = ((driver_byte(result) & SUGGEST_MASK) >> 4);
	printk("Driverbyte=0x%02x ", driver_byte(scsiresult));
	printk("Result: hostbyte=%s driverbyte=%s,%s\n",
	printk("(%s,%s) ",
	       (hb < NUM_HOSTBYTE_STRS ? hostbyte_table[hb]     : "invalid"),
	       (dr < NUM_DRIVERBYTE_STRS ? driverbyte_table[dr] : "invalid"),
	       (db < NUM_DRIVERBYTE_STRS ? driverbyte_table[db] : "invalid"),
	       (su < NUM_SUGGEST_STRS ? driversuggest_table[su] : "invalid"));
	       (su < NUM_SUGGEST_STRS ? driversuggest_table[su] : "invalid"));
}
}
#else
#else
void scsi_print_driverbyte(int scsiresult)
void scsi_show_result(int result)
{
{
	printk("Driverbyte=0x%02x ", driver_byte(scsiresult));
	printk("Result: hostbyte=0x%02x driverbyte=0x%02x\n",
	       host_byte(result), driver_byte(result));
}
}
#endif
#endif
EXPORT_SYMBOL(scsi_show_result);
void scsi_print_result(struct scsi_cmnd *cmd)
{
	scmd_printk(KERN_INFO, cmd, "");
	scsi_show_result(cmd->result);
}
EXPORT_SYMBOL(scsi_print_result);
(-) a/include/scsi/scsi_dbg.h (-4 / +6 lines)
 Lines 5-18   struct scsi_cmnd; Link Here 
struct scsi_sense_hdr;
struct scsi_sense_hdr;
extern void scsi_print_command(struct scsi_cmnd *);
extern void scsi_print_command(struct scsi_cmnd *);
extern void scsi_print_sense_hdr(const char *, struct scsi_sense_hdr *);
extern void __scsi_print_command(unsigned char *);
extern void __scsi_print_command(unsigned char *);
extern void scsi_print_sense(const char *, struct scsi_cmnd *);
extern void scsi_show_extd_sense(unsigned char, unsigned char);
extern void scsi_show_sense_hdr(struct scsi_sense_hdr *);
extern void scsi_print_sense_hdr(const char *, struct scsi_sense_hdr *);
extern void scsi_print_sense(char *, struct scsi_cmnd *);
extern void __scsi_print_sense(const char *name,
extern void __scsi_print_sense(const char *name,
			       const unsigned char *sense_buffer,
			       const unsigned char *sense_buffer,
			       int sense_len);
			       int sense_len);
extern void scsi_print_driverbyte(int);
extern void scsi_show_result(int);
extern void scsi_print_hostbyte(int);
extern void scsi_print_result(struct scsi_cmnd *);
extern void scsi_print_status(unsigned char);
extern void scsi_print_status(unsigned char);
extern const char *scsi_sense_key_string(unsigned char);
extern const char *scsi_sense_key_string(unsigned char);
extern const char *scsi_extd_sense_format(unsigned char, unsigned char);
extern const char *scsi_extd_sense_format(unsigned char, unsigned char);
- Define sd_printk(), sd_print_sense_hdr() and sd_print_result()
- Define sd_printk(), sd_print_sense_hdr() and sd_print_result()
- Move relevant header bits into sd.h
- Move relevant header bits into sd.h
- Remove all the legacy disk_name passing and use scsi_disk pointers
- Remove all the legacy disk_name passing and use scsi_disk pointers
  where possible
  where possible
- Switch printk() lines to the new sd_ functions so that output is
- Switch printk() lines to the new sd_ functions so that output is
  consistent
  consistent
(-) a/drivers/scsi/sd.c (-158 / +95 lines)
 Lines 58-73    Link Here 
#include <scsi/scsi_host.h>
#include <scsi/scsi_host.h>
#include <scsi/scsi_ioctl.h>
#include <scsi/scsi_ioctl.h>
#include <scsi/scsicam.h>
#include <scsi/scsicam.h>
#include <scsi/sd.h>
#include "scsi_logging.h"
#include "scsi_logging.h"
/*
 * More than enough for everybody ;)  The huge number of majors
 * is a leftover from 16bit dev_t days, we don't really need that
 * much numberspace.
 */
#define SD_MAJORS	16
MODULE_AUTHOR("Eric Youngdale");
MODULE_AUTHOR("Eric Youngdale");
MODULE_DESCRIPTION("SCSI disk (sd) driver");
MODULE_DESCRIPTION("SCSI disk (sd) driver");
MODULE_LICENSE("GPL");
MODULE_LICENSE("GPL");
 Lines 89-133   MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_DISK13_MAJOR); Link Here 
MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_DISK14_MAJOR);
MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_DISK14_MAJOR);
MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_DISK15_MAJOR);
MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_DISK15_MAJOR);
/*
 * This is limited by the naming scheme enforced in sd_probe,
 * add another character to it if you really need more disks.
 */
#define SD_MAX_DISKS	(((26 * 26) + 26 + 1) * 26)
/*
 * Time out in seconds for disks and Magneto-opticals (which are slower).
 */
#define SD_TIMEOUT		(30 * HZ)
#define SD_MOD_TIMEOUT		(75 * HZ)
/*
 * Number of allowed retries
 */
#define SD_MAX_RETRIES		5
#define SD_PASSTHROUGH_RETRIES	1
/*
 * Size of the initial data buffer for mode and read capacity data
 */
#define SD_BUF_SIZE		512
struct scsi_disk {
	struct scsi_driver *driver;	/* always &sd_template */
	struct scsi_device *device;
	struct class_device cdev;
	struct gendisk	*disk;
	unsigned int	openers;	/* protected by BKL for now, yuck */
	sector_t	capacity;	/* size in 512-byte sectors */
	u32		index;
	u8		media_present;
	u8		write_prot;
	unsigned	WCE : 1;	/* state of disk WCE bit */
	unsigned	RCD : 1;	/* state of disk RCD bit, unused */
	unsigned	DPOFUA : 1;	/* state of disk DPOFUA bit */
};
#define to_scsi_disk(obj) container_of(obj,struct scsi_disk,cdev)
static DEFINE_IDR(sd_index_idr);
static DEFINE_IDR(sd_index_idr);
static DEFINE_SPINLOCK(sd_index_lock);
static DEFINE_SPINLOCK(sd_index_lock);
 Lines 136-155   static DEFINE_SPINLOCK(sd_index_lock); Link Here 
 * object after last put) */
 * object after last put) */
static DEFINE_MUTEX(sd_ref_mutex);
static DEFINE_MUTEX(sd_ref_mutex);
static int sd_revalidate_disk(struct gendisk *disk);
static void sd_rw_intr(struct scsi_cmnd * SCpnt);
static int sd_probe(struct device *);
static int sd_remove(struct device *);
static void sd_shutdown(struct device *dev);
static void sd_rescan(struct device *);
static int sd_init_command(struct scsi_cmnd *);
static int sd_issue_flush(struct device *, sector_t *);
static void sd_prepare_flush(request_queue_t *, struct request *);
static void sd_read_capacity(struct scsi_disk *sdkp, char *diskname,
			     unsigned char *buffer);
static void scsi_disk_release(struct class_device *cdev);
static const char *sd_cache_types[] = {
static const char *sd_cache_types[] = {
	"write through", "none", "write back",
	"write through", "none", "write back",
	"write back, no read (daft)"
	"write back, no read (daft)"
 Lines 199-205   static ssize_t sd_store_cache_type(struct class_device *cdev, const char *buf, Link Here 
	if (scsi_mode_select(sdp, 1, sp, 8, buffer_data, len, SD_TIMEOUT,
	if (scsi_mode_select(sdp, 1, sp, 8, buffer_data, len, SD_TIMEOUT,
			     SD_MAX_RETRIES, &data, &sshdr)) {
			     SD_MAX_RETRIES, &data, &sshdr)) {
		if (scsi_sense_valid(&sshdr))
		if (scsi_sense_valid(&sshdr))
			scsi_print_sense_hdr(sdkp->disk->disk_name, &sshdr);
			sd_print_sense_hdr(sdkp, &sshdr);
		return -EINVAL;
		return -EINVAL;
	}
	}
	sd_revalidate_disk(sdkp->disk);
	sd_revalidate_disk(sdkp->disk);
 Lines 407-413   static int sd_init_command(struct scsi_cmnd * SCpnt) Link Here 
	 */
	 */
	if (sdp->sector_size == 1024) {
	if (sdp->sector_size == 1024) {
		if ((block & 1) || (rq->nr_sectors & 1)) {
		if ((block & 1) || (rq->nr_sectors & 1)) {
			printk(KERN_ERR "sd: Bad block number requested");
			scmd_printk(KERN_ERR, SCpnt,
				    "Bad block number requested\n");
			return 0;
			return 0;
		} else {
		} else {
			block = block >> 1;
			block = block >> 1;
 Lines 416-422   static int sd_init_command(struct scsi_cmnd * SCpnt) Link Here 
	}
	}
	if (sdp->sector_size == 2048) {
	if (sdp->sector_size == 2048) {
		if ((block & 3) || (rq->nr_sectors & 3)) {
		if ((block & 3) || (rq->nr_sectors & 3)) {
			printk(KERN_ERR "sd: Bad block number requested");
			scmd_printk(KERN_ERR, SCpnt,
				    "Bad block number requested\n");
			return 0;
			return 0;
		} else {
		} else {
			block = block >> 2;
			block = block >> 2;
 Lines 425-431   static int sd_init_command(struct scsi_cmnd * SCpnt) Link Here 
	}
	}
	if (sdp->sector_size == 4096) {
	if (sdp->sector_size == 4096) {
		if ((block & 7) || (rq->nr_sectors & 7)) {
		if ((block & 7) || (rq->nr_sectors & 7)) {
			printk(KERN_ERR "sd: Bad block number requested");
			scmd_printk(KERN_ERR, SCpnt,
				    "Bad block number requested\n");
			return 0;
			return 0;
		} else {
		} else {
			block = block >> 3;
			block = block >> 3;
 Lines 442-448   static int sd_init_command(struct scsi_cmnd * SCpnt) Link Here 
		SCpnt->cmnd[0] = READ_6;
		SCpnt->cmnd[0] = READ_6;
		SCpnt->sc_data_direction = DMA_FROM_DEVICE;
		SCpnt->sc_data_direction = DMA_FROM_DEVICE;
	} else {
	} else {
		printk(KERN_ERR "sd: Unknown command %x\n", rq->cmd_flags);
		scmd_printk(KERN_ERR, SCpnt, "Unknown command %x\n", rq->cmd_flags);
		return 0;
		return 0;
	}
	}
 Lines 490-496   static int sd_init_command(struct scsi_cmnd * SCpnt) Link Here 
			 * during operation and thus turned off
			 * during operation and thus turned off
			 * use_10_for_rw.
			 * use_10_for_rw.
			 */
			 */
			printk(KERN_ERR "sd: FUA write on READ/WRITE(6) drive\n");
			scmd_printk(KERN_ERR, SCpnt,
				    "FUA write on READ/WRITE(6) drive\n");
			return 0;
			return 0;
		}
		}
 Lines 786-794   not_present: Link Here 
	return 1;
	return 1;
}
}
static int sd_sync_cache(struct scsi_device *sdp)
static int sd_sync_cache(struct scsi_disk *sdkp)
{
{
	int retries, res;
	int retries, res;
	struct scsi_device *sdp = sdkp->device;
	struct scsi_sense_hdr sshdr;
	struct scsi_sense_hdr sshdr;
	if (!scsi_device_online(sdp))
	if (!scsi_device_online(sdp))
 Lines 809-820   static int sd_sync_cache(struct scsi_device *sdp) Link Here 
			break;
			break;
	}
	}
	if (res) {		printk(KERN_WARNING "FAILED\n  status = %x, message = %02x, "
	if (res) {
				    "host = %d, driver = %02x\n  ",
		sd_print_result(sdkp, res);
				    status_byte(res), msg_byte(res),
		if (driver_byte(res) & DRIVER_SENSE)
				    host_byte(res), driver_byte(res));
			sd_print_sense_hdr(sdkp, &sshdr);
			if (driver_byte(res) & DRIVER_SENSE)
				scsi_print_sense_hdr("sd", &sshdr);
	}
	}
	return res;
	return res;
 Lines 823-836   static int sd_sync_cache(struct scsi_device *sdp) Link Here 
static int sd_issue_flush(struct device *dev, sector_t *error_sector)
static int sd_issue_flush(struct device *dev, sector_t *error_sector)
{
{
	int ret = 0;
	int ret = 0;
	struct scsi_device *sdp = to_scsi_device(dev);
	struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev);
	struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev);
	if (!sdkp)
	if (!sdkp)
               return -ENODEV;
               return -ENODEV;
	if (sdkp->WCE)
	if (sdkp->WCE)
		ret = sd_sync_cache(sdp);
		ret = sd_sync_cache(sdkp);
	scsi_disk_put(sdkp);
	scsi_disk_put(sdkp);
	return ret;
	return ret;
}
}
 Lines 1025-1031   static int media_not_present(struct scsi_disk *sdkp, Link Here 
 * spinup disk - called only in sd_revalidate_disk()
 * spinup disk - called only in sd_revalidate_disk()
 */
 */
static void
static void
sd_spinup_disk(struct scsi_disk *sdkp, char *diskname)
sd_spinup_disk(struct scsi_disk *sdkp)
{
{
	unsigned char cmd[10];
	unsigned char cmd[10];
	unsigned long spintime_expire = 0;
	unsigned long spintime_expire = 0;
 Lines 1069-1077   sd_spinup_disk(struct scsi_disk *sdkp, char *diskname) Link Here 
		if ((driver_byte(the_result) & DRIVER_SENSE) == 0) {
		if ((driver_byte(the_result) & DRIVER_SENSE) == 0) {
			/* no sense, TUR either succeeded or failed
			/* no sense, TUR either succeeded or failed
			 * with a status error */
			 * with a status error */
			if(!spintime && !scsi_status_is_good(the_result))
			if(!spintime && !scsi_status_is_good(the_result)) {
				printk(KERN_NOTICE "%s: Unit Not Ready, "
				sd_printk(KERN_NOTICE, sdkp, "Unit Not Ready\n");
				       "error = 0x%x\n", diskname, the_result);
				sd_print_result(sdkp, the_result);
			}
			break;
			break;
		}
		}
					
					
 Lines 1096-1103   sd_spinup_disk(struct scsi_disk *sdkp, char *diskname) Link Here 
		 */
		 */
		} else if (sense_valid && sshdr.sense_key == NOT_READY) {
		} else if (sense_valid && sshdr.sense_key == NOT_READY) {
			if (!spintime) {
			if (!spintime) {
				printk(KERN_NOTICE "%s: Spinning up disk...",
				sd_printk(KERN_NOTICE, sdkp, "Spinning up disk...");
				       diskname);
				cmd[0] = START_STOP;
				cmd[0] = START_STOP;
				cmd[1] = 1;	/* Return immediately */
				cmd[1] = 1;	/* Return immediately */
				memset((void *) &cmd[2], 0, 8);
				memset((void *) &cmd[2], 0, 8);
 Lines 1130-1138   sd_spinup_disk(struct scsi_disk *sdkp, char *diskname) Link Here 
			/* we don't understand the sense code, so it's
			/* we don't understand the sense code, so it's
			 * probably pointless to loop */
			 * probably pointless to loop */
			if(!spintime) {
			if(!spintime) {
				printk(KERN_NOTICE "%s: Unit Not Ready, "
				sd_printk(KERN_NOTICE, sdkp, "Unit Not Ready\n");
					"sense:\n", diskname);
				sd_print_sense_hdr(sdkp, &sshdr);
				scsi_print_sense_hdr("", &sshdr);
			}
			}
			break;
			break;
		}
		}
 Lines 1151-1158   sd_spinup_disk(struct scsi_disk *sdkp, char *diskname) Link Here 
 * read disk capacity
 * read disk capacity
 */
 */
static void
static void
sd_read_capacity(struct scsi_disk *sdkp, char *diskname,
sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer)
		 unsigned char *buffer)
{
{
	unsigned char cmd[16];
	unsigned char cmd[16];
	int the_result, retries;
	int the_result, retries;
 Lines 1191-1208   repeat: Link Here 
	} while (the_result && retries);
	} while (the_result && retries);
	if (the_result && !longrc) {
	if (the_result && !longrc) {
		printk(KERN_NOTICE "%s : READ CAPACITY failed.\n"
		sd_printk(KERN_NOTICE, sdkp, "READ CAPACITY failed\n");
		       "%s : status=%x, message=%02x, host=%d, driver=%02x \n",
		sd_print_result(sdkp, the_result);
		       diskname, diskname,
		       status_byte(the_result),
		       msg_byte(the_result),
		       host_byte(the_result),
		       driver_byte(the_result));
		if (driver_byte(the_result) & DRIVER_SENSE)
		if (driver_byte(the_result) & DRIVER_SENSE)
			scsi_print_sense_hdr("sd", &sshdr);
			sd_print_sense_hdr(sdkp, &sshdr);
		else
		else
			printk("%s : sense not available. \n", diskname);
			sd_printk(KERN_NOTICE, sdkp, "Sense not available.\n");
		/* Set dirty bit for removable devices if not ready -
		/* Set dirty bit for removable devices if not ready -
		 * sometimes drives will not report this properly. */
		 * sometimes drives will not report this properly. */
 Lines 1218-1233   repeat: Link Here 
		return;
		return;
	} else if (the_result && longrc) {
	} else if (the_result && longrc) {
		/* READ CAPACITY(16) has been failed */
		/* READ CAPACITY(16) has been failed */
		printk(KERN_NOTICE "%s : READ CAPACITY(16) failed.\n"
		sd_printk(KERN_NOTICE, sdkp, "READ CAPACITY(16) failed\n");
		       "%s : status=%x, message=%02x, host=%d, driver=%02x \n",
		sd_print_result(sdkp, the_result);
		       diskname, diskname,
		sd_printk(KERN_NOTICE, sdkp, "Use 0xffffffff as device size\n");
		       status_byte(the_result),
		       msg_byte(the_result),
		       host_byte(the_result),
		       driver_byte(the_result));
		printk(KERN_NOTICE "%s : use 0xffffffff as device size\n",
		       diskname);
		
		sdkp->capacity = 1 + (sector_t) 0xffffffff;		
		sdkp->capacity = 1 + (sector_t) 0xffffffff;		
		goto got_data;
		goto got_data;
	}	
	}	
 Lines 1238-1251   repeat: Link Here 
		if (buffer[0] == 0xff && buffer[1] == 0xff &&
		if (buffer[0] == 0xff && buffer[1] == 0xff &&
		    buffer[2] == 0xff && buffer[3] == 0xff) {
		    buffer[2] == 0xff && buffer[3] == 0xff) {
			if(sizeof(sdkp->capacity) > 4) {
			if(sizeof(sdkp->capacity) > 4) {
				printk(KERN_NOTICE "%s : very big device. try to use"
				sd_printk(KERN_NOTICE, sdkp, "Very big device. "
				       " READ CAPACITY(16).\n", diskname);
					  "Trying to use READ CAPACITY(16).\n");
				longrc = 1;
				longrc = 1;
				goto repeat;
				goto repeat;
			}
			}
			printk(KERN_ERR "%s: too big for this kernel.  Use a "
			sd_printk(KERN_ERR, sdkp, "Too big for this kernel. Use "
			       "kernel compiled with support for large block "
				  "a kernel compiled with support for large "
			       "devices.\n", diskname);
				  "block devices.\n");
			sdkp->capacity = 0;
			sdkp->capacity = 0;
			goto got_data;
			goto got_data;
		}
		}
 Lines 1284-1291   repeat: Link Here 
got_data:
got_data:
	if (sector_size == 0) {
	if (sector_size == 0) {
		sector_size = 512;
		sector_size = 512;
		printk(KERN_NOTICE "%s : sector size 0 reported, "
		sd_printk(KERN_NOTICE, sdkp, "Sector size 0 reported, "
		       "assuming 512.\n", diskname);
			  "assuming 512.\n");
	}
	}
	if (sector_size != 512 &&
	if (sector_size != 512 &&
 Lines 1293-1300   got_data: Link Here 
	    sector_size != 2048 &&
	    sector_size != 2048 &&
	    sector_size != 4096 &&
	    sector_size != 4096 &&
	    sector_size != 256) {
	    sector_size != 256) {
		printk(KERN_NOTICE "%s : unsupported sector size "
		sd_printk(KERN_NOTICE, sdkp, "Unsupported sector size %d.\n",
		       "%d.\n", diskname, sector_size);
			  sector_size);
		/*
		/*
		 * The user might want to re-format the drive with
		 * The user might want to re-format the drive with
		 * a supported sectorsize.  Once this happens, it
		 * a supported sectorsize.  Once this happens, it
 Lines 1327-1336   got_data: Link Here 
		mb -= sz - 974;
		mb -= sz - 974;
		sector_div(mb, 1950);
		sector_div(mb, 1950);
		printk(KERN_NOTICE "SCSI device %s: "
		sd_printk(KERN_NOTICE, sdkp,
		       "%llu %d-byte hdwr sectors (%llu MB)\n",
			  "%llu %d-byte hardware sectors (%llu MB)\n",
		       diskname, (unsigned long long)sdkp->capacity,
			  (unsigned long long)sdkp->capacity,
		       hard_sector, (unsigned long long)mb);
			  hard_sector, (unsigned long long)mb);
	}
	}
	/* Rescale capacity to 512-byte units */
	/* Rescale capacity to 512-byte units */
 Lines 1362-1369   sd_do_mode_sense(struct scsi_device *sdp, int dbd, int modepage, Link Here 
 * called with buffer of length SD_BUF_SIZE
 * called with buffer of length SD_BUF_SIZE
 */
 */
static void
static void
sd_read_write_protect_flag(struct scsi_disk *sdkp, char *diskname,
sd_read_write_protect_flag(struct scsi_disk *sdkp, unsigned char *buffer)
			   unsigned char *buffer)
{
{
	int res;
	int res;
	struct scsi_device *sdp = sdkp->device;
	struct scsi_device *sdp = sdkp->device;
 Lines 1371-1377   sd_read_write_protect_flag(struct scsi_disk *sdkp, char *diskname, Link Here 
	set_disk_ro(sdkp->disk, 0);
	set_disk_ro(sdkp->disk, 0);
	if (sdp->skip_ms_page_3f) {
	if (sdp->skip_ms_page_3f) {
		printk(KERN_NOTICE "%s: assuming Write Enabled\n", diskname);
		sd_printk(KERN_NOTICE, sdkp, "Assuming Write Enabled\n");
		return;
		return;
	}
	}
 Lines 1403-1417   sd_read_write_protect_flag(struct scsi_disk *sdkp, char *diskname, Link Here 
	}
	}
	if (!scsi_status_is_good(res)) {
	if (!scsi_status_is_good(res)) {
		printk(KERN_WARNING
		sd_printk(KERN_WARNING, sdkp,
		       "%s: test WP failed, assume Write Enabled\n", diskname);
			  "Test WP failed, assume Write Enabled\n");
	} else {
	} else {
		sdkp->write_prot = ((data.device_specific & 0x80) != 0);
		sdkp->write_prot = ((data.device_specific & 0x80) != 0);
		set_disk_ro(sdkp->disk, sdkp->write_prot);
		set_disk_ro(sdkp->disk, sdkp->write_prot);
		printk(KERN_NOTICE "%s: Write Protect is %s\n", diskname,
		sd_printk(KERN_NOTICE, sdkp, "Write Protect is %s\n",
		       sdkp->write_prot ? "on" : "off");
			  sdkp->write_prot ? "on" : "off");
		printk(KERN_DEBUG "%s: Mode Sense: %02x %02x %02x %02x\n",
		sd_printk(KERN_DEBUG, sdkp,
		       diskname, buffer[0], buffer[1], buffer[2], buffer[3]);
			  "Mode Sense: %02x %02x %02x %02x\n",
			  buffer[0], buffer[1], buffer[2], buffer[3]);
	}
	}
}
}
 Lines 1420-1427   sd_read_write_protect_flag(struct scsi_disk *sdkp, char *diskname, Link Here 
 * called with buffer of length SD_BUF_SIZE
 * called with buffer of length SD_BUF_SIZE
 */
 */
static void
static void
sd_read_cache_type(struct scsi_disk *sdkp, char *diskname,
sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer)
		   unsigned char *buffer)
{
{
	int len = 0, res;
	int len = 0, res;
	struct scsi_device *sdp = sdkp->device;
	struct scsi_device *sdp = sdkp->device;
 Lines 1450-1457   sd_read_cache_type(struct scsi_disk *sdkp, char *diskname, Link Here 
	if (!data.header_length) {
	if (!data.header_length) {
		modepage = 6;
		modepage = 6;
		printk(KERN_ERR "%s: missing header in MODE_SENSE response\n",
		sd_printk(KERN_ERR, sdkp, "Missing header in MODE_SENSE response\n");
		       diskname);
	}
	}
	/* that went OK, now ask for the proper length */
	/* that went OK, now ask for the proper length */
 Lines 1478-1490   sd_read_cache_type(struct scsi_disk *sdkp, char *diskname, Link Here 
		int offset = data.header_length + data.block_descriptor_length;
		int offset = data.header_length + data.block_descriptor_length;
		if (offset >= SD_BUF_SIZE - 2) {
		if (offset >= SD_BUF_SIZE - 2) {
			printk(KERN_ERR "%s: malformed MODE SENSE response",
			sd_printk(KERN_ERR, sdkp, "Malformed MODE SENSE response\n");
				diskname);
			goto defaults;
			goto defaults;
		}
		}
		if ((buffer[offset] & 0x3f) != modepage) {
		if ((buffer[offset] & 0x3f) != modepage) {
			printk(KERN_ERR "%s: got wrong page\n", diskname);
			sd_printk(KERN_ERR, sdkp, "Got wrong page\n");
			goto defaults;
			goto defaults;
		}
		}
 Lines 1498-1511   sd_read_cache_type(struct scsi_disk *sdkp, char *diskname, Link Here 
		sdkp->DPOFUA = (data.device_specific & 0x10) != 0;
		sdkp->DPOFUA = (data.device_specific & 0x10) != 0;
		if (sdkp->DPOFUA && !sdkp->device->use_10_for_rw) {
		if (sdkp->DPOFUA && !sdkp->device->use_10_for_rw) {
			printk(KERN_NOTICE "SCSI device %s: uses "
			sd_printk(KERN_NOTICE, sdkp,
			       "READ/WRITE(6), disabling FUA\n", diskname);
				  "Uses READ/WRITE(6), disabling FUA\n");
			sdkp->DPOFUA = 0;
			sdkp->DPOFUA = 0;
		}
		}
		printk(KERN_NOTICE "SCSI device %s: "
		sd_printk(KERN_NOTICE, sdkp,
		       "write cache: %s, read cache: %s, %s\n",
		       "Write cache: %s, read cache: %s, %s\n",
		       diskname,
		       sdkp->WCE ? "enabled" : "disabled",
		       sdkp->WCE ? "enabled" : "disabled",
		       sdkp->RCD ? "disabled" : "enabled",
		       sdkp->RCD ? "disabled" : "enabled",
		       sdkp->DPOFUA ? "supports DPO and FUA"
		       sdkp->DPOFUA ? "supports DPO and FUA"
 Lines 1518-1532   bad_sense: Link Here 
	if (scsi_sense_valid(&sshdr) &&
	if (scsi_sense_valid(&sshdr) &&
	    sshdr.sense_key == ILLEGAL_REQUEST &&
	    sshdr.sense_key == ILLEGAL_REQUEST &&
	    sshdr.asc == 0x24 && sshdr.ascq == 0x0)
	    sshdr.asc == 0x24 && sshdr.ascq == 0x0)
		printk(KERN_NOTICE "%s: cache data unavailable\n",
		/* Invalid field in CDB */
		       diskname);	/* Invalid field in CDB */
		sd_printk(KERN_NOTICE, sdkp, "Cache data unavailable\n");
	else
	else
		printk(KERN_ERR "%s: asking for cache data failed\n",
		sd_printk(KERN_ERR, sdkp, "Asking for cache data failed\n");
		       diskname);
defaults:
defaults:
	printk(KERN_ERR "%s: assuming drive cache: write through\n",
	sd_printk(KERN_ERR, sdkp, "Assuming drive cache: write through\n");
	       diskname);
	sdkp->WCE = 0;
	sdkp->WCE = 0;
	sdkp->RCD = 0;
	sdkp->RCD = 0;
	sdkp->DPOFUA = 0;
	sdkp->DPOFUA = 0;
 Lines 1555-1562   static int sd_revalidate_disk(struct gendisk *disk) Link Here 
	buffer = kmalloc(SD_BUF_SIZE, GFP_KERNEL | __GFP_DMA);
	buffer = kmalloc(SD_BUF_SIZE, GFP_KERNEL | __GFP_DMA);
	if (!buffer) {
	if (!buffer) {
		printk(KERN_WARNING "(sd_revalidate_disk:) Memory allocation "
		sd_printk(KERN_WARNING, sdkp, "sd_revalidate_disk: Memory "
		       "failure.\n");
			  "allocation failure.\n");
		goto out;
		goto out;
	}
	}
 Lines 1568-1583   static int sd_revalidate_disk(struct gendisk *disk) Link Here 
	sdkp->WCE = 0;
	sdkp->WCE = 0;
	sdkp->RCD = 0;
	sdkp->RCD = 0;
	sd_spinup_disk(sdkp, disk->disk_name);
	sd_spinup_disk(sdkp);
	/*
	/*
	 * Without media there is no reason to ask; moreover, some devices
	 * Without media there is no reason to ask; moreover, some devices
	 * react badly if we do.
	 * react badly if we do.
	 */
	 */
	if (sdkp->media_present) {
	if (sdkp->media_present) {
		sd_read_capacity(sdkp, disk->disk_name, buffer);
		sd_read_capacity(sdkp, buffer);
		sd_read_write_protect_flag(sdkp, disk->disk_name, buffer);
		sd_read_write_protect_flag(sdkp, buffer);
		sd_read_cache_type(sdkp, disk->disk_name, buffer);
		sd_read_cache_type(sdkp, buffer);
	}
	}
	/*
	/*
 Lines 1709-1716   static int sd_probe(struct device *dev) Link Here 
	dev_set_drvdata(dev, sdkp);
	dev_set_drvdata(dev, sdkp);
	add_disk(gd);
	add_disk(gd);
	sdev_printk(KERN_NOTICE, sdp, "Attached scsi %sdisk %s\n",
	sd_printk(KERN_NOTICE, sdkp, "Attached SCSI %sdisk\n",
		    sdp->removable ? "removable " : "", gd->disk_name);
		  sdp->removable ? "removable " : "");
	return 0;
	return 0;
 Lines 1781-1796   static void scsi_disk_release(struct class_device *cdev) Link Here 
 */
 */
static void sd_shutdown(struct device *dev)
static void sd_shutdown(struct device *dev)
{
{
	struct scsi_device *sdp = to_scsi_device(dev);
	struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev);
	struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev);
	if (!sdkp)
	if (!sdkp)
		return;         /* this can happen */
		return;         /* this can happen */
	if (sdkp->WCE) {
	if (sdkp->WCE) {
		printk(KERN_NOTICE "Synchronizing SCSI cache for disk %s: \n",
		sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n");
				sdkp->disk->disk_name);
		sd_sync_cache(sdkp);
		sd_sync_cache(sdp);
	}
	}
	scsi_disk_put(sdkp);
	scsi_disk_put(sdkp);
}
}
 Lines 1852-1854   static void __exit exit_sd(void) Link Here 
module_init(init_sd);
module_init(init_sd);
module_exit(exit_sd);
module_exit(exit_sd);
static void sd_print_sense_hdr(struct scsi_disk *sdkp,
			       struct scsi_sense_hdr *sshdr)
{
	sd_printk(KERN_INFO, sdkp, "");
	scsi_show_sense_hdr(sshdr);
	sd_printk(KERN_INFO, sdkp, "");
	scsi_show_extd_sense(sshdr->asc, sshdr->ascq);
}
static void sd_print_result(struct scsi_disk *sdkp, int result)
{
	sd_printk(KERN_INFO, sdkp, "");
	scsi_show_result(result);
}
(-) a/include/scsi/sd.h (+70 lines)
Line 0    Link Here 
#ifndef _SCSI_DISK_H
#define _SCSI_DISK_H
/*
 * More than enough for everybody ;)  The huge number of majors
 * is a leftover from 16bit dev_t days, we don't really need that
 * much numberspace.
 */
#define SD_MAJORS	16
/*
 * This is limited by the naming scheme enforced in sd_probe,
 * add another character to it if you really need more disks.
 */
#define SD_MAX_DISKS	(((26 * 26) + 26 + 1) * 26)
/*
 * Time out in seconds for disks and Magneto-opticals (which are slower).
 */
#define SD_TIMEOUT		(30 * HZ)
#define SD_MOD_TIMEOUT		(75 * HZ)
/*
 * Number of allowed retries
 */
#define SD_MAX_RETRIES		5
#define SD_PASSTHROUGH_RETRIES	1
/*
 * Size of the initial data buffer for mode and read capacity data
 */
#define SD_BUF_SIZE		512
struct scsi_disk {
	struct scsi_driver *driver;	/* always &sd_template */
	struct scsi_device *device;
	struct class_device cdev;
	struct gendisk	*disk;
	unsigned int	openers;	/* protected by BKL for now, yuck */
	sector_t	capacity;	/* size in 512-byte sectors */
	u32		index;
	u8		media_present;
	u8		write_prot;
	unsigned	WCE : 1;	/* state of disk WCE bit */
	unsigned	RCD : 1;	/* state of disk RCD bit, unused */
	unsigned	DPOFUA : 1;	/* state of disk DPOFUA bit */
};
#define to_scsi_disk(obj) container_of(obj,struct scsi_disk,cdev)
static int  sd_revalidate_disk(struct gendisk *disk);
static void sd_rw_intr(struct scsi_cmnd * SCpnt);
static int  sd_probe(struct device *);
static int  sd_remove(struct device *);
static void sd_shutdown(struct device *dev);
static void sd_rescan(struct device *);
static int  sd_init_command(struct scsi_cmnd *);
static int  sd_issue_flush(struct device *, sector_t *);
static void sd_prepare_flush(request_queue_t *, struct request *);
static void sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer);
static void scsi_disk_release(struct class_device *cdev);
static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *);
static void sd_print_result(struct scsi_disk *, int);
#define sd_printk(prefix, sdsk, fmt, a...)				\
        (sdsk)->disk ?							\
	sdev_printk(prefix, (sdsk)->device, "[%s] " fmt,		\
		    (sdsk)->disk->disk_name, ##a) :			\
	sdev_printk(prefix, (sdsk)->device, fmt, ##a)
#endif /* _SCSI_DISK_H */
(-) a/drivers/scsi/sd.c (-1 / +3 lines)
 Lines 766-772   static int sd_sync_cache(struct scsi_disk *sdkp) Link Here 
			sd_print_sense_hdr(sdkp, &sshdr);
			sd_print_sense_hdr(sdkp, &sshdr);
	}
	}
	return res;
	if (res)
		return -EIO;
	return 0;
}
}
static int sd_issue_flush(struct device *dev, sector_t *error_sector)
static int sd_issue_flush(struct device *dev, sector_t *error_sector)
(-) a/drivers/scsi/scsi_sysfs.c (-4 / +27 lines)
 Lines 278-283   static int scsi_bus_match(struct device *dev, struct device_driver *gendrv) Link Here 
static int scsi_bus_suspend(struct device * dev, pm_message_t state)
static int scsi_bus_suspend(struct device * dev, pm_message_t state)
{
{
	struct device_driver *drv = dev->driver;
	struct scsi_device *sdev = to_scsi_device(dev);
	struct scsi_device *sdev = to_scsi_device(dev);
	struct scsi_host_template *sht = sdev->host->hostt;
	struct scsi_host_template *sht = sdev->host->hostt;
	int err;
	int err;
 Lines 286-308   static int scsi_bus_suspend(struct device * dev, pm_message_t state) Link Here 
	if (err)
	if (err)
		return err;
		return err;
	if (sht->suspend)
	/* call HLD suspend first */
	if (drv && drv->suspend) {
		err = drv->suspend(dev, state);
		if (err)
			return err;
	}
	/* then, call host suspend */
	if (sht->suspend) {
		err = sht->suspend(sdev, state);
		err = sht->suspend(sdev, state);
		if (err) {
			if (drv && drv->resume)
				drv->resume(dev);
			return err;
		}
	}
	return err;
	return 0;
}
}
static int scsi_bus_resume(struct device * dev)
static int scsi_bus_resume(struct device * dev)
{
{
	struct device_driver *drv = dev->driver;
	struct scsi_device *sdev = to_scsi_device(dev);
	struct scsi_device *sdev = to_scsi_device(dev);
	struct scsi_host_template *sht = sdev->host->hostt;
	struct scsi_host_template *sht = sdev->host->hostt;
	int err = 0;
	int err = 0, err2 = 0;
	/* call host resume first */
	if (sht->resume)
	if (sht->resume)
		err = sht->resume(sdev);
		err = sht->resume(sdev);
	/* then, call HLD resume */
	if (drv && drv->resume)
		err2 = drv->resume(dev);
	scsi_device_resume(sdev);
	scsi_device_resume(sdev);
	return err;
	/* favor LLD failure */
	return err ? err : err2;;
}
}
struct bus_type scsi_bus_type = {
struct bus_type scsi_bus_type = {
(-) a/drivers/scsi/sd.c (+101 lines)
 Lines 147-152   static ssize_t sd_store_cache_type(struct class_device *cdev, const char *buf, Link Here 
	return count;
	return count;
}
}
static ssize_t sd_store_manage_start_stop(struct class_device *cdev,
					  const char *buf, size_t count)
{
	struct scsi_disk *sdkp = to_scsi_disk(cdev);
	struct scsi_device *sdp = sdkp->device;
	if (!capable(CAP_SYS_ADMIN))
		return -EACCES;
	sdp->manage_start_stop = simple_strtoul(buf, NULL, 10);
	return count;
}
static ssize_t sd_store_allow_restart(struct class_device *cdev, const char *buf,
static ssize_t sd_store_allow_restart(struct class_device *cdev, const char *buf,
				      size_t count)
				      size_t count)
{
{
 Lines 179-184   static ssize_t sd_show_fua(struct class_device *cdev, char *buf) Link Here 
	return snprintf(buf, 20, "%u\n", sdkp->DPOFUA);
	return snprintf(buf, 20, "%u\n", sdkp->DPOFUA);
}
}
static ssize_t sd_show_manage_start_stop(struct class_device *cdev, char *buf)
{
	struct scsi_disk *sdkp = to_scsi_disk(cdev);
	struct scsi_device *sdp = sdkp->device;
	return snprintf(buf, 20, "%u\n", sdp->manage_start_stop);
}
static ssize_t sd_show_allow_restart(struct class_device *cdev, char *buf)
static ssize_t sd_show_allow_restart(struct class_device *cdev, char *buf)
{
{
	struct scsi_disk *sdkp = to_scsi_disk(cdev);
	struct scsi_disk *sdkp = to_scsi_disk(cdev);
 Lines 192-197   static struct class_device_attribute sd_disk_attrs[] = { Link Here 
	__ATTR(FUA, S_IRUGO, sd_show_fua, NULL),
	__ATTR(FUA, S_IRUGO, sd_show_fua, NULL),
	__ATTR(allow_restart, S_IRUGO|S_IWUSR, sd_show_allow_restart,
	__ATTR(allow_restart, S_IRUGO|S_IWUSR, sd_show_allow_restart,
	       sd_store_allow_restart),
	       sd_store_allow_restart),
	__ATTR(manage_start_stop, S_IRUGO|S_IWUSR, sd_show_manage_start_stop,
	       sd_store_manage_start_stop),
	__ATTR_NULL,
	__ATTR_NULL,
};
};
 Lines 208-213   static struct scsi_driver sd_template = { Link Here 
		.name		= "sd",
		.name		= "sd",
		.probe		= sd_probe,
		.probe		= sd_probe,
		.remove		= sd_remove,
		.remove		= sd_remove,
		.suspend	= sd_suspend,
		.resume		= sd_resume,
		.shutdown	= sd_shutdown,
		.shutdown	= sd_shutdown,
	},
	},
	.rescan			= sd_rescan,
	.rescan			= sd_rescan,
 Lines 1707-1712   static void scsi_disk_release(struct class_device *cdev) Link Here 
	kfree(sdkp);
	kfree(sdkp);
}
}
static int sd_start_stop_device(struct scsi_device *sdp, int start)
{
	unsigned char cmd[6] = { START_STOP };	/* START_VALID */
	struct scsi_sense_hdr sshdr;
	int res;
	if (start)
		cmd[4] |= 1;	/* START */
	if (!scsi_device_online(sdp))
		return -ENODEV;
	res = scsi_execute_req(sdp, cmd, DMA_NONE, NULL, 0, &sshdr,
			       SD_TIMEOUT, SD_MAX_RETRIES);
	if (res) {
		printk(KERN_WARNING "FAILED\n  status = %x, message = %02x, "
		       "host = %d, driver = %02x\n  ",
		       status_byte(res), msg_byte(res),
		       host_byte(res), driver_byte(res));
		if (driver_byte(res) & DRIVER_SENSE)
			scsi_print_sense_hdr("sd", &sshdr);
	}
	return res;
}
/*
/*
 * Send a SYNCHRONIZE CACHE instruction down to the device through
 * Send a SYNCHRONIZE CACHE instruction down to the device through
 * the normal SCSI command structure.  Wait for the command to
 * the normal SCSI command structure.  Wait for the command to
 Lines 1714-1719   static void scsi_disk_release(struct class_device *cdev) Link Here 
 */
 */
static void sd_shutdown(struct device *dev)
static void sd_shutdown(struct device *dev)
{
{
	struct scsi_device *sdp = to_scsi_device(dev);
	struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev);
	struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev);
	if (!sdkp)
	if (!sdkp)
 Lines 1723-1731   static void sd_shutdown(struct device *dev) Link Here 
		sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n");
		sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n");
		sd_sync_cache(sdkp);
		sd_sync_cache(sdkp);
	}
	}
	if (system_state != SYSTEM_RESTART && sdp->manage_start_stop) {
		printk(KERN_NOTICE "Stopping disk %s: \n",
		       sdkp->disk->disk_name);
		sd_start_stop_device(sdp, 0);
	}
	scsi_disk_put(sdkp);
	scsi_disk_put(sdkp);
}
}
static int sd_suspend(struct device *dev, pm_message_t mesg)
{
	struct scsi_device *sdp = to_scsi_device(dev);
	struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev);
	int ret;
	if (!sdkp)
		return 0;	/* this can happen */
	if (sdkp->WCE) {
		printk(KERN_NOTICE "Synchronizing SCSI cache for disk %s: \n",
				sdkp->disk->disk_name);
		ret = sd_sync_cache(sdkp);
		if (ret)
			return ret;
	}
	if (mesg.event == PM_EVENT_SUSPEND && sdp->manage_start_stop) {
		printk(KERN_NOTICE "Stopping disk %s: \n",
		       sdkp->disk->disk_name);
		ret = sd_start_stop_device(sdp, 0);
		if (ret)
			return ret;
	}
	return 0;
}
static int sd_resume(struct device *dev)
{
	struct scsi_device *sdp = to_scsi_device(dev);
	struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev);
	if (!sdp->manage_start_stop)
		return 0;
	printk(KERN_NOTICE "Starting disk %s: \n", sdkp->disk->disk_name);
	return sd_start_stop_device(sdp, 1);
}
/**
/**
 *	init_sd - entry point for this driver (both when built in or when
 *	init_sd - entry point for this driver (both when built in or when
 *	a module).
 *	a module).
(-) a/include/scsi/scsi_device.h (+1 lines)
 Lines 120-125   struct scsi_device { Link Here 
	unsigned use_192_bytes_for_3f:1; /* ask for 192 bytes from page 0x3f */
	unsigned use_192_bytes_for_3f:1; /* ask for 192 bytes from page 0x3f */
	unsigned no_start_on_add:1;	/* do not issue start on add */
	unsigned no_start_on_add:1;	/* do not issue start on add */
	unsigned allow_restart:1; /* issue START_UNIT in error handler */
	unsigned allow_restart:1; /* issue START_UNIT in error handler */
	unsigned manage_start_stop:1;	/* Let HLD (sd) manage start/stop */
	unsigned no_uld_attach:1; /* disable connecting to upper level drivers */
	unsigned no_uld_attach:1; /* disable connecting to upper level drivers */
	unsigned select_no_atn:1;
	unsigned select_no_atn:1;
	unsigned fix_capacity:1;	/* READ_CAPACITY is too high by 1 */
	unsigned fix_capacity:1;	/* READ_CAPACITY is too high by 1 */
(-) a/include/scsi/sd.h (+2 lines)
 Lines 52-57   static void sd_rw_intr(struct scsi_cmnd * SCpnt); Link Here 
static int  sd_probe(struct device *);
static int  sd_probe(struct device *);
static int  sd_remove(struct device *);
static int  sd_remove(struct device *);
static void sd_shutdown(struct device *dev);
static void sd_shutdown(struct device *dev);
static int sd_suspend(struct device *dev, pm_message_t state);
static int sd_resume(struct device *dev);
static void sd_rescan(struct device *);
static void sd_rescan(struct device *);
static int  sd_init_command(struct scsi_cmnd *);
static int  sd_init_command(struct scsi_cmnd *);
static int  sd_issue_flush(struct device *, sector_t *);
static int  sd_issue_flush(struct device *, sector_t *);
 code is simplified a lot.
 code is simplified a lot.
 status is port-wide now.
 status is port-wide now.
 couldn't find easy way out as libata is in EH waiting for the
 couldn't find easy way out as libata is in EH waiting for the
 disk to be ready and sd is waiting for EH to complete to issue
 disk to be ready and sd is waiting for EH to complete to issue
 START_STOP.
 START_STOP.
 This fixes spindown on shutdown and suspend-to-disk.
 This fixes spindown on shutdown and suspend-to-disk.
drivers/ata/ahci.c              |    4 -
drivers/ata/ahci.c              |    4 -
drivers/ata/ata_generic.c       |    6 +-
drivers/ata/ata_generic.c       |    6 +-
drivers/ata/ata_piix.c          |    4 -
drivers/ata/ata_piix.c          |    4 -
drivers/ata/libata-core.c       |   39 +------
drivers/ata/libata-core.c       |   39 +------
drivers/ata/libata-eh.c         |  237 +--------------------------------------
drivers/ata/libata-eh.c         |  237 +--------------------------------------
drivers/ata/libata-scsi.c       |  129 +---------------------
drivers/ata/libata-scsi.c       |  129 +---------------------
drivers/ata/pata_ali.c          |    4 -
drivers/ata/pata_ali.c          |    4 -
drivers/ata/pata_amd.c          |    4 -
drivers/ata/pata_amd.c          |    4 -
drivers/ata/pata_atiixp.c       |    4 -
drivers/ata/pata_atiixp.c       |    4 -
drivers/ata/pata_cmd64x.c       |    4 -
drivers/ata/pata_cmd64x.c       |    4 -
drivers/ata/pata_cs5520.c       |    4 -
drivers/ata/pata_cs5520.c       |    4 -
drivers/ata/pata_cs5530.c       |    4 -
drivers/ata/pata_cs5530.c       |    4 -
drivers/ata/pata_cs5535.c       |    4 -
drivers/ata/pata_cs5535.c       |    4 -
drivers/ata/pata_cypress.c      |    4 -
drivers/ata/pata_cypress.c      |    4 -
drivers/ata/pata_efar.c         |    4 -
drivers/ata/pata_efar.c         |    4 -
drivers/ata/pata_hpt366.c       |    4 -
drivers/ata/pata_hpt366.c       |    4 -
drivers/ata/pata_hpt3x3.c       |    4 -
drivers/ata/pata_hpt3x3.c       |    4 -
drivers/ata/pata_it8213.c       |    4 -
drivers/ata/pata_it8213.c       |    4 -
drivers/ata/pata_it821x.c       |    4 -
drivers/ata/pata_it821x.c       |    4 -
drivers/ata/pata_ixp4xx_cf.c    |    2 +-
drivers/ata/pata_ixp4xx_cf.c    |    2 +-
drivers/ata/pata_jmicron.c      |    4 -
drivers/ata/pata_jmicron.c      |    4 -
drivers/ata/pata_marvell.c      |    4 -
drivers/ata/pata_marvell.c      |    4 -
drivers/ata/pata_mpc52xx.c      |    4 -
drivers/ata/pata_mpc52xx.c      |    4 -
drivers/ata/pata_mpiix.c        |    4 -
drivers/ata/pata_mpiix.c        |    4 -
drivers/ata/pata_netcell.c      |    4 -
drivers/ata/pata_netcell.c      |    4 -
drivers/ata/pata_ns87410.c      |    4 -
drivers/ata/pata_ns87410.c      |    4 -
drivers/ata/pata_oldpiix.c      |    4 -
drivers/ata/pata_oldpiix.c      |    4 -
drivers/ata/pata_opti.c         |    4 -
drivers/ata/pata_opti.c         |    4 -
drivers/ata/pata_optidma.c      |    4 -
drivers/ata/pata_optidma.c      |    4 -
drivers/ata/pata_pdc202xx_old.c |    4 -
drivers/ata/pata_pdc202xx_old.c |    4 -
drivers/ata/pata_radisys.c      |    4 -
drivers/ata/pata_radisys.c      |    4 -
drivers/ata/pata_rz1000.c       |    6 +-
drivers/ata/pata_rz1000.c       |    6 +-
drivers/ata/pata_sc1200.c       |    4 -
drivers/ata/pata_sc1200.c       |    4 -
drivers/ata/pata_scc.c          |    4 -
drivers/ata/pata_scc.c          |    4 -
drivers/ata/pata_serverworks.c  |    4 -
drivers/ata/pata_serverworks.c  |    4 -
drivers/ata/pata_sil680.c       |    4 -
drivers/ata/pata_sil680.c       |    4 -
drivers/ata/pata_sis.c          |    4 -
drivers/ata/pata_sis.c          |    4 -
drivers/ata/pata_triflex.c      |    4 -
drivers/ata/pata_triflex.c      |    4 -
drivers/ata/pata_via.c          |    4 -
drivers/ata/pata_via.c          |    4 -
drivers/ata/sata_inic162x.c     |    4 -
drivers/ata/sata_inic162x.c     |    4 -
drivers/ata/sata_nv.c           |    8 --
drivers/ata/sata_nv.c           |    8 --
drivers/ata/sata_sil.c          |    4 -
drivers/ata/sata_sil.c          |    4 -
drivers/ata/sata_sil24.c        |    4 -
drivers/ata/sata_sil24.c        |    4 -
include/linux/libata.h          |   14 +--
include/linux/libata.h          |   14 +--
44 files changed, 14 insertions(+), 571 deletions(-)
44 files changed, 14 insertions(+), 571 deletions(-)
(-) a/drivers/ata/ahci.c (-4 lines)
 Lines 250-259   static struct scsi_host_template ahci_sh Link Here 
	.slave_configure	= ata_scsi_slave_config,
	.slave_configure	= ata_scsi_slave_config,
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.suspend		= ata_scsi_device_suspend,
	.resume			= ata_scsi_device_resume,
#endif
};
};
static const struct ata_port_operations ahci_ops = {
static const struct ata_port_operations ahci_ops = {
(-) a/drivers/ata/ata_generic.c (-5 / +1 lines)
 Lines 54-60   static int generic_set_mode(struct ata_p Link Here 
	for (i = 0; i < ATA_MAX_DEVICES; i++) {
	for (i = 0; i < ATA_MAX_DEVICES; i++) {
		struct ata_device *dev = &ap->device[i];
		struct ata_device *dev = &ap->device[i];
		if (ata_dev_ready(dev)) {
		if (ata_dev_enabled(dev)) {
			/* We don't really care */
			/* We don't really care */
			dev->pio_mode = XFER_PIO_0;
			dev->pio_mode = XFER_PIO_0;
			dev->dma_mode = XFER_MW_DMA_0;
			dev->dma_mode = XFER_MW_DMA_0;
 Lines 90-99   static struct scsi_host_template generic Link Here 
	.slave_configure	= ata_scsi_slave_config,
	.slave_configure	= ata_scsi_slave_config,
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.resume			= ata_scsi_device_resume,
	.suspend		= ata_scsi_device_suspend,
#endif
};
};
static struct ata_port_operations generic_port_ops = {
static struct ata_port_operations generic_port_ops = {
(-) a/drivers/ata/ata_piix.c (-4 lines)
 Lines 275-284   static struct scsi_host_template piix_sh Link Here 
	.slave_configure	= ata_scsi_slave_config,
	.slave_configure	= ata_scsi_slave_config,
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.resume			= ata_scsi_device_resume,
	.suspend		= ata_scsi_device_suspend,
#endif
};
};
static const struct ata_port_operations piix_pata_ops = {
static const struct ata_port_operations piix_pata_ops = {
(-) a/drivers/ata/libata-core.c (-35 / +4 lines)
 Lines 2858-2864   int ata_do_set_mode(struct ata_port *ap, Link Here 
		dev = &ap->device[i];
		dev = &ap->device[i];
		/* don't update suspended devices' xfer mode */
		/* don't update suspended devices' xfer mode */
		if (!ata_dev_ready(dev))
		if (!ata_dev_enabled(dev))
			continue;
			continue;
		rc = ata_dev_set_mode(dev);
		rc = ata_dev_set_mode(dev);
 Lines 5793-5829   static int ata_host_request_pm(struct at Link Here 
 */
 */
int ata_host_suspend(struct ata_host *host, pm_message_t mesg)
int ata_host_suspend(struct ata_host *host, pm_message_t mesg)
{
{
	int i, j, rc;
	int rc;
	rc = ata_host_request_pm(host, mesg, 0, ATA_EHI_QUIET, 1);
	rc = ata_host_request_pm(host, mesg, 0, ATA_EHI_QUIET, 1);
	if (rc)
	if (rc == 0)
		goto fail;
		host->dev->power.power_state = mesg;
	/* EH is quiescent now.  Fail if we have any ready device.
	 * This happens if hotplug occurs between completion of device
	 * suspension and here.
	 */
	for (i = 0; i < host->n_ports; i++) {
		struct ata_port *ap = host->ports[i];
		for (j = 0; j < ATA_MAX_DEVICES; j++) {
			struct ata_device *dev = &ap->device[j];
			if (ata_dev_ready(dev)) {
				ata_port_printk(ap, KERN_WARNING,
						"suspend failed, device %d "
						"still active\n", dev->devno);
				rc = -EBUSY;
				goto fail;
			}
		}
	}
	host->dev->power.power_state = mesg;
	return 0;
 fail:
	ata_host_resume(host);
	return rc;
	return rc;
}
}
 Lines 6836-6846   EXPORT_SYMBOL_GPL(ata_pci_default_filter Link Here 
EXPORT_SYMBOL_GPL(ata_pci_clear_simplex);
EXPORT_SYMBOL_GPL(ata_pci_clear_simplex);
#endif /* CONFIG_PCI */
#endif /* CONFIG_PCI */
#ifdef CONFIG_PM
EXPORT_SYMBOL_GPL(ata_scsi_device_suspend);
EXPORT_SYMBOL_GPL(ata_scsi_device_resume);
#endif /* CONFIG_PM */
EXPORT_SYMBOL_GPL(ata_eng_timeout);
EXPORT_SYMBOL_GPL(ata_eng_timeout);
EXPORT_SYMBOL_GPL(ata_port_schedule_eh);
EXPORT_SYMBOL_GPL(ata_port_schedule_eh);
EXPORT_SYMBOL_GPL(ata_port_abort);
EXPORT_SYMBOL_GPL(ata_port_abort);
(-) a/drivers/ata/libata-eh.c (-233 / +4 lines)
 Lines 55-83   static void ata_eh_finish(struct ata_por Link Here 
#ifdef CONFIG_PM
#ifdef CONFIG_PM
static void ata_eh_handle_port_suspend(struct ata_port *ap);
static void ata_eh_handle_port_suspend(struct ata_port *ap);
static void ata_eh_handle_port_resume(struct ata_port *ap);
static void ata_eh_handle_port_resume(struct ata_port *ap);
static int ata_eh_suspend(struct ata_port *ap,
			  struct ata_device **r_failed_dev);
static void ata_eh_prep_resume(struct ata_port *ap);
static int ata_eh_resume(struct ata_port *ap, struct ata_device **r_failed_dev);
#else /* CONFIG_PM */
#else /* CONFIG_PM */
static void ata_eh_handle_port_suspend(struct ata_port *ap)
static void ata_eh_handle_port_suspend(struct ata_port *ap)
{ }
{ }
static void ata_eh_handle_port_resume(struct ata_port *ap)
static void ata_eh_handle_port_resume(struct ata_port *ap)
{ }
{ }
static int ata_eh_suspend(struct ata_port *ap, struct ata_device **r_failed_dev)
{
	return 0;
}
static void ata_eh_prep_resume(struct ata_port *ap)
{ }
static int ata_eh_resume(struct ata_port *ap, struct ata_device **r_failed_dev)
{
	return 0;
}
#endif /* CONFIG_PM */
#endif /* CONFIG_PM */
static void ata_ering_record(struct ata_ering *ering, int is_io,
static void ata_ering_record(struct ata_ering *ering, int is_io,
 Lines 1767-1773   static int ata_eh_revalidate_and_attach( Link Here 
		if (ehc->i.flags & ATA_EHI_DID_RESET)
		if (ehc->i.flags & ATA_EHI_DID_RESET)
			readid_flags |= ATA_READID_POSTRESET;
			readid_flags |= ATA_READID_POSTRESET;
		if (action & ATA_EH_REVALIDATE && ata_dev_ready(dev)) {
		if ((action & ATA_EH_REVALIDATE) && ata_dev_enabled(dev)) {
			if (ata_port_offline(ap)) {
			if (ata_port_offline(ap)) {
				rc = -EIO;
				rc = -EIO;
				goto err;
				goto err;
 Lines 1848-2013   static int ata_eh_revalidate_and_attach( Link Here 
	return rc;
	return rc;
}
}
#ifdef CONFIG_PM
/**
 *	ata_eh_suspend - handle suspend EH action
 *	@ap: target host port
 *	@r_failed_dev: result parameter to indicate failing device
 *
 *	Handle suspend EH action.  Disk devices are spinned down and
 *	other types of devices are just marked suspended.  Once
 *	suspended, no EH action to the device is allowed until it is
 *	resumed.
 *
 *	LOCKING:
 *	Kernel thread context (may sleep).
 *
 *	RETURNS:
 *	0 on success, -errno otherwise
 */
static int ata_eh_suspend(struct ata_port *ap, struct ata_device **r_failed_dev)
{
	struct ata_device *dev;
	int i, rc = 0;
	DPRINTK("ENTER\n");
	for (i = 0; i < ATA_MAX_DEVICES; i++) {
		unsigned long flags;
		unsigned int action, err_mask;
		dev = &ap->device[i];
		action = ata_eh_dev_action(dev);
		if (!ata_dev_enabled(dev) || !(action & ATA_EH_SUSPEND))
			continue;
		WARN_ON(dev->flags & ATA_DFLAG_SUSPENDED);
		ata_eh_about_to_do(ap, dev, ATA_EH_SUSPEND);
		if (dev->class == ATA_DEV_ATA && !(action & ATA_EH_PM_FREEZE)) {
			/* flush cache */
			rc = ata_flush_cache(dev);
			if (rc)
				break;
			/* spin down */
			err_mask = ata_do_simple_cmd(dev, ATA_CMD_STANDBYNOW1);
			if (err_mask) {
				ata_dev_printk(dev, KERN_ERR, "failed to "
					       "spin down (err_mask=0x%x)\n",
					       err_mask);
				rc = -EIO;
				break;
			}
		}
		spin_lock_irqsave(ap->lock, flags);
		dev->flags |= ATA_DFLAG_SUSPENDED;
		spin_unlock_irqrestore(ap->lock, flags);
		ata_eh_done(ap, dev, ATA_EH_SUSPEND);
	}
	if (rc)
		*r_failed_dev = dev;
	DPRINTK("EXIT\n");
	return rc;
}
/**
 *	ata_eh_prep_resume - prep for resume EH action
 *	@ap: target host port
 *
 *	Clear SUSPENDED in preparation for scheduled resume actions.
 *	This allows other parts of EH to access the devices being
 *	resumed.
 *
 *	LOCKING:
 *	Kernel thread context (may sleep).
 */
static void ata_eh_prep_resume(struct ata_port *ap)
{
	struct ata_device *dev;
	unsigned long flags;
	int i;
	DPRINTK("ENTER\n");
	for (i = 0; i < ATA_MAX_DEVICES; i++) {
		unsigned int action;
		dev = &ap->device[i];
		action = ata_eh_dev_action(dev);
		if (!ata_dev_enabled(dev) || !(action & ATA_EH_RESUME))
			continue;
		spin_lock_irqsave(ap->lock, flags);
		dev->flags &= ~ATA_DFLAG_SUSPENDED;
		spin_unlock_irqrestore(ap->lock, flags);
	}
	DPRINTK("EXIT\n");
}
/**
 *	ata_eh_resume - handle resume EH action
 *	@ap: target host port
 *	@r_failed_dev: result parameter to indicate failing device
 *
 *	Handle resume EH action.  Target devices are already reset and
 *	revalidated.  Spinning up is the only operation left.
 *
 *	LOCKING:
 *	Kernel thread context (may sleep).
 *
 *	RETURNS:
 *	0 on success, -errno otherwise
 */
static int ata_eh_resume(struct ata_port *ap, struct ata_device **r_failed_dev)
{
	struct ata_device *dev;
	int i, rc = 0;
	DPRINTK("ENTER\n");
	for (i = 0; i < ATA_MAX_DEVICES; i++) {
		unsigned int action, err_mask;
		dev = &ap->device[i];
		action = ata_eh_dev_action(dev);
		if (!ata_dev_enabled(dev) || !(action & ATA_EH_RESUME))
			continue;
		ata_eh_about_to_do(ap, dev, ATA_EH_RESUME);
		if (dev->class == ATA_DEV_ATA && !(action & ATA_EH_PM_FREEZE)) {
			err_mask = ata_do_simple_cmd(dev,
						     ATA_CMD_IDLEIMMEDIATE);
			if (err_mask) {
				ata_dev_printk(dev, KERN_ERR, "failed to "
					       "spin up (err_mask=0x%x)\n",
					       err_mask);
				rc = -EIO;
				break;
			}
		}
		ata_eh_done(ap, dev, ATA_EH_RESUME);
	}
	if (rc)
		*r_failed_dev = dev;
	DPRINTK("EXIT\n");
	return 0;
}
#endif /* CONFIG_PM */
static int ata_port_nr_enabled(struct ata_port *ap)
static int ata_port_nr_enabled(struct ata_port *ap)
{
{
	int i, cnt = 0;
	int i, cnt = 0;
 Lines 2033-2049   static int ata_eh_skip_recovery(struct a Link Here 
	struct ata_eh_context *ehc = &ap->eh_context;
	struct ata_eh_context *ehc = &ap->eh_context;
	int i;
	int i;
	/* skip if all possible devices are suspended */
	for (i = 0; i < ata_port_max_devices(ap); i++) {
		struct ata_device *dev = &ap->device[i];
		if (!(dev->flags & ATA_DFLAG_SUSPENDED))
			break;
	}
	if (i == ata_port_max_devices(ap))
		return 1;
	/* thaw frozen port, resume link and recover failed devices */
	/* thaw frozen port, resume link and recover failed devices */
	if ((ap->pflags & ATA_PFLAG_FROZEN) ||
	if ((ap->pflags & ATA_PFLAG_FROZEN) ||
	    (ehc->i.flags & ATA_EHI_RESUME_LINK) || ata_port_nr_enabled(ap))
	    (ehc->i.flags & ATA_EHI_RESUME_LINK) || ata_port_nr_enabled(ap))
 Lines 2123-2131   static int ata_eh_recover(struct ata_por Link Here 
	if (ap->pflags & ATA_PFLAG_UNLOADING)
	if (ap->pflags & ATA_PFLAG_UNLOADING)
		goto out;
		goto out;
	/* prep for resume */
	ata_eh_prep_resume(ap);
	/* skip EH if possible. */
	/* skip EH if possible. */
	if (ata_eh_skip_recovery(ap))
	if (ata_eh_skip_recovery(ap))
		ehc->i.action = 0;
		ehc->i.action = 0;
 Lines 2153-2163   static int ata_eh_recover(struct ata_por Link Here 
	if (rc)
	if (rc)
		goto dev_fail;
		goto dev_fail;
	/* resume devices */
	rc = ata_eh_resume(ap, &dev);
	if (rc)
		goto dev_fail;
	/* configure transfer mode if necessary */
	/* configure transfer mode if necessary */
	if (ehc->i.flags & ATA_EHI_SETMODE) {
	if (ehc->i.flags & ATA_EHI_SETMODE) {
		rc = ata_set_mode(ap, &dev);
		rc = ata_set_mode(ap, &dev);
 Lines 2166-2176   static int ata_eh_recover(struct ata_por Link Here 
		ehc->i.flags &= ~ATA_EHI_SETMODE;
		ehc->i.flags &= ~ATA_EHI_SETMODE;
	}
	}
	/* suspend devices */
	rc = ata_eh_suspend(ap, &dev);
	if (rc)
		goto dev_fail;
	goto out;
	goto out;
 dev_fail:
 dev_fail:
 Lines 2366-2387   static void ata_eh_handle_port_suspend(s Link Here 
 *
 *
 *	Resume @ap.
 *	Resume @ap.
 *
 *
 *	This function also waits upto one second until all devices
 *	hanging off this port requests resume EH action.  This is to
 *	prevent invoking EH and thus reset multiple times on resume.
 *
 *	On DPM resume, where some of devices might not be resumed
 *	together, this may delay port resume upto one second, but such
 *	DPM resumes are rare and 1 sec delay isn't too bad.
 *
 *	LOCKING:
 *	LOCKING:
 *	Kernel thread context (may sleep).
 *	Kernel thread context (may sleep).
 */
 */
static void ata_eh_handle_port_resume(struct ata_port *ap)
static void ata_eh_handle_port_resume(struct ata_port *ap)
{
{
	unsigned long timeout;
	unsigned long flags;
	unsigned long flags;
	int i, rc = 0;
	int rc = 0;
	/* are we resuming? */
	/* are we resuming? */
	spin_lock_irqsave(ap->lock, flags);
	spin_lock_irqsave(ap->lock, flags);
 Lines 2392-2422   static void ata_eh_handle_port_resume(st Link Here 
	}
	}
	spin_unlock_irqrestore(ap->lock, flags);
	spin_unlock_irqrestore(ap->lock, flags);
	/* spurious? */
	WARN_ON(!(ap->pflags & ATA_PFLAG_SUSPENDED));
	if (!(ap->pflags & ATA_PFLAG_SUSPENDED))
		goto done;
	if (ap->ops->port_resume)
	if (ap->ops->port_resume)
		rc = ap->ops->port_resume(ap);
		rc = ap->ops->port_resume(ap);
	/* give devices time to request EH */
	/* report result */
	timeout = jiffies + HZ; /* 1s max */
	while (1) {
		for (i = 0; i < ATA_MAX_DEVICES; i++) {
			struct ata_device *dev = &ap->device[i];
			unsigned int action = ata_eh_dev_action(dev);
			if ((dev->flags & ATA_DFLAG_SUSPENDED) &&
			    !(action & ATA_EH_RESUME))
				break;
		}
		if (i == ATA_MAX_DEVICES || time_after(jiffies, timeout))
			break;
		msleep(10);
	}
 done:
	spin_lock_irqsave(ap->lock, flags);
	spin_lock_irqsave(ap->lock, flags);
	ap->pflags &= ~(ATA_PFLAG_PM_PENDING | ATA_PFLAG_SUSPENDED);
	ap->pflags &= ~(ATA_PFLAG_PM_PENDING | ATA_PFLAG_SUSPENDED);
	if (ap->pm_result) {
	if (ap->pm_result) {
(-) a/drivers/ata/libata-scsi.c (-127 / +2 lines)
 Lines 510-642   static void ata_dump_status(unsigned id, Link Here 
	}
	}
}
}
#ifdef CONFIG_PM
/**
 *	ata_scsi_device_suspend - suspend ATA device associated with sdev
 *	@sdev: the SCSI device to suspend
 *	@mesg: target power management message
 *
 *	Request suspend EH action on the ATA device associated with
 *	@sdev and wait for the operation to complete.
 *
 *	LOCKING:
 *	Kernel thread context (may sleep).
 *
 *	RETURNS:
 *	0 on success, -errno otherwise.
 */
int ata_scsi_device_suspend(struct scsi_device *sdev, pm_message_t mesg)
{
	struct ata_port *ap = ata_shost_to_port(sdev->host);
	struct ata_device *dev = ata_scsi_find_dev(ap, sdev);
	unsigned long flags;
	unsigned int action;
	int rc = 0;
	if (!dev)
		goto out;
	spin_lock_irqsave(ap->lock, flags);
	/* wait for the previous resume to complete */
	while (dev->flags & ATA_DFLAG_SUSPENDED) {
		spin_unlock_irqrestore(ap->lock, flags);
		ata_port_wait_eh(ap);
		spin_lock_irqsave(ap->lock, flags);
	}
	/* if @sdev is already detached, nothing to do */
	if (sdev->sdev_state == SDEV_OFFLINE ||
	    sdev->sdev_state == SDEV_CANCEL || sdev->sdev_state == SDEV_DEL)
		goto out_unlock;
	/* request suspend */
	action = ATA_EH_SUSPEND;
	if (mesg.event != PM_EVENT_SUSPEND)
		action |= ATA_EH_PM_FREEZE;
	ap->eh_info.dev_action[dev->devno] |= action;
	ap->eh_info.flags |= ATA_EHI_QUIET;
	ata_port_schedule_eh(ap);
	spin_unlock_irqrestore(ap->lock, flags);
	/* wait for EH to do the job */
	ata_port_wait_eh(ap);
	spin_lock_irqsave(ap->lock, flags);
	/* If @sdev is still attached but the associated ATA device
	 * isn't suspended, the operation failed.
	 */
	if (sdev->sdev_state != SDEV_OFFLINE &&
	    sdev->sdev_state != SDEV_CANCEL && sdev->sdev_state != SDEV_DEL &&
	    !(dev->flags & ATA_DFLAG_SUSPENDED))
		rc = -EIO;
 out_unlock:
	spin_unlock_irqrestore(ap->lock, flags);
 out:
	if (rc == 0)
		sdev->sdev_gendev.power.power_state = mesg;
	return rc;
}
/**
 *	ata_scsi_device_resume - resume ATA device associated with sdev
 *	@sdev: the SCSI device to resume
 *
 *	Request resume EH action on the ATA device associated with
 *	@sdev and return immediately.  This enables parallel
 *	wakeup/spinup of devices.
 *
 *	LOCKING:
 *	Kernel thread context (may sleep).
 *
 *	RETURNS:
 *	0.
 */
int ata_scsi_device_resume(struct scsi_device *sdev)
{
	struct ata_port *ap = ata_shost_to_port(sdev->host);
	struct ata_device *dev = ata_scsi_find_dev(ap, sdev);
	struct ata_eh_info *ehi = &ap->eh_info;
	unsigned long flags;
	unsigned int action;
	if (!dev)
		goto out;
	spin_lock_irqsave(ap->lock, flags);
	/* if @sdev is already detached, nothing to do */
	if (sdev->sdev_state == SDEV_OFFLINE ||
	    sdev->sdev_state == SDEV_CANCEL || sdev->sdev_state == SDEV_DEL)
		goto out_unlock;
	/* request resume */
	action = ATA_EH_RESUME;
	if (sdev->sdev_gendev.power.power_state.event == PM_EVENT_SUSPEND)
		__ata_ehi_hotplugged(ehi);
	else
		action |= ATA_EH_PM_FREEZE | ATA_EH_SOFTRESET;
	ehi->dev_action[dev->devno] |= action;
	/* We don't want autopsy and verbose EH messages.  Disable
	 * those if we're the only device on this link.
	 */
	if (ata_port_max_devices(ap) == 1)
		ehi->flags |= ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET;
	ata_port_schedule_eh(ap);
 out_unlock:
	spin_unlock_irqrestore(ap->lock, flags);
 out:
	sdev->sdev_gendev.power.power_state = PMSG_ON;
	return 0;
}
#endif /* CONFIG_PM */
/**
/**
 *	ata_to_sense_error - convert ATA error to SCSI error
 *	ata_to_sense_error - convert ATA error to SCSI error
 *	@id: ATA device number
 *	@id: ATA device number
 Lines 929-934   int ata_scsi_slave_config(struct scsi_de Link Here 
	blk_queue_max_phys_segments(sdev->request_queue, LIBATA_MAX_PRD);
	blk_queue_max_phys_segments(sdev->request_queue, LIBATA_MAX_PRD);
	sdev->manage_start_stop = 1;
	if (dev)
	if (dev)
		ata_scsi_dev_config(sdev, dev);
		ata_scsi_dev_config(sdev, dev);
(-) a/drivers/ata/pata_ali.c (-4 lines)
 Lines 291-300   static struct scsi_host_template ali_sht Link Here 
	.slave_configure	= ata_scsi_slave_config,
	.slave_configure	= ata_scsi_slave_config,
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.resume			= ata_scsi_device_resume,
	.suspend		= ata_scsi_device_suspend,
#endif
};
};
/*
/*
(-) a/drivers/ata/pata_amd.c (-4 lines)
 Lines 323-332   static struct scsi_host_template amd_sht Link Here 
	.slave_configure	= ata_scsi_slave_config,
	.slave_configure	= ata_scsi_slave_config,
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.resume			= ata_scsi_device_resume,
	.suspend		= ata_scsi_device_suspend,
#endif
};
};
static struct ata_port_operations amd33_port_ops = {
static struct ata_port_operations amd33_port_ops = {
(-) a/drivers/ata/pata_atiixp.c (-4 lines)
 Lines 229-238   static struct scsi_host_template atiixp_ Link Here 
	.slave_configure	= ata_scsi_slave_config,
	.slave_configure	= ata_scsi_slave_config,
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.resume			= ata_scsi_device_resume,
	.suspend		= ata_scsi_device_suspend,
#endif
};
};
static struct ata_port_operations atiixp_port_ops = {
static struct ata_port_operations atiixp_port_ops = {
(-) a/drivers/ata/pata_cmd64x.c (-4 lines)
 Lines 266-275   static struct scsi_host_template cmd64x_ Link Here 
	.slave_configure	= ata_scsi_slave_config,
	.slave_configure	= ata_scsi_slave_config,
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.resume			= ata_scsi_device_resume,
	.suspend		= ata_scsi_device_suspend,
#endif
};
};
static struct ata_port_operations cmd64x_port_ops = {
static struct ata_port_operations cmd64x_port_ops = {
(-) a/drivers/ata/pata_cs5520.c (-4 lines)
 Lines 155-164   static struct scsi_host_template cs5520_ Link Here 
	.slave_configure	= ata_scsi_slave_config,
	.slave_configure	= ata_scsi_slave_config,
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.resume			= ata_scsi_device_resume,
	.suspend		= ata_scsi_device_suspend,
#endif
};
};
static struct ata_port_operations cs5520_port_ops = {
static struct ata_port_operations cs5520_port_ops = {
(-) a/drivers/ata/pata_cs5530.c (-4 lines)
 Lines 176-185   static struct scsi_host_template cs5530_ Link Here 
	.slave_configure	= ata_scsi_slave_config,
	.slave_configure	= ata_scsi_slave_config,
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.resume			= ata_scsi_device_resume,
	.suspend		= ata_scsi_device_suspend,
#endif
};
};
static struct ata_port_operations cs5530_port_ops = {
static struct ata_port_operations cs5530_port_ops = {
(-) a/drivers/ata/pata_cs5535.c (-4 lines)
 Lines 172-181   static struct scsi_host_template cs5535_ Link Here 
	.slave_configure	= ata_scsi_slave_config,
	.slave_configure	= ata_scsi_slave_config,
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.resume			= ata_scsi_device_resume,
	.suspend		= ata_scsi_device_suspend,
#endif
};
};
static struct ata_port_operations cs5535_port_ops = {
static struct ata_port_operations cs5535_port_ops = {
(-) a/drivers/ata/pata_cypress.c (-4 lines)
 Lines 125-134   static struct scsi_host_template cy82c69 Link Here 
	.slave_configure	= ata_scsi_slave_config,
	.slave_configure	= ata_scsi_slave_config,
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.resume			= ata_scsi_device_resume,
	.suspend		= ata_scsi_device_suspend,
#endif
};
};
static struct ata_port_operations cy82c693_port_ops = {
static struct ata_port_operations cy82c693_port_ops = {
(-) a/drivers/ata/pata_efar.c (-4 lines)
 Lines 246-255   static struct scsi_host_template efar_sh Link Here 
	.slave_configure	= ata_scsi_slave_config,
	.slave_configure	= ata_scsi_slave_config,
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.resume			= ata_scsi_device_resume,
	.suspend		= ata_scsi_device_suspend,
#endif
};
};
static const struct ata_port_operations efar_ops = {
static const struct ata_port_operations efar_ops = {
(-) a/drivers/ata/pata_hpt366.c (-4 lines)
 Lines 331-340   static struct scsi_host_template hpt36x_ Link Here 
	.slave_configure	= ata_scsi_slave_config,
	.slave_configure	= ata_scsi_slave_config,
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.resume			= ata_scsi_device_resume,
	.suspend		= ata_scsi_device_suspend,
#endif
};
};
/*
/*
(-) a/drivers/ata/pata_hpt3x3.c (-4 lines)
 Lines 100-109   static struct scsi_host_template hpt3x3_ Link Here 
	.slave_configure	= ata_scsi_slave_config,
	.slave_configure	= ata_scsi_slave_config,
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.resume			= ata_scsi_device_resume,
	.suspend		= ata_scsi_device_suspend,
#endif
};
};
static struct ata_port_operations hpt3x3_port_ops = {
static struct ata_port_operations hpt3x3_port_ops = {
(-) a/drivers/ata/pata_it8213.c (-4 lines)
 Lines 255-264   static struct scsi_host_template it8213_ Link Here 
	.dma_boundary		= ATA_DMA_BOUNDARY,
	.dma_boundary		= ATA_DMA_BOUNDARY,
	.slave_configure	= ata_scsi_slave_config,
	.slave_configure	= ata_scsi_slave_config,
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.resume			= ata_scsi_device_resume,
	.suspend		= ata_scsi_device_suspend,
#endif
};
};
static const struct ata_port_operations it8213_ops = {
static const struct ata_port_operations it8213_ops = {
(-) a/drivers/ata/pata_it821x.c (-4 lines)
 Lines 620-629   static struct scsi_host_template it821x_ Link Here 
	.slave_configure	= ata_scsi_slave_config,
	.slave_configure	= ata_scsi_slave_config,
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.resume			= ata_scsi_device_resume,
	.suspend		= ata_scsi_device_suspend,
#endif
};
};
static struct ata_port_operations it821x_smart_port_ops = {
static struct ata_port_operations it821x_smart_port_ops = {
(-) a/drivers/ata/pata_ixp4xx_cf.c (-1 / +1 lines)
 Lines 31-37   static int ixp4xx_set_mode(struct ata_po Link Here 
	for (i = 0; i < ATA_MAX_DEVICES; i++) {
	for (i = 0; i < ATA_MAX_DEVICES; i++) {
		struct ata_device *dev = &ap->device[i];
		struct ata_device *dev = &ap->device[i];
		if (ata_dev_ready(dev)) {
		if (ata_dev_enabled(dev)) {
			ata_dev_printk(dev, KERN_INFO, "configured for PIO0\n");
			ata_dev_printk(dev, KERN_INFO, "configured for PIO0\n");
			dev->pio_mode = XFER_PIO_0;
			dev->pio_mode = XFER_PIO_0;
			dev->xfer_mode = XFER_PIO_0;
			dev->xfer_mode = XFER_PIO_0;
(-) a/drivers/ata/pata_jmicron.c (-4 lines)
 Lines 137-146   static struct scsi_host_template jmicron Link Here 
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	/* Use standard CHS mapping rules */
	/* Use standard CHS mapping rules */
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.suspend		= ata_scsi_device_suspend,
	.resume			= ata_scsi_device_resume,
#endif
};
};
static const struct ata_port_operations jmicron_ops = {
static const struct ata_port_operations jmicron_ops = {
(-) a/drivers/ata/pata_marvell.c (-4 lines)
 Lines 104-113   static struct scsi_host_template marvell Link Here 
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	/* Use standard CHS mapping rules */
	/* Use standard CHS mapping rules */
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.resume			= ata_scsi_device_resume,
	.suspend		= ata_scsi_device_suspend,
#endif
};
};
static const struct ata_port_operations marvell_ops = {
static const struct ata_port_operations marvell_ops = {
(-) a/drivers/ata/pata_mpc52xx.c (-4 lines)
 Lines 280-289   static struct scsi_host_template mpc52xx Link Here 
	.dma_boundary		= ATA_DMA_BOUNDARY,
	.dma_boundary		= ATA_DMA_BOUNDARY,
	.slave_configure	= ata_scsi_slave_config,
	.slave_configure	= ata_scsi_slave_config,
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.suspend		= ata_scsi_device_suspend,
	.resume			= ata_scsi_device_resume,
#endif
};
};
static struct ata_port_operations mpc52xx_ata_port_ops = {
static struct ata_port_operations mpc52xx_ata_port_ops = {
(-) a/drivers/ata/pata_mpiix.c (-4 lines)
 Lines 164-173   static struct scsi_host_template mpiix_s Link Here 
	.slave_configure	= ata_scsi_slave_config,
	.slave_configure	= ata_scsi_slave_config,
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.resume			= ata_scsi_device_resume,
	.suspend		= ata_scsi_device_suspend,
#endif
};
};
static struct ata_port_operations mpiix_port_ops = {
static struct ata_port_operations mpiix_port_ops = {
(-) a/drivers/ata/pata_netcell.c (-4 lines)
 Lines 37-46   static struct scsi_host_template netcell Link Here 
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	/* Use standard CHS mapping rules */
	/* Use standard CHS mapping rules */
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.resume			= ata_scsi_device_resume,
	.suspend		= ata_scsi_device_suspend,
#endif
};
};
static const struct ata_port_operations netcell_ops = {
static const struct ata_port_operations netcell_ops = {
(-) a/drivers/ata/pata_ns87410.c (-4 lines)
 Lines 156-165   static struct scsi_host_template ns87410 Link Here 
	.slave_configure	= ata_scsi_slave_config,
	.slave_configure	= ata_scsi_slave_config,
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.resume			= ata_scsi_device_resume,
	.suspend		= ata_scsi_device_suspend,
#endif
};
};
static struct ata_port_operations ns87410_port_ops = {
static struct ata_port_operations ns87410_port_ops = {
(-) a/drivers/ata/pata_oldpiix.c (-4 lines)
 Lines 232-241   static struct scsi_host_template oldpiix Link Here 
	.slave_configure	= ata_scsi_slave_config,
	.slave_configure	= ata_scsi_slave_config,
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.resume			= ata_scsi_device_resume,
	.suspend		= ata_scsi_device_suspend,
#endif
};
};
static const struct ata_port_operations oldpiix_pata_ops = {
static const struct ata_port_operations oldpiix_pata_ops = {
(-) a/drivers/ata/pata_opti.c (-4 lines)
 Lines 177-186   static struct scsi_host_template opti_sh Link Here 
	.slave_configure	= ata_scsi_slave_config,
	.slave_configure	= ata_scsi_slave_config,
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.resume			= ata_scsi_device_resume,
	.suspend		= ata_scsi_device_suspend,
#endif
};
};
static struct ata_port_operations opti_port_ops = {
static struct ata_port_operations opti_port_ops = {
(-) a/drivers/ata/pata_optidma.c (-4 lines)
 Lines 362-371   static struct scsi_host_template optidma Link Here 
	.slave_configure	= ata_scsi_slave_config,
	.slave_configure	= ata_scsi_slave_config,
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.resume			= ata_scsi_device_resume,
	.suspend		= ata_scsi_device_suspend,
#endif
};
};
static struct ata_port_operations optidma_port_ops = {
static struct ata_port_operations optidma_port_ops = {
(-) a/drivers/ata/pata_pdc202xx_old.c (-4 lines)
 Lines 244-253   static struct scsi_host_template pdc202x Link Here 
	.slave_configure	= ata_scsi_slave_config,
	.slave_configure	= ata_scsi_slave_config,
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.resume			= ata_scsi_device_resume,
	.suspend		= ata_scsi_device_suspend,
#endif
};
};
static struct ata_port_operations pdc2024x_port_ops = {
static struct ata_port_operations pdc2024x_port_ops = {
(-) a/drivers/ata/pata_radisys.c (-4 lines)
 Lines 200-209   static struct scsi_host_template radisys Link Here 
	.slave_configure	= ata_scsi_slave_config,
	.slave_configure	= ata_scsi_slave_config,
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.resume			= ata_scsi_device_resume,
	.suspend		= ata_scsi_device_suspend,
#endif
};
};
static const struct ata_port_operations radisys_pata_ops = {
static const struct ata_port_operations radisys_pata_ops = {
(-) a/drivers/ata/pata_rz1000.c (-5 / +1 lines)
 Lines 40-46   static int rz1000_set_mode(struct ata_po Link Here 
	for (i = 0; i < ATA_MAX_DEVICES; i++) {
	for (i = 0; i < ATA_MAX_DEVICES; i++) {
		struct ata_device *dev = &ap->device[i];
		struct ata_device *dev = &ap->device[i];
		if (ata_dev_ready(dev)) {
		if (ata_dev_enabled(dev)) {
			/* We don't really care */
			/* We don't really care */
			dev->pio_mode = XFER_PIO_0;
			dev->pio_mode = XFER_PIO_0;
			dev->xfer_mode = XFER_PIO_0;
			dev->xfer_mode = XFER_PIO_0;
 Lines 69-78   static struct scsi_host_template rz1000_ Link Here 
	.slave_configure	= ata_scsi_slave_config,
	.slave_configure	= ata_scsi_slave_config,
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.resume			= ata_scsi_device_resume,
	.suspend		= ata_scsi_device_suspend,
#endif
};
};
static struct ata_port_operations rz1000_port_ops = {
static struct ata_port_operations rz1000_port_ops = {
(-) a/drivers/ata/pata_sc1200.c (-4 lines)
 Lines 194-203   static struct scsi_host_template sc1200_ Link Here 
	.slave_configure	= ata_scsi_slave_config,
	.slave_configure	= ata_scsi_slave_config,
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.resume			= ata_scsi_device_resume,
	.suspend		= ata_scsi_device_suspend,
#endif
};
};
static struct ata_port_operations sc1200_port_ops = {
static struct ata_port_operations sc1200_port_ops = {
(-) a/drivers/ata/pata_scc.c (-4 lines)
 Lines 984-993   static struct scsi_host_template scc_sht Link Here 
	.slave_configure	= ata_scsi_slave_config,
	.slave_configure	= ata_scsi_slave_config,
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.resume			= ata_scsi_device_resume,
	.suspend		= ata_scsi_device_suspend,
#endif
};
};
static const struct ata_port_operations scc_pata_ops = {
static const struct ata_port_operations scc_pata_ops = {
(-) a/drivers/ata/pata_serverworks.c (-4 lines)
 Lines 313-322   static struct scsi_host_template serverw Link Here 
	.slave_configure	= ata_scsi_slave_config,
	.slave_configure	= ata_scsi_slave_config,
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.resume			= ata_scsi_device_resume,
	.suspend		= ata_scsi_device_suspend,
#endif
};
};
static struct ata_port_operations serverworks_osb4_port_ops = {
static struct ata_port_operations serverworks_osb4_port_ops = {
(-) a/drivers/ata/pata_sil680.c (-4 lines)
 Lines 230-239   static struct scsi_host_template sil680_ Link Here 
	.slave_configure	= ata_scsi_slave_config,
	.slave_configure	= ata_scsi_slave_config,
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.suspend		= ata_scsi_device_suspend,
	.resume			= ata_scsi_device_resume,
#endif
};
};
static struct ata_port_operations sil680_port_ops = {
static struct ata_port_operations sil680_port_ops = {
(-) a/drivers/ata/pata_sis.c (-4 lines)
 Lines 520-529   static struct scsi_host_template sis_sht Link Here 
	.slave_configure	= ata_scsi_slave_config,
	.slave_configure	= ata_scsi_slave_config,
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.resume			= ata_scsi_device_resume,
	.suspend		= ata_scsi_device_suspend,
#endif
};
};
static const struct ata_port_operations sis_133_ops = {
static const struct ata_port_operations sis_133_ops = {
(-) a/drivers/ata/pata_triflex.c (-4 lines)
 Lines 192-201   static struct scsi_host_template triflex Link Here 
	.slave_configure	= ata_scsi_slave_config,
	.slave_configure	= ata_scsi_slave_config,
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.resume			= ata_scsi_device_resume,
	.suspend		= ata_scsi_device_suspend,
#endif
};
};
static struct ata_port_operations triflex_port_ops = {
static struct ata_port_operations triflex_port_ops = {
(-) a/drivers/ata/pata_via.c (-4 lines)
 Lines 300-309   static struct scsi_host_template via_sht Link Here 
	.slave_configure	= ata_scsi_slave_config,
	.slave_configure	= ata_scsi_slave_config,
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.resume			= ata_scsi_device_resume,
	.suspend		= ata_scsi_device_suspend,
#endif
};
};
static struct ata_port_operations via_port_ops = {
static struct ata_port_operations via_port_ops = {
(-) a/drivers/ata/sata_inic162x.c (-4 lines)
 Lines 135-144   static struct scsi_host_template inic_sh Link Here 
	.slave_configure	= inic_slave_config,
	.slave_configure	= inic_slave_config,
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.suspend		= ata_scsi_device_suspend,
	.resume			= ata_scsi_device_resume,
#endif
};
};
static const int scr_map[] = {
static const int scr_map[] = {
(-) a/drivers/ata/sata_nv.c (-8 lines)
 Lines 323-332   static struct scsi_host_template nv_sht Link Here 
	.slave_configure	= ata_scsi_slave_config,
	.slave_configure	= ata_scsi_slave_config,
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.suspend		= ata_scsi_device_suspend,
	.resume			= ata_scsi_device_resume,
#endif
};
};
static struct scsi_host_template nv_adma_sht = {
static struct scsi_host_template nv_adma_sht = {
 Lines 345-354   static struct scsi_host_template nv_adma Link Here 
	.slave_configure	= nv_adma_slave_config,
	.slave_configure	= nv_adma_slave_config,
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.suspend		= ata_scsi_device_suspend,
	.resume			= ata_scsi_device_resume,
#endif
};
};
static const struct ata_port_operations nv_generic_ops = {
static const struct ata_port_operations nv_generic_ops = {
(-) a/drivers/ata/sata_sil.c (-4 lines)
 Lines 182-191   static struct scsi_host_template sil_sht Link Here 
	.slave_configure	= ata_scsi_slave_config,
	.slave_configure	= ata_scsi_slave_config,
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.suspend		= ata_scsi_device_suspend,
	.resume			= ata_scsi_device_resume,
#endif
};
};
static const struct ata_port_operations sil_ops = {
static const struct ata_port_operations sil_ops = {
(-) a/drivers/ata/sata_sil24.c (-4 lines)
 Lines 380-389   static struct scsi_host_template sil24_s Link Here 
	.slave_configure	= ata_scsi_slave_config,
	.slave_configure	= ata_scsi_slave_config,
	.slave_destroy		= ata_scsi_slave_destroy,
	.slave_destroy		= ata_scsi_slave_destroy,
	.bios_param		= ata_std_bios_param,
	.bios_param		= ata_std_bios_param,
#ifdef CONFIG_PM
	.suspend		= ata_scsi_device_suspend,
	.resume			= ata_scsi_device_resume,
#endif
};
};
static const struct ata_port_operations sil24_ops = {
static const struct ata_port_operations sil24_ops = {
(-) a/include/linux/libata.h (-13 / +1 lines)
 Lines 140-146   enum { Link Here 
	ATA_DFLAG_PIO		= (1 << 8), /* device limited to PIO mode */
	ATA_DFLAG_PIO		= (1 << 8), /* device limited to PIO mode */
	ATA_DFLAG_NCQ_OFF	= (1 << 9), /* device limited to non-NCQ mode */
	ATA_DFLAG_NCQ_OFF	= (1 << 9), /* device limited to non-NCQ mode */
	ATA_DFLAG_SUSPENDED	= (1 << 10), /* device suspended */
	ATA_DFLAG_INIT_MASK	= (1 << 16) - 1,
	ATA_DFLAG_INIT_MASK	= (1 << 16) - 1,
	ATA_DFLAG_DETACH	= (1 << 16),
	ATA_DFLAG_DETACH	= (1 << 16),
 Lines 268-280   enum { Link Here 
	ATA_EH_REVALIDATE	= (1 << 0),
	ATA_EH_REVALIDATE	= (1 << 0),
	ATA_EH_SOFTRESET	= (1 << 1),
	ATA_EH_SOFTRESET	= (1 << 1),
	ATA_EH_HARDRESET	= (1 << 2),
	ATA_EH_HARDRESET	= (1 << 2),
	ATA_EH_SUSPEND		= (1 << 3),
	ATA_EH_RESUME		= (1 << 4),
	ATA_EH_PM_FREEZE	= (1 << 5),
	ATA_EH_RESET_MASK	= ATA_EH_SOFTRESET | ATA_EH_HARDRESET,
	ATA_EH_RESET_MASK	= ATA_EH_SOFTRESET | ATA_EH_HARDRESET,
	ATA_EH_PERDEV_MASK	= ATA_EH_REVALIDATE | ATA_EH_SUSPEND |
	ATA_EH_PERDEV_MASK	= ATA_EH_REVALIDATE,
				  ATA_EH_RESUME | ATA_EH_PM_FREEZE,
	/* ata_eh_info->flags */
	/* ata_eh_info->flags */
	ATA_EHI_HOTPLUGGED	= (1 << 0),  /* could have been hotplugged */
	ATA_EHI_HOTPLUGGED	= (1 << 0),  /* could have been hotplugged */
 Lines 742-749   extern int sata_scr_write_flush(struct a Link Here 
extern int ata_port_online(struct ata_port *ap);
extern int ata_port_online(struct ata_port *ap);
extern int ata_port_offline(struct ata_port *ap);
extern int ata_port_offline(struct ata_port *ap);
#ifdef CONFIG_PM
#ifdef CONFIG_PM
extern int ata_scsi_device_resume(struct scsi_device *);
extern int ata_scsi_device_suspend(struct scsi_device *, pm_message_t mesg);
extern int ata_host_suspend(struct ata_host *host, pm_message_t mesg);
extern int ata_host_suspend(struct ata_host *host, pm_message_t mesg);
extern void ata_host_resume(struct ata_host *host);
extern void ata_host_resume(struct ata_host *host);
#endif
#endif
 Lines 1018-1028   static inline unsigned int ata_dev_absen Link Here 
	return ata_class_absent(dev->class);
	return ata_class_absent(dev->class);
}
}
static inline unsigned int ata_dev_ready(const struct ata_device *dev)
{
	return ata_dev_enabled(dev) && !(dev->flags & ATA_DFLAG_SUSPENDED);
}
/*
/*
 * port helpers
 * port helpers
 */
 */
 * Check whether /sys/modules/libata/parameters/spindown_compat
 * Check whether /sys/modules/libata/parameters/spindown_compat
   exists.  If it does, write 0 to it.
   exists.  If it does, write 0 to it.
 * For each libata harddisk {
 * For each libata harddisk {
 }
 }
Documentation/feature-removal-schedule.txt |   19 +++++++++++++++++++
Documentation/feature-removal-schedule.txt |   19 +++++++++++++++++++
drivers/ata/libata-core.c                  |    6 ++++++
drivers/ata/libata-core.c                  |    6 ++++++
drivers/ata/libata-scsi.c                  |   28 +++++++++++++++++++++++++++-
drivers/ata/libata-scsi.c                  |   28 +++++++++++++++++++++++++++-
drivers/ata/libata.h                       |    1 +
drivers/ata/libata.h                       |    1 +
4 files changed, 53 insertions(+), 1 deletions(-)
4 files changed, 53 insertions(+), 1 deletions(-)
(-) a/Documentation/feature-removal-schedule.txt (+19 lines)
 Lines 314-316   Why: Code was merged, then submitter imm Link Here 
Who:	David S. Miller <davem@davemloft.net>
Who:	David S. Miller <davem@davemloft.net>
---------------------------
---------------------------
What:	libata.spindown_compat module parameter
When:	Dec 2008
Why:	halt(8) synchronizes caches for and spins down libata disks
	because libata didn't use to spin down disk on system halt
	(only synchronized caches).
	Spin down on system halt is now implemented and can be tested
	using sysfs node /sys/class/scsi_disk/h:c:i:l/manage_start_stop.
	Because issuing spin down command to an already spun down disk
	makes some disks spin up just to spin down again, the old
	behavior needs to be maintained till userspace tool is updated
	to check the sysfs node and not to spin down disks with the
	node set to one.
	This module parameter is to give userspace tool the time to
	get updated and should be removed after userspace is
	reasonably updated.
Who:	Tejun Heo <htejun@gmail.com>
---------------------------
(-) a/drivers/ata/libata-core.c (+6 lines)
 Lines 101-106   int libata_noacpi = 1; Link Here 
module_param_named(noacpi, libata_noacpi, int, 0444);
module_param_named(noacpi, libata_noacpi, int, 0444);
MODULE_PARM_DESC(noacpi, "Disables the use of ACPI in suspend/resume when set");
MODULE_PARM_DESC(noacpi, "Disables the use of ACPI in suspend/resume when set");
int ata_spindown_compat = 1;
module_param_named(spindown_compat, ata_spindown_compat, int, 0644);
MODULE_PARM_DESC(spindown_compat, "Enable backward compatible spindown "
		 "behavior.  Will be removed.  More info can be found in "
		 "Documentation/feature-removal-schedule.txt\n");
MODULE_AUTHOR("Jeff Garzik");
MODULE_AUTHOR("Jeff Garzik");
MODULE_DESCRIPTION("Library module for ATA devices");
MODULE_DESCRIPTION("Library module for ATA devices");
MODULE_LICENSE("GPL");
MODULE_LICENSE("GPL");
(-) a/drivers/ata/libata-scsi.c (-1 / +27 lines)
 Lines 944-952   static unsigned int ata_scsi_start_stop_ Link Here 
		}
		}
		tf->command = ATA_CMD_VERIFY;	/* READ VERIFY */
		tf->command = ATA_CMD_VERIFY;	/* READ VERIFY */
	} else
	} else {
		/* XXX: This is for backward compatibility, will be
		 * removed.  Read Documentation/feature-removal-schedule.txt
		 * for more info.
		 */
		if (ata_spindown_compat &&
		    (system_state == SYSTEM_HALT ||
		     system_state == SYSTEM_POWER_OFF)) {
			static int warned = 0;
			if (!warned) {
				spin_unlock_irq(qc->ap->lock);
				ata_dev_printk(qc->dev, KERN_WARNING,
					"DISK MIGHT NOT BE SPUN DOWN PROPERLY. "
					"UPDATE SHUTDOWN UTILITY\n");
				ata_dev_printk(qc->dev, KERN_WARNING,
					"For more info, visit "
					"http://linux-ata.org/shutdown.html\n");
				warned = 1;
				ssleep(5);
				spin_lock_irq(qc->ap->lock);
			}
			scmd->result = SAM_STAT_GOOD;
			return 1;
		}
		/* Issue ATA STANDBY IMMEDIATE command */
		/* Issue ATA STANDBY IMMEDIATE command */
		tf->command = ATA_CMD_STANDBYNOW1;
		tf->command = ATA_CMD_STANDBYNOW1;
	}
	/*
	/*
	 * Standby and Idle condition timers could be implemented but that
	 * Standby and Idle condition timers could be implemented but that
(-) a/drivers/ata/libata.h (+1 lines)
 Lines 58-63   extern int atapi_enabled; Link Here 
extern int atapi_dmadir;
extern int atapi_dmadir;
extern int libata_fua;
extern int libata_fua;
extern int libata_noacpi;
extern int libata_noacpi;
extern int ata_spindown_compat;
extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev);
extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev);
extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev,
extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev,
			   u64 block, u32 n_block, unsigned int tf_flags,
			   u64 block, u32 n_block, unsigned int tf_flags,