Messages in this thread | | | Date | Fri, 22 Jan 1999 16:53:47 +0200 (IST) | From | Gadi Oxman <> | Subject | Re: ide-probe.c logic wrong? |
| |
Hi,
On Fri, 22 Jan 1999, Edmund GRIMLEY EVANS wrote:
> I discovered the hard way that strstr() was broken in pre8, so I > suppose my LS-120 drive will work again with pre9, but I still think > this bit of code in ide-probe.c is wrong:
No, the current kernel code is correct. ATAPI devices are self identifying, and report their type in response to the the ATAPI IDENTIFY device command. At that point in the code, the drive type will be in the "type" local variable":
0 - IDE floppy, 1 - IDE tape, 5 - IDE cdrom
The goal of the function is to set "drive->media" to the drive type, so that theoretically we could have just done:
drive->media = type
However, early CDROM devices identified themself as "type 0", which requires special logic to decide between ATAPI CDROM and floppy drives.
This problem was identified in SFF8070, the ATAPI floppy specs, and to help solve it, the specification required that the drive name will contain the string "floppy" for ATAPI floppy drives. Nevertheless, we have ATAPI drives with type 0 which don't include it, such as the ATAPI ZIP drive. Therefore, in the absence of a hint from the user using a kernel command line parameter:
If the string contains the word "CD-ROM", we identify the drive as a CDROM (this will correctly identify the pre-ATAPI NEC 260 cdrom model). Otherwise, it is identified as a floppy, to be compatible with new drives.
If the user supplied a "hdx=cdrom" command line paramter, drive->media will be set to ide_cdrom at this point, and we will follow the user's selection regardless of both the drive's identification type and the strstr logic.
Gadi
> switch (type) { > case ide_floppy: > if (!strstr(id->model, "CD-ROM")) { > if (!strstr(id->model, "oppy") && > !strstr(id->model, "poyp") && !strstr(id->model, "ZIP")) > printk("cdrom or floppy?, assuming "); > if (drive->media != ide_cdrom) { > printk ("FLOPPY"); > break; > } > } > type = ide_cdrom; /* Early cdrom models used zero > */ > case ide_cdrom: > > > Suppose drive->media is equal to ide_cdrom. > > Suppose id->model contains none of the substrings mentioned. > > Then the code prints "... assuming " and sets the type to ide_cdrom. > > Now suppose id->model contains "oppy" but none of the other substrings. > > Then the code DOESN'T print "... assuming ", but it STILL sets the type > to ide_cdrom. > > This doesn't make sense! > > Here is what I suspect was intended: > > > switch (type) { > case ide_floppy: > if (strstr(id->model, "CD-ROM")) goto cdrom; > if (!strstr(id->model, "oppy") && !strstr(id->model, > "poyp") && !strstr(id->model, "ZIP")) { > printk("cdrom or floppy?, assuming "); > if (drive->media == ide_cdrom) goto cdrom; > } > printk ("FLOPPY"); > break; > cdrom: > type = ide_cdrom; /* Early cdrom models used zero > */ > case ide_cdrom: > > > Edmund > > - > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.rutgers.edu > Please read the FAQ at http://www.tux.org/lkml/ > >
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |