コード例 #1
0
int ftape_activate_drive(vendor_struct * drive_type)
{
	int result = 0;
	TRACE_FUN(ft_t_flow);

	/* If we already know the drive type, wake it up.
	 * Else try to find out what kind of drive is attached.
	 */
	if (drive_type->wake_up != unknown_wake_up) {
		TRACE(ft_t_flow, "enabling tape drive and fdc");
		result = ftape_wakeup_drive(drive_type->wake_up);
		if (result < 0) {
			TRACE(ft_t_err, "known wakeup method failed");
		}
	} else {
		wake_up_types method;
		const ft_trace_t old_tracing = TRACE_LEVEL;
		if (TRACE_LEVEL < ft_t_flow) {
			SET_TRACE_LEVEL(ft_t_bug);
		}

		/*  Try to awaken the drive using all known methods.
		 *  Lower tracing for a while.
		 */
		for (method=no_wake_up; method < NR_ITEMS(methods); ++method) {
			drive_type->wake_up = method;
#ifdef CONFIG_FT_TWO_DRIVES
			/*  Test setup for dual drive configuration.
			 *  /dev/rft2 uses mountain wakeup
			 *  /dev/rft3 uses colorado wakeup
			 *  Other systems will use the normal scheme.
			 */
			if ((ft_drive_sel < 2)                            ||
			    (ft_drive_sel == 2 && method == FT_WAKE_UP_1) ||
			    (ft_drive_sel == 3 && method == FT_WAKE_UP_2)) {
				result=ftape_wakeup_drive(drive_type->wake_up);
			} else {
				result = -EIO;
			}
#else
			result = ftape_wakeup_drive(drive_type->wake_up);
#endif
			if (result >= 0) {
				TRACE(ft_t_warn, "drive wakeup method: %s",
				      methods[drive_type->wake_up].name);
				break;
			}
		}
		SET_TRACE_LEVEL(old_tracing);

		if (method >= NR_ITEMS(methods)) {
			/* no response at all, cannot open this drive */
			drive_type->wake_up = unknown_wake_up;
			TRACE(ft_t_err, "no tape drive found !");
			result = -ENODEV;
		}
	}
	TRACE_EXIT result;
}
コード例 #2
0
ファイル: ftape-ctl.c プロジェクト: robacklin/uclinux-linux
int ftape_activate_drive(vendor_struct * drive_type)
{
	TRACE_FUN(5, "ftape_activate_drive");
	int result = 0;

	/* If we already know the drive type, wake it up.
	 * Else try to find out what kind of drive is attached.
	 */
	if (drive_type->wake_up != unknown_wake_up) {
		TRACE(5, "enabling tape drive and fdc");
		result = ftape_wakeup_drive(drive_type->wake_up);
		if (result < 0) {
			TRACE(1, "known wakeup method failed");
		}
	} else {
		int old_tracing = tracing;
		wake_up_types method;

		/*  Try to awaken the drive using all known methods.
		 *  Lower tracing for a while.
		 */
		if (tracing <= 4) {
			tracing = 0;
		}
		for (method = no_wake_up; method < NR_ITEMS(methods); ++method) {
			drive_type->wake_up = method;
#if 0
			/*  Test setup for dual drive configuration in dodo.
			 *  /dev/rft2 uses mountain wakeup only -> Archive QIC-80
			 *  /dev/rft3 uses colorado wakeup only -> Jumbo QIC-40
			 *  Other systems will use the normal scheme.
			 */
			if ((FTAPE_UNIT < 2) ||
			(FTAPE_UNIT == 2 && method == wake_up_mountain) ||
			(FTAPE_UNIT == 3 && method == wake_up_colorado)) {
				result = ftape_wakeup_drive(drive_type->wake_up);
			} else {
				result = -EIO;
			}
#else
			result = ftape_wakeup_drive(drive_type->wake_up);
#endif
			if (result >= 0) {
				int tracing = old_tracing;	/* fool TRACE */
				TRACEx1(2, "drive wakeup method: %s",
				      methods[drive_type->wake_up].name);
				break;
			}
		}
		tracing = old_tracing;
		if (method >= NR_ITEMS(methods)) {
			/* no response at all, cannot open this drive */
			drive_type->wake_up = unknown_wake_up;
			TRACE(1, "no tape drive found !");
			tracing = old_tracing;
			result = -ENODEV;
		}
	}
	TRACE_EXIT;
	return result;
}