/* In case of error returns error value after doing "*startstop = ide_error()". The caller should return the updated value of "startstop" in this case, "startstop" is unchanged when the function returns 0.  */
int ide_wait_stat(ide_startstop_t *startstop, ide_drive_t *drive, u8 good, u8 bad, unsigned long timeout)
/* In case of error returns error value after doing "*startstop = ide_error()". The caller should return the updated value of "startstop" in this case, "startstop" is unchanged when the function returns 0.  */
int ide_wait_stat(ide_startstop_t *startstop, ide_drive_t *drive, u8 good, u8 bad, unsigned long timeout)
{
	int err;
	u8 stat;
	if (drive->max_failures && (drive->failures > drive->max_failures)) {
		*startstop = ide_stopped;
		return 1;
	}
	err = __ide_wait_stat(drive, good, bad, timeout, &stat);
	if (err) {
		char *s = (err == -EBUSY) ? "status timeout" : "status error";
		*startstop = ide_error(drive, s, stat);
	}
	return err;
}