From: Ben Gras Date: Tue, 26 Jul 2005 13:11:16 +0000 (+0000) Subject: Added an IDENTIFIED flag that is set on successfully identified drives. X-Git-Tag: v3.1.0~539 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/doxygen.log?a=commitdiff_plain;h=435dd377eda0eb265fb14952e605c6525348f8db;p=minix.git Added an IDENTIFIED flag that is set on successfully identified drives. This avoids the bug scenario where DEAF but not-w_identify()d drives are never properly identified, but are seen as real devices. --- diff --git a/drivers/at_wini/at_wini.c b/drivers/at_wini/at_wini.c index bcce7aa44..b7499c6b1 100644 --- a/drivers/at_wini/at_wini.c +++ b/drivers/at_wini/at_wini.c @@ -167,6 +167,7 @@ int wakeup_ticks = WAKEUP; #else #define ATAPI 0 /* don't bother with ATAPI; optimise out */ #endif +#define IDENTIFIED 0x10 /* w_identify done successfully */ int timeout_ticks = DEF_TIMEOUT_TICKS, max_errors = MAX_ERRORS; @@ -317,16 +318,18 @@ message *m_ptr; struct wini *wn; if (w_prepare(m_ptr->DEVICE) == NIL_DEV) return(ENXIO); + wn = w_wn; - if (wn->state == 0) { + if (!(wn->state & (IDENTIFIED)) || (wn->state & DEAF)) { /* Try to identify the device. */ if (w_identify() != OK) { - printf("%s: probe failed\n", w_name()); + printf("%s: probe failed\n", w_name()); if (wn->state & DEAF) w_reset(); wn->state = 0; return(ENXIO); } + } if (wn->open_ct == 0) { #if ENABLE_ATAPI @@ -448,7 +451,7 @@ PRIVATE int w_identify() /* Not an ATA device; no translations, no special features. Don't * touch it unless the BIOS knows about it. */ - if (wn->lcylinders == 0) return(ERR); /* no BIOS parameters */ + if (wn->lcylinders == 0) { return(ERR); } /* no BIOS parameters */ wn->pcylinders = wn->lcylinders; wn->pheads = wn->lheads; wn->psectors = wn->lsectors; @@ -458,7 +461,9 @@ PRIVATE int w_identify() /* Size of the whole drive */ wn->part[0].dv_size = mul64u(size, SECTOR_SIZE); - if (w_specify() != OK && w_specify() != OK) return(ERR); + if (w_specify() != OK && w_specify() != OK) { + return(ERR); + } printf("%s: user-space AT Winchester driver detected ", w_name()); if (wn->state & (SMART|ATAPI)) { @@ -473,6 +478,7 @@ PRIVATE int w_identify() panic(w_name(), "coudn't set IRQ policy", s); if ((s=sys_irqenable(&wn->irq_hook_id)) != OK) panic(w_name(), "coudn't enable IRQ line", s); + wn->state |= IDENTIFIED; return(OK); }