From 04c923e6c53ed6d2d794decfac6c399f21122c85 Mon Sep 17 00:00:00 2001 From: sos Date: Tue, 13 Jan 2004 21:35:39 +0000 Subject: [PATCH] Fix ata_getparam to accept the fact that some crappy devices can pose as both master and slave at the same time confusing the probe code. --- sys/dev/ata/ata-all.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/sys/dev/ata/ata-all.c b/sys/dev/ata/ata-all.c index 05f40c297d0c..f8bccf18b592 100644 --- a/sys/dev/ata/ata-all.c +++ b/sys/dev/ata/ata-all.c @@ -563,13 +563,13 @@ ata_getparam(struct ata_device *atadev, u_int8_t command) if (request) { request->device = atadev; request->u.ata.command = command; - request->flags = (ATA_R_READ | ATA_R_AT_HEAD); + request->flags = (ATA_R_READ | ATA_R_AT_HEAD | ATA_R_QUIET); request->data = (caddr_t)atadev->param; request->timeout = 2; request->retries = 3; request->bytecount = sizeof(struct ata_params); request->transfersize = DEV_BSIZE; - while (request->retries) { + while (request->retries > 0 ) { ata_queue_request(request); if (!(error = request->result)) break; @@ -577,14 +577,8 @@ ata_getparam(struct ata_device *atadev, u_int8_t command) } ata_free_request(request); } - if (!isprint(atadev->param->model[0]) || - !isprint(atadev->param->model[1])) - error = ENXIO; - if (error) { - free(atadev->param, M_ATA); - atadev->param = NULL; - } - else { + if (!error && (isprint(atadev->param->model[0]) || + isprint(atadev->param->model[1]))) { struct ata_params *atacap = atadev->param; #if BYTE_ORDER == BIG_ENDIAN int16_t *ptr; @@ -613,6 +607,14 @@ ata_getparam(struct ata_device *atadev, u_int8_t command) ata_umode(atacap), (atacap->hwres & ATA_CABLE_ID) ? "80":"40"); } + else { + if (!error) + error = ENXIO; + if (atadev->param) { + free(atadev->param, M_ATA); + atadev->param = NULL; + } + } } return error; }