aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-floppy.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-10 16:39:34 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-10 16:39:34 -0400
commit51509eec34debffec3c6f481f7371c9aeb6c63c1 (patch)
tree94728b2030fadb1f59d5d171541af9518d194366 /drivers/ide/ide-floppy.c
parent05236ea6df7419f0f37cf9603cfee265cfce5832 (diff)
ide: add ide_check_atapi_device() helper
* Add ide_check_atapi_device() to ide-atapi.c and convert ide-{floppy,tape}.c to use it instead of ide*_identify_device(). While at it: * Add DRV_NAME defines to ide-{floppy,tape}.c. Cc: Borislav Petkov <petkovbb@gmail.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-floppy.c')
-rw-r--r--drivers/ide/ide-floppy.c48
1 files changed, 3 insertions, 45 deletions
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 */
969static 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
1010ide_devset_rw(bios_cyl, 0, 1023, bios_cyl); 968ide_devset_rw(bios_cyl, 0, 1023, bios_cyl);
1011ide_devset_rw(bios_head, 0, 255, bios_head); 969ide_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;