mi/util.c
// calculate the idle timer value to send to the drive.
calculate the idle timer value to send to the drive.
calculate the idle timer value to send to the drive .
int32_t 
ata_getidleval(uint32_t idle_mins, uint16_t *timer_val)
{
	int32_t rc = 0;
	if( idle_mins == 0 )
		*timer_val = 0;
	if( idle_mins <= 20 )
		*timer_val = (idle_mins*60)/5;
	if( idle_mins == 21 )
		*timer_val = 252;
	if( (idle_mins > 21) && (idle_mins < 30) ) {
		printf("cannot set timeout for values 20-30 minutes\n" );
		rc = -2;
	}
	if( idle_mins >= 30 ) {
		if( (((idle_mins % 30) != 0) || (idle_mins > 330)) && (idle_mins != ATA_IDLEVAL_IMMEDIATE) ) {
			printf( "idle value must be a multiple of 30 minutes, "
					"up to 5 hours\n" );
			rc = -2;
		}
		if(idle_mins == ATA_IDLEVAL_IMMEDIATE)
			*timer_val = ATA_IDLEVAL_IMMEDIATE;
		else
			*timer_val = 241 + (idle_mins/30);
	}
	return rc;
}
int32_t ata_getidleval ( uint32_t idle_mins , uint16_t * timer_val ) { int32_t rc = 0 ; if ( idle_mins == 0 ) * timer_val = 0 ; if ( idle_mins <= 20 ) * timer_val = ( idle_mins * 60 ) / 5 ; if ( idle_mins == 21 ) * timer_val = 252 ; if ( ( idle_mins > 21 ) && ( idle_mins < 30 ) ) { printf ( " \n " ) ; rc = -2 ; } if ( idle_mins >= 30 ) { if ( ( ( ( idle_mins % 30 ) != 0 ) || ( idle_mins > 330 ) ) && ( idle_mins != ATA_IDLEVAL_IMMEDIATE ) ) { printf ( " " " \n " ) ; rc = -2 ; } if ( idle_mins == ATA_IDLEVAL_IMMEDIATE ) * timer_val = ATA_IDLEVAL_IMMEDIATE ; else * timer_val = 241 + ( idle_mins / 30 ) ; } return rc ; }
calculate the idle timer value to send to the drive.
calculate the idle timer value to send to the drive .
// idle value of 0 disabled spindown // value is (value*5)s between 1 and 20 minutes // special case for 21 minutes // there is no encoding for values between 21 and 30 minutes // after 30 mins, encoding is (idle_mins-29)*30, so you // can only encode multiples of 30 minutes // if it's not a multiple of 30 minutes, or it's greater than 5 hours, // we can't handle it. // otherwise, calculate the timer value