mi/util.c
int32_t 
ata_setstandby(struct ATA *ata, uint32_t chan, uint32_t dev, uint32_t standby_mins)
{
	uint16_t timer_val = 0;
	int32_t rc = 0;

	rc = ata_getidleval( standby_mins, &timer_val );	

	if (timer_val == ATA_IDLEVAL_IMMEDIATE)
		ata_setataparams(ata, 0, 0);
	else
		ata_setataparams(ata, timer_val, 0);

	// send the STANDBY command to the drive
	if(!rc) {
		if(timer_val == ATA_IDLEVAL_IMMEDIATE)
			rc = ata_cmd(ata, chan, dev, ATA_STANDBY_IMMEDIATE, 0);
		else
			rc = ata_cmd(ata, chan, dev, ATA_STANDBY, 0);
	}	
	if(rc) {
 		perror("error setting idle timeout");
	} else {
		if( timer_val == ATA_IDLEVAL_IMMEDIATE )
				printf("set chan %d, dev %d to standby immediately\n",
					chan, dev);
		else if(timer_val == 0)
			printf("turned off standby timer on chan %d, dev %d\n", 
						chan, dev);
		else
			printf("set chan %d, dev %d to standby after %d minutes\n", 
					chan, dev, standby_mins);
	}
	return rc;
}
// command the device to spindown after standby_mins of no disk activity
command the device to spindown after standby_mins of no disk activity
command the device to spindown after standby_mins of no disk activity
int32_t 
ata_setstandby(struct ATA *ata, uint32_t chan, uint32_t dev, uint32_t standby_mins)
{
	uint16_t timer_val = 0;
	int32_t rc = 0;
	rc = ata_getidleval( standby_mins, &timer_val );	
	if (timer_val == ATA_IDLEVAL_IMMEDIATE)
		ata_setataparams(ata, 0, 0);
	else
		ata_setataparams(ata, timer_val, 0);
	if(!rc) {
		if(timer_val == ATA_IDLEVAL_IMMEDIATE)
			rc = ata_cmd(ata, chan, dev, ATA_STANDBY_IMMEDIATE, 0);
		else
			rc = ata_cmd(ata, chan, dev, ATA_STANDBY, 0);
	}	
	if(rc) {
 		perror("error setting idle timeout");
	} else {
		if( timer_val == ATA_IDLEVAL_IMMEDIATE )
				printf("set chan %d, dev %d to standby immediately\n",
					chan, dev);
		else if(timer_val == 0)
			printf("turned off standby timer on chan %d, dev %d\n", 
						chan, dev);
		else
			printf("set chan %d, dev %d to standby after %d minutes\n", 
					chan, dev, standby_mins);
	}
	return rc;
}
int32_t ata_setstandby ( struct ATA * ata , uint32_t chan , uint32_t dev , uint32_t standby_mins ) { uint16_t timer_val = 0 ; int32_t rc = 0 ; rc = ata_getidleval ( standby_mins , & timer_val ) ; if ( timer_val == ATA_IDLEVAL_IMMEDIATE ) ata_setataparams ( ata , 0 , 0 ) ; else ata_setataparams ( ata , timer_val , 0 ) ; if ( ! rc ) { if ( timer_val == ATA_IDLEVAL_IMMEDIATE ) rc = ata_cmd ( ata , chan , dev , ATA_STANDBY_IMMEDIATE , 0 ) ; else rc = ata_cmd ( ata , chan , dev , ATA_STANDBY , 0 ) ; } if ( rc ) { perror ( " " ) ; } else { if ( timer_val == ATA_IDLEVAL_IMMEDIATE ) printf ( " \n " , chan , dev ) ; else if ( timer_val == 0 ) printf ( " \n " , chan , dev ) ; else printf ( " \n " , chan , dev , standby_mins ) ; } return rc ; }
command the device to spindown after standby_mins of no disk activity
command the device to spindown after standby_mins of no disk activity
// send the STANDBY command to the drive