diff options
-rw-r--r-- | drivers/ide/ide-atapi.c | 47 | ||||
-rw-r--r-- | drivers/ide/ide-floppy.c | 48 | ||||
-rw-r--r-- | drivers/ide/ide-tape.c | 43 | ||||
-rw-r--r-- | include/linux/ide.h | 2 |
4 files changed, 55 insertions, 85 deletions
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c index 12674e6519e6..61c52fb665ca 100644 --- a/drivers/ide/ide-atapi.c +++ b/drivers/ide/ide-atapi.c | |||
@@ -14,6 +14,53 @@ | |||
14 | #define debug_log(fmt, args...) do {} while (0) | 14 | #define debug_log(fmt, args...) do {} while (0) |
15 | #endif | 15 | #endif |
16 | 16 | ||
17 | /* | ||
18 | * Check whether we can support a device, | ||
19 | * based on the ATAPI IDENTIFY command results. | ||
20 | */ | ||
21 | int ide_check_atapi_device(ide_drive_t *drive, const char *s) | ||
22 | { | ||
23 | u16 *id = drive->id; | ||
24 | u8 gcw[2], protocol, device_type, removable, drq_type, packet_size; | ||
25 | |||
26 | *((u16 *)&gcw) = id[ATA_ID_CONFIG]; | ||
27 | |||
28 | protocol = (gcw[1] & 0xC0) >> 6; | ||
29 | device_type = gcw[1] & 0x1F; | ||
30 | removable = (gcw[0] & 0x80) >> 7; | ||
31 | drq_type = (gcw[0] & 0x60) >> 5; | ||
32 | packet_size = gcw[0] & 0x03; | ||
33 | |||
34 | #ifdef CONFIG_PPC | ||
35 | /* kludge for Apple PowerBook internal zip */ | ||
36 | if (drive->media == ide_floppy && device_type == 5 && | ||
37 | !strstr((char *)&id[ATA_ID_PROD], "CD-ROM") && | ||
38 | strstr((char *)&id[ATA_ID_PROD], "ZIP")) | ||
39 | device_type = 0; | ||
40 | #endif | ||
41 | |||
42 | if (protocol != 2) | ||
43 | printk(KERN_ERR "%s: %s: protocol (0x%02x) is not ATAPI\n", | ||
44 | s, drive->name, protocol); | ||
45 | else if ((drive->media == ide_floppy && device_type != 0) || | ||
46 | (drive->media == ide_tape && device_type != 1)) | ||
47 | printk(KERN_ERR "%s: %s: invalid device type (0x%02x)\n", | ||
48 | s, drive->name, device_type); | ||
49 | else if (removable == 0) | ||
50 | printk(KERN_ERR "%s: %s: the removable flag is not set\n", | ||
51 | s, drive->name); | ||
52 | else if (drive->media == ide_floppy && drq_type == 3) | ||
53 | printk(KERN_ERR "%s: %s: sorry, DRQ type (0x%02x) not " | ||
54 | "supported\n", s, drive->name, drq_type); | ||
55 | else if (packet_size != 0) | ||
56 | printk(KERN_ERR "%s: %s: packet size (0x%02x) is not 12 " | ||
57 | "bytes\n", s, drive->name, packet_size); | ||
58 | else | ||
59 | return 1; | ||
60 | return 0; | ||
61 | } | ||
62 | EXPORT_SYMBOL_GPL(ide_check_atapi_device); | ||
63 | |||
17 | /* TODO: unify the code thus making some arguments go away */ | 64 | /* TODO: unify the code thus making some arguments go away */ |
18 | ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc, | 65 | ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc, |
19 | ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry, | 66 | ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry, |
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index de8d42b3f698..ace6f26a296a 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c | |||
@@ -15,6 +15,8 @@ | |||
15 | * Documentation/ide/ChangeLog.ide-floppy.1996-2002 | 15 | * Documentation/ide/ChangeLog.ide-floppy.1996-2002 |
16 | */ | 16 | */ |
17 | 17 | ||
18 | #define DRV_NAME "ide-floppy" | ||
19 | |||
18 | #define IDEFLOPPY_VERSION "1.00" | 20 | #define IDEFLOPPY_VERSION "1.00" |
19 | 21 | ||
20 | #include <linux/module.h> | 22 | #include <linux/module.h> |
@@ -962,50 +964,6 @@ static sector_t idefloppy_capacity(ide_drive_t *drive) | |||
962 | return capacity; | 964 | return capacity; |
963 | } | 965 | } |
964 | 966 | ||
965 | /* | ||
966 | * Check whether we can support a drive, based on the ATAPI IDENTIFY command | ||
967 | * results. | ||
968 | */ | ||
969 | static int idefloppy_identify_device(ide_drive_t *drive, u16 *id) | ||
970 | { | ||
971 | u8 gcw[2]; | ||
972 | u8 device_type, protocol, removable, drq_type, packet_size; | ||
973 | |||
974 | *((u16 *)&gcw) = id[ATA_ID_CONFIG]; | ||
975 | |||
976 | device_type = gcw[1] & 0x1F; | ||
977 | removable = (gcw[0] & 0x80) >> 7; | ||
978 | protocol = (gcw[1] & 0xC0) >> 6; | ||
979 | drq_type = (gcw[0] & 0x60) >> 5; | ||
980 | packet_size = gcw[0] & 0x03; | ||
981 | |||
982 | #ifdef CONFIG_PPC | ||
983 | /* kludge for Apple PowerBook internal zip */ | ||
984 | if (device_type == 5 && | ||
985 | !strstr((char *)&id[ATA_ID_PROD], "CD-ROM") && | ||
986 | strstr((char *)&id[ATA_ID_PROD], "ZIP")) | ||
987 | device_type = 0; | ||
988 | #endif | ||
989 | |||
990 | if (protocol != 2) | ||
991 | printk(KERN_ERR "ide-floppy: Protocol (0x%02x) is not ATAPI\n", | ||
992 | protocol); | ||
993 | else if (device_type != 0) | ||
994 | printk(KERN_ERR "ide-floppy: Device type (0x%02x) is not set " | ||
995 | "to floppy\n", device_type); | ||
996 | else if (!removable) | ||
997 | printk(KERN_ERR "ide-floppy: The removable flag is not set\n"); | ||
998 | else if (drq_type == 3) | ||
999 | printk(KERN_ERR "ide-floppy: Sorry, DRQ type (0x%02x) not " | ||
1000 | "supported\n", drq_type); | ||
1001 | else if (packet_size != 0) | ||
1002 | printk(KERN_ERR "ide-floppy: Packet size (0x%02x) is not 12 " | ||
1003 | "bytes\n", packet_size); | ||
1004 | else | ||
1005 | return 1; | ||
1006 | return 0; | ||
1007 | } | ||
1008 | |||
1009 | #ifdef CONFIG_IDE_PROC_FS | 967 | #ifdef CONFIG_IDE_PROC_FS |
1010 | ide_devset_rw(bios_cyl, 0, 1023, bios_cyl); | 968 | ide_devset_rw(bios_cyl, 0, 1023, bios_cyl); |
1011 | ide_devset_rw(bios_head, 0, 255, bios_head); | 969 | ide_devset_rw(bios_head, 0, 255, bios_head); |
@@ -1407,7 +1365,7 @@ static int ide_floppy_probe(ide_drive_t *drive) | |||
1407 | if (drive->media != ide_floppy) | 1365 | if (drive->media != ide_floppy) |
1408 | goto failed; | 1366 | goto failed; |
1409 | 1367 | ||
1410 | if (!idefloppy_identify_device(drive, drive->id)) { | 1368 | if (!ide_check_atapi_device(drive, DRV_NAME)) { |
1411 | printk(KERN_ERR "ide-floppy: %s: not supported by this version" | 1369 | printk(KERN_ERR "ide-floppy: %s: not supported by this version" |
1412 | " of ide-floppy\n", drive->name); | 1370 | " of ide-floppy\n", drive->name); |
1413 | goto failed; | 1371 | goto failed; |
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 1fc1c2a6888f..7f56f2003342 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -15,6 +15,8 @@ | |||
15 | * Documentation/ide/ChangeLog.ide-tape.1995-2002 | 15 | * Documentation/ide/ChangeLog.ide-tape.1995-2002 |
16 | */ | 16 | */ |
17 | 17 | ||
18 | #define DRV_NAME "ide-tape" | ||
19 | |||
18 | #define IDETAPE_VERSION "1.20" | 20 | #define IDETAPE_VERSION "1.20" |
19 | 21 | ||
20 | #include <linux/module.h> | 22 | #include <linux/module.h> |
@@ -2296,45 +2298,6 @@ static int idetape_chrdev_release(struct inode *inode, struct file *filp) | |||
2296 | return 0; | 2298 | return 0; |
2297 | } | 2299 | } |
2298 | 2300 | ||
2299 | /* | ||
2300 | * check the contents of the ATAPI IDENTIFY command results. We return: | ||
2301 | * | ||
2302 | * 1 - If the tape can be supported by us, based on the information we have so | ||
2303 | * far. | ||
2304 | * | ||
2305 | * 0 - If this tape driver is not currently supported by us. | ||
2306 | */ | ||
2307 | static int idetape_identify_device(ide_drive_t *drive) | ||
2308 | { | ||
2309 | u8 gcw[2], protocol, device_type, removable, packet_size; | ||
2310 | |||
2311 | if (drive->id_read == 0) | ||
2312 | return 1; | ||
2313 | |||
2314 | *((u16 *)&gcw) = drive->id[ATA_ID_CONFIG]; | ||
2315 | |||
2316 | protocol = (gcw[1] & 0xC0) >> 6; | ||
2317 | device_type = gcw[1] & 0x1F; | ||
2318 | removable = !!(gcw[0] & 0x80); | ||
2319 | packet_size = gcw[0] & 0x3; | ||
2320 | |||
2321 | /* Check that we can support this device */ | ||
2322 | if (protocol != 2) | ||
2323 | printk(KERN_ERR "ide-tape: Protocol (0x%02x) is not ATAPI\n", | ||
2324 | protocol); | ||
2325 | else if (device_type != 1) | ||
2326 | printk(KERN_ERR "ide-tape: Device type (0x%02x) is not set " | ||
2327 | "to tape\n", device_type); | ||
2328 | else if (!removable) | ||
2329 | printk(KERN_ERR "ide-tape: The removable flag is not set\n"); | ||
2330 | else if (packet_size != 0) { | ||
2331 | printk(KERN_ERR "ide-tape: Packet size (0x%02x) is not 12" | ||
2332 | " bytes\n", packet_size); | ||
2333 | } else | ||
2334 | return 1; | ||
2335 | return 0; | ||
2336 | } | ||
2337 | |||
2338 | static void idetape_get_inquiry_results(ide_drive_t *drive) | 2301 | static void idetape_get_inquiry_results(ide_drive_t *drive) |
2339 | { | 2302 | { |
2340 | idetape_tape_t *tape = drive->driver_data; | 2303 | idetape_tape_t *tape = drive->driver_data; |
@@ -2679,7 +2642,7 @@ static int ide_tape_probe(ide_drive_t *drive) | |||
2679 | if (drive->media != ide_tape) | 2642 | if (drive->media != ide_tape) |
2680 | goto failed; | 2643 | goto failed; |
2681 | 2644 | ||
2682 | if (!idetape_identify_device(drive)) { | 2645 | if (drive->id_read == 1 && !ide_check_atapi_device(drive, DRV_NAME)) { |
2683 | printk(KERN_ERR "ide-tape: %s: not supported by this version of" | 2646 | printk(KERN_ERR "ide-tape: %s: not supported by this version of" |
2684 | " the driver\n", drive->name); | 2647 | " the driver\n", drive->name); |
2685 | goto failed; | 2648 | goto failed; |
diff --git a/include/linux/ide.h b/include/linux/ide.h index 40102bd50a70..e63ff63d1f0b 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h | |||
@@ -1109,6 +1109,8 @@ extern int drive_is_ready(ide_drive_t *); | |||
1109 | 1109 | ||
1110 | void ide_pktcmd_tf_load(ide_drive_t *, u32, u16, u8); | 1110 | void ide_pktcmd_tf_load(ide_drive_t *, u32, u16, u8); |
1111 | 1111 | ||
1112 | int ide_check_atapi_device(ide_drive_t *, const char *); | ||
1113 | |||
1112 | ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc, | 1114 | ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc, |
1113 | ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry, | 1115 | ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry, |
1114 | void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *), | 1116 | void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *), |