Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge git://git.kernel.org/pub/scm/linux/kernel/git/bart/linux-hdreg-h-cleanup

* git://git.kernel.org/pub/scm/linux/kernel/git/bart/linux-hdreg-h-cleanup:
remove <linux/ata.h> include from <linux/hdreg.h>
include/linux/hdreg.h: remove unused defines
isd200: use ATA_* defines instead of *_STAT and *_ERR ones
include/linux/hdreg.h: cover WIN_* and friends with #ifndef/#endif __KERNEL__
aoe: WIN_* -> ATA_CMD_*
isd200: WIN_* -> ATA_CMD_*
include/linux/hdreg.h: cover struct hd_driveid with #ifndef/#endif __KERNEL__
xsysace: make it 'struct hd_driveid'-free
ubd_kern: make it 'struct hd_driveid'-free
isd200: make it 'struct hd_driveid'-free

+116 -254
+6 -6
arch/um/drivers/ubd_kern.c
··· 22 22 #include "linux/kernel.h" 23 23 #include "linux/module.h" 24 24 #include "linux/blkdev.h" 25 + #include "linux/ata.h" 25 26 #include "linux/hdreg.h" 26 27 #include "linux/init.h" 27 28 #include "linux/cdrom.h" ··· 1309 1308 unsigned int cmd, unsigned long arg) 1310 1309 { 1311 1310 struct ubd *ubd_dev = bdev->bd_disk->private_data; 1312 - struct hd_driveid ubd_id = { 1313 - .cyls = 0, 1314 - .heads = 128, 1315 - .sectors = 32, 1316 - }; 1311 + u16 ubd_id[ATA_ID_WORDS]; 1317 1312 1318 1313 switch (cmd) { 1319 1314 struct cdrom_volctrl volume; 1320 1315 case HDIO_GET_IDENTITY: 1321 - ubd_id.cyls = ubd_dev->size / (128 * 32 * 512); 1316 + memset(&ubd_id, 0, ATA_ID_WORDS * 2); 1317 + ubd_id[ATA_ID_CYLS] = ubd_dev->size / (128 * 32 * 512); 1318 + ubd_id[ATA_ID_HEADS] = 128; 1319 + ubd_id[ATA_ID_SECTORS] = 32; 1322 1320 if(copy_to_user((char __user *) arg, (char *) &ubd_id, 1323 1321 sizeof(ubd_id))) 1324 1322 return -EFAULT;
+12 -11
drivers/block/aoe/aoecmd.c
··· 4 4 * Filesystem request handling methods 5 5 */ 6 6 7 + #include <linux/ata.h> 7 8 #include <linux/hdreg.h> 8 9 #include <linux/blkdev.h> 9 10 #include <linux/skbuff.h> ··· 268 267 writebit = 0; 269 268 } 270 269 271 - ah->cmdstat = WIN_READ | writebit | extbit; 270 + ah->cmdstat = ATA_CMD_PIO_READ | writebit | extbit; 272 271 273 272 /* mark all tracking fields and load out */ 274 273 buf->nframesout += 1; ··· 363 362 switch (ah->cmdstat) { 364 363 default: 365 364 break; 366 - case WIN_READ: 367 - case WIN_READ_EXT: 368 - case WIN_WRITE: 369 - case WIN_WRITE_EXT: 365 + case ATA_CMD_PIO_READ: 366 + case ATA_CMD_PIO_READ_EXT: 367 + case ATA_CMD_PIO_WRITE: 368 + case ATA_CMD_PIO_WRITE_EXT: 370 369 put_lba(ah, f->lba); 371 370 372 371 n = f->bcnt; ··· 813 812 d->htgt = NULL; 814 813 n = ahout->scnt << 9; 815 814 switch (ahout->cmdstat) { 816 - case WIN_READ: 817 - case WIN_READ_EXT: 815 + case ATA_CMD_PIO_READ: 816 + case ATA_CMD_PIO_READ_EXT: 818 817 if (skb->len - sizeof *hin - sizeof *ahin < n) { 819 818 printk(KERN_ERR 820 819 "aoe: %s. skb->len=%d need=%ld\n", ··· 824 823 return; 825 824 } 826 825 memcpy(f->bufaddr, ahin+1, n); 827 - case WIN_WRITE: 828 - case WIN_WRITE_EXT: 826 + case ATA_CMD_PIO_WRITE: 827 + case ATA_CMD_PIO_WRITE_EXT: 829 828 ifp = getif(t, skb->dev); 830 829 if (ifp) { 831 830 ifp->lost = 0; ··· 839 838 goto xmit; 840 839 } 841 840 break; 842 - case WIN_IDENTIFY: 841 + case ATA_CMD_ID_ATA: 843 842 if (skb->len - sizeof *hin - sizeof *ahin < 512) { 844 843 printk(KERN_INFO 845 844 "aoe: runt data size in ataid. skb->len=%d\n", ··· 915 914 916 915 /* set up ata header */ 917 916 ah->scnt = 1; 918 - ah->cmdstat = WIN_IDENTIFY; 917 + ah->cmdstat = ATA_CMD_ID_ATA; 919 918 ah->lba3 = 0xa0; 920 919 921 920 skb->dev = t->ifp->nd;
+2
drivers/block/hd.c
··· 42 42 #include <linux/ata.h> 43 43 #include <linux/hdreg.h> 44 44 45 + #define HD_IRQ 14 46 + 45 47 #define REALLY_SLOW_IO 46 48 #include <asm/system.h> 47 49 #include <asm/io.h>
+13 -17
drivers/block/xsysace.c
··· 89 89 #include <linux/delay.h> 90 90 #include <linux/slab.h> 91 91 #include <linux/blkdev.h> 92 + #include <linux/ata.h> 92 93 #include <linux/hdreg.h> 93 94 #include <linux/platform_device.h> 94 95 #if defined(CONFIG_OF) ··· 209 208 struct gendisk *gd; 210 209 211 210 /* Inserted CF card parameters */ 212 - struct hd_driveid cf_id; 211 + u16 cf_id[ATA_ID_WORDS]; 213 212 }; 214 213 215 214 static int ace_major; ··· 403 402 ace_in32(ace, ACE_CFGLBA), ace_in(ace, ACE_FATSTAT)); 404 403 } 405 404 406 - void ace_fix_driveid(struct hd_driveid *id) 405 + void ace_fix_driveid(u16 *id) 407 406 { 408 407 #if defined(__BIG_ENDIAN) 409 - u16 *buf = (void *)id; 410 408 int i; 411 409 412 410 /* All half words have wrong byte order; swap the bytes */ 413 - for (i = 0; i < sizeof(struct hd_driveid); i += 2, buf++) 414 - *buf = le16_to_cpu(*buf); 415 - 416 - /* Some of the data values are 32bit; swap the half words */ 417 - id->lba_capacity = ((id->lba_capacity >> 16) & 0x0000FFFF) | 418 - ((id->lba_capacity << 16) & 0xFFFF0000); 419 - id->spg = ((id->spg >> 16) & 0x0000FFFF) | 420 - ((id->spg << 16) & 0xFFFF0000); 411 + for (i = 0; i < ATA_ID_WORDS; i++, id++) 412 + *id = le16_to_cpu(*id); 421 413 #endif 422 414 } 423 415 ··· 608 614 break; 609 615 610 616 case ACE_FSM_STATE_IDENTIFY_COMPLETE: 611 - ace_fix_driveid(&ace->cf_id); 617 + ace_fix_driveid(&ace->cf_id[0]); 612 618 ace_dump_mem(&ace->cf_id, 512); /* Debug: Dump out disk ID */ 613 619 614 620 if (ace->data_result) { ··· 621 627 ace->media_change = 0; 622 628 623 629 /* Record disk parameters */ 624 - set_capacity(ace->gd, ace->cf_id.lba_capacity); 630 + set_capacity(ace->gd, 631 + ata_id_u32(&ace->cf_id, ATA_ID_LBA_CAPACITY)); 625 632 dev_info(ace->dev, "capacity: %i sectors\n", 626 - ace->cf_id.lba_capacity); 633 + ata_id_u32(&ace->cf_id, ATA_ID_LBA_CAPACITY)); 627 634 } 628 635 629 636 /* We're done, drop to IDLE state and notify waiters */ ··· 923 928 static int ace_getgeo(struct block_device *bdev, struct hd_geometry *geo) 924 929 { 925 930 struct ace_device *ace = bdev->bd_disk->private_data; 931 + u16 *cf_id = &ace->cf_id[0]; 926 932 927 933 dev_dbg(ace->dev, "ace_getgeo()\n"); 928 934 929 - geo->heads = ace->cf_id.heads; 930 - geo->sectors = ace->cf_id.sectors; 931 - geo->cylinders = ace->cf_id.cyls; 935 + geo->heads = cf_id[ATA_ID_HEADS]; 936 + geo->sectors = cf_id[ATA_ID_SECTORS]; 937 + geo->cylinders = cf_id[ATA_ID_CYLS]; 932 938 933 939 return 0; 934 940 }
+79 -158
drivers/usb/storage/isd200.c
··· 46 46 #include <linux/errno.h> 47 47 #include <linux/module.h> 48 48 #include <linux/slab.h> 49 + #include <linux/ata.h> 49 50 #include <linux/hdreg.h> 50 51 #include <linux/scatterlist.h> 51 52 ··· 329 328 330 329 struct isd200_info { 331 330 struct inquiry_data InquiryData; 332 - struct hd_driveid *id; 331 + u16 *id; 333 332 struct isd200_config ConfigData; 334 333 unsigned char *RegsBuf; 335 334 unsigned char ATARegs[8]; ··· 420 419 buf->Flags = UNIT_ATTENTION; 421 420 buf->AdditionalSenseCode = 0; 422 421 buf->AdditionalSenseCodeQualifier = 0; 423 - } else if(error & MCR_ERR) { 422 + } else if (error & ATA_MCR) { 424 423 buf->ErrorCode = 0x70 | SENSE_ERRCODE_VALID; 425 424 buf->AdditionalSenseLength = 0xb; 426 425 buf->Flags = UNIT_ATTENTION; 427 426 buf->AdditionalSenseCode = 0; 428 427 buf->AdditionalSenseCodeQualifier = 0; 429 - } else if(error & TRK0_ERR) { 428 + } else if (error & ATA_TRK0NF) { 430 429 buf->ErrorCode = 0x70 | SENSE_ERRCODE_VALID; 431 430 buf->AdditionalSenseLength = 0xb; 432 431 buf->Flags = NOT_READY; 433 432 buf->AdditionalSenseCode = 0; 434 433 buf->AdditionalSenseCodeQualifier = 0; 435 - } else if(error & ECC_ERR) { 434 + } else if (error & ATA_UNC) { 436 435 buf->ErrorCode = 0x70 | SENSE_ERRCODE_VALID; 437 436 buf->AdditionalSenseLength = 0xb; 438 437 buf->Flags = DATA_PROTECT; ··· 548 547 ata.generic.ActionSelect = ACTION_SELECT_1|ACTION_SELECT_5; 549 548 ata.generic.RegisterSelect = REG_DEVICE_HEAD | REG_COMMAND; 550 549 ata.write.DeviceHeadByte = info->DeviceHead; 551 - ata.write.CommandByte = WIN_SRST; 550 + ata.write.CommandByte = ATA_CMD_DEV_RESET; 552 551 isd200_set_srb(info, DMA_NONE, NULL, 0); 553 552 break; 554 553 555 554 case ACTION_IDENTIFY: 556 555 US_DEBUGP(" isd200_action(IDENTIFY)\n"); 557 556 ata.generic.RegisterSelect = REG_COMMAND; 558 - ata.write.CommandByte = WIN_IDENTIFY; 557 + ata.write.CommandByte = ATA_CMD_ID_ATA; 559 558 isd200_set_srb(info, DMA_FROM_DEVICE, info->id, 560 - sizeof(struct hd_driveid)); 559 + ATA_ID_WORDS * 2); 561 560 break; 562 561 563 562 default: ··· 945 944 break; 946 945 947 946 if (!detect) { 948 - if (regs[ATA_REG_STATUS_OFFSET] & BUSY_STAT) { 947 + if (regs[ATA_REG_STATUS_OFFSET] & ATA_BUSY) { 949 948 US_DEBUGP(" %s status is still BSY, try again...\n",mstr); 950 949 } else { 951 950 US_DEBUGP(" %s status !BSY, continue with next operation\n",mstr); 952 951 break; 953 952 } 954 953 } 955 - /* check for BUSY_STAT and */ 956 - /* WRERR_STAT (workaround ATA Zip drive) and */ 957 - /* ERR_STAT (workaround for Archos CD-ROM) */ 954 + /* check for ATA_BUSY and */ 955 + /* ATA_DF (workaround ATA Zip drive) and */ 956 + /* ATA_ERR (workaround for Archos CD-ROM) */ 958 957 else if (regs[ATA_REG_STATUS_OFFSET] & 959 - (BUSY_STAT | WRERR_STAT | ERR_STAT )) { 958 + (ATA_BUSY | ATA_DF | ATA_ERR)) { 960 959 US_DEBUGP(" Status indicates it is not ready, try again...\n"); 961 960 } 962 961 /* check for DRDY, ATA devices set DRDY after SRST */ 963 - else if (regs[ATA_REG_STATUS_OFFSET] & READY_STAT) { 962 + else if (regs[ATA_REG_STATUS_OFFSET] & ATA_DRDY) { 964 963 US_DEBUGP(" Identified ATA device\n"); 965 964 info->DeviceFlags |= DF_ATA_DEVICE; 966 965 info->DeviceHead = master_slave; ··· 1054 1053 return(retStatus); 1055 1054 } 1056 1055 1057 - static void isd200_fix_driveid (struct hd_driveid *id) 1056 + static void isd200_fix_driveid(u16 *id) 1058 1057 { 1059 1058 #ifndef __LITTLE_ENDIAN 1060 1059 # ifdef __BIG_ENDIAN 1061 1060 int i; 1062 - u16 *stringcast; 1063 1061 1064 - id->config = __le16_to_cpu(id->config); 1065 - id->cyls = __le16_to_cpu(id->cyls); 1066 - id->reserved2 = __le16_to_cpu(id->reserved2); 1067 - id->heads = __le16_to_cpu(id->heads); 1068 - id->track_bytes = __le16_to_cpu(id->track_bytes); 1069 - id->sector_bytes = __le16_to_cpu(id->sector_bytes); 1070 - id->sectors = __le16_to_cpu(id->sectors); 1071 - id->vendor0 = __le16_to_cpu(id->vendor0); 1072 - id->vendor1 = __le16_to_cpu(id->vendor1); 1073 - id->vendor2 = __le16_to_cpu(id->vendor2); 1074 - stringcast = (u16 *)&id->serial_no[0]; 1075 - for (i = 0; i < (20/2); i++) 1076 - stringcast[i] = __le16_to_cpu(stringcast[i]); 1077 - id->buf_type = __le16_to_cpu(id->buf_type); 1078 - id->buf_size = __le16_to_cpu(id->buf_size); 1079 - id->ecc_bytes = __le16_to_cpu(id->ecc_bytes); 1080 - stringcast = (u16 *)&id->fw_rev[0]; 1081 - for (i = 0; i < (8/2); i++) 1082 - stringcast[i] = __le16_to_cpu(stringcast[i]); 1083 - stringcast = (u16 *)&id->model[0]; 1084 - for (i = 0; i < (40/2); i++) 1085 - stringcast[i] = __le16_to_cpu(stringcast[i]); 1086 - id->dword_io = __le16_to_cpu(id->dword_io); 1087 - id->reserved50 = __le16_to_cpu(id->reserved50); 1088 - id->field_valid = __le16_to_cpu(id->field_valid); 1089 - id->cur_cyls = __le16_to_cpu(id->cur_cyls); 1090 - id->cur_heads = __le16_to_cpu(id->cur_heads); 1091 - id->cur_sectors = __le16_to_cpu(id->cur_sectors); 1092 - id->cur_capacity0 = __le16_to_cpu(id->cur_capacity0); 1093 - id->cur_capacity1 = __le16_to_cpu(id->cur_capacity1); 1094 - id->lba_capacity = __le32_to_cpu(id->lba_capacity); 1095 - id->dma_1word = __le16_to_cpu(id->dma_1word); 1096 - id->dma_mword = __le16_to_cpu(id->dma_mword); 1097 - id->eide_pio_modes = __le16_to_cpu(id->eide_pio_modes); 1098 - id->eide_dma_min = __le16_to_cpu(id->eide_dma_min); 1099 - id->eide_dma_time = __le16_to_cpu(id->eide_dma_time); 1100 - id->eide_pio = __le16_to_cpu(id->eide_pio); 1101 - id->eide_pio_iordy = __le16_to_cpu(id->eide_pio_iordy); 1102 - for (i = 0; i < 2; ++i) 1103 - id->words69_70[i] = __le16_to_cpu(id->words69_70[i]); 1104 - for (i = 0; i < 4; ++i) 1105 - id->words71_74[i] = __le16_to_cpu(id->words71_74[i]); 1106 - id->queue_depth = __le16_to_cpu(id->queue_depth); 1107 - for (i = 0; i < 4; ++i) 1108 - id->words76_79[i] = __le16_to_cpu(id->words76_79[i]); 1109 - id->major_rev_num = __le16_to_cpu(id->major_rev_num); 1110 - id->minor_rev_num = __le16_to_cpu(id->minor_rev_num); 1111 - id->command_set_1 = __le16_to_cpu(id->command_set_1); 1112 - id->command_set_2 = __le16_to_cpu(id->command_set_2); 1113 - id->cfsse = __le16_to_cpu(id->cfsse); 1114 - id->cfs_enable_1 = __le16_to_cpu(id->cfs_enable_1); 1115 - id->cfs_enable_2 = __le16_to_cpu(id->cfs_enable_2); 1116 - id->csf_default = __le16_to_cpu(id->csf_default); 1117 - id->dma_ultra = __le16_to_cpu(id->dma_ultra); 1118 - id->trseuc = __le16_to_cpu(id->trseuc); 1119 - id->trsEuc = __le16_to_cpu(id->trsEuc); 1120 - id->CurAPMvalues = __le16_to_cpu(id->CurAPMvalues); 1121 - id->mprc = __le16_to_cpu(id->mprc); 1122 - id->hw_config = __le16_to_cpu(id->hw_config); 1123 - id->acoustic = __le16_to_cpu(id->acoustic); 1124 - id->msrqs = __le16_to_cpu(id->msrqs); 1125 - id->sxfert = __le16_to_cpu(id->sxfert); 1126 - id->sal = __le16_to_cpu(id->sal); 1127 - id->spg = __le32_to_cpu(id->spg); 1128 - id->lba_capacity_2 = __le64_to_cpu(id->lba_capacity_2); 1129 - for (i = 0; i < 22; i++) 1130 - id->words104_125[i] = __le16_to_cpu(id->words104_125[i]); 1131 - id->last_lun = __le16_to_cpu(id->last_lun); 1132 - id->word127 = __le16_to_cpu(id->word127); 1133 - id->dlf = __le16_to_cpu(id->dlf); 1134 - id->csfo = __le16_to_cpu(id->csfo); 1135 - for (i = 0; i < 26; i++) 1136 - id->words130_155[i] = __le16_to_cpu(id->words130_155[i]); 1137 - id->word156 = __le16_to_cpu(id->word156); 1138 - for (i = 0; i < 3; i++) 1139 - id->words157_159[i] = __le16_to_cpu(id->words157_159[i]); 1140 - id->cfa_power = __le16_to_cpu(id->cfa_power); 1141 - for (i = 0; i < 14; i++) 1142 - id->words161_175[i] = __le16_to_cpu(id->words161_175[i]); 1143 - for (i = 0; i < 31; i++) 1144 - id->words176_205[i] = __le16_to_cpu(id->words176_205[i]); 1145 - for (i = 0; i < 48; i++) 1146 - id->words206_254[i] = __le16_to_cpu(id->words206_254[i]); 1147 - id->integrity_word = __le16_to_cpu(id->integrity_word); 1062 + for (i = 0; i < ATA_ID_WORDS; i++) 1063 + id[i] = __le16_to_cpu(id[i]); 1148 1064 # else 1149 1065 # error "Please fix <asm/byteorder.h>" 1150 1066 # endif 1151 1067 #endif 1152 1068 } 1153 1069 1070 + static void isd200_dump_driveid(u16 *id) 1071 + { 1072 + US_DEBUGP(" Identify Data Structure:\n"); 1073 + US_DEBUGP(" config = 0x%x\n", id[ATA_ID_CONFIG]); 1074 + US_DEBUGP(" cyls = 0x%x\n", id[ATA_ID_CYLS]); 1075 + US_DEBUGP(" heads = 0x%x\n", id[ATA_ID_HEADS]); 1076 + US_DEBUGP(" track_bytes = 0x%x\n", id[4]); 1077 + US_DEBUGP(" sector_bytes = 0x%x\n", id[5]); 1078 + US_DEBUGP(" sectors = 0x%x\n", id[ATA_ID_SECTORS]); 1079 + US_DEBUGP(" serial_no[0] = 0x%x\n", *(char *)&id[ATA_ID_SERNO]); 1080 + US_DEBUGP(" buf_type = 0x%x\n", id[20]); 1081 + US_DEBUGP(" buf_size = 0x%x\n", id[ATA_ID_BUF_SIZE]); 1082 + US_DEBUGP(" ecc_bytes = 0x%x\n", id[22]); 1083 + US_DEBUGP(" fw_rev[0] = 0x%x\n", *(char *)&id[ATA_ID_FW_REV]); 1084 + US_DEBUGP(" model[0] = 0x%x\n", *(char *)&id[ATA_ID_PROD]); 1085 + US_DEBUGP(" max_multsect = 0x%x\n", id[ATA_ID_MAX_MULTSECT] & 0xff); 1086 + US_DEBUGP(" dword_io = 0x%x\n", id[ATA_ID_DWORD_IO]); 1087 + US_DEBUGP(" capability = 0x%x\n", id[ATA_ID_CAPABILITY] >> 8); 1088 + US_DEBUGP(" tPIO = 0x%x\n", id[ATA_ID_OLD_PIO_MODES] >> 8); 1089 + US_DEBUGP(" tDMA = 0x%x\n", id[ATA_ID_OLD_DMA_MODES] >> 8); 1090 + US_DEBUGP(" field_valid = 0x%x\n", id[ATA_ID_FIELD_VALID]); 1091 + US_DEBUGP(" cur_cyls = 0x%x\n", id[ATA_ID_CUR_CYLS]); 1092 + US_DEBUGP(" cur_heads = 0x%x\n", id[ATA_ID_CUR_HEADS]); 1093 + US_DEBUGP(" cur_sectors = 0x%x\n", id[ATA_ID_CUR_SECTORS]); 1094 + US_DEBUGP(" cur_capacity = 0x%x\n", ata_id_u32(id, 57)); 1095 + US_DEBUGP(" multsect = 0x%x\n", id[ATA_ID_MULTSECT] & 0xff); 1096 + US_DEBUGP(" lba_capacity = 0x%x\n", ata_id_u32(id, ATA_ID_LBA_CAPACITY)); 1097 + US_DEBUGP(" command_set_1 = 0x%x\n", id[ATA_ID_COMMAND_SET_1]); 1098 + US_DEBUGP(" command_set_2 = 0x%x\n", id[ATA_ID_COMMAND_SET_2]); 1099 + } 1154 1100 1155 1101 /************************************************************************** 1156 1102 * isd200_get_inquiry_data ··· 1111 1163 { 1112 1164 struct isd200_info *info = (struct isd200_info *)us->extra; 1113 1165 int retStatus = ISD200_GOOD; 1114 - struct hd_driveid *id = info->id; 1166 + u16 *id = info->id; 1115 1167 1116 1168 US_DEBUGP("Entering isd200_get_inquiry_data\n"); 1117 1169 ··· 1128 1180 /* this must be an ATA device */ 1129 1181 /* perform an ATA Command Identify */ 1130 1182 transferStatus = isd200_action( us, ACTION_IDENTIFY, 1131 - id, 1132 - sizeof(struct hd_driveid) ); 1183 + id, ATA_ID_WORDS * 2); 1133 1184 if (transferStatus != ISD200_TRANSPORT_GOOD) { 1134 1185 /* Error issuing ATA Command Identify */ 1135 1186 US_DEBUGP(" Error issuing ATA Command Identify\n"); ··· 1138 1191 int i; 1139 1192 __be16 *src; 1140 1193 __u16 *dest; 1141 - isd200_fix_driveid(id); 1142 1194 1143 - US_DEBUGP(" Identify Data Structure:\n"); 1144 - US_DEBUGP(" config = 0x%x\n", id->config); 1145 - US_DEBUGP(" cyls = 0x%x\n", id->cyls); 1146 - US_DEBUGP(" heads = 0x%x\n", id->heads); 1147 - US_DEBUGP(" track_bytes = 0x%x\n", id->track_bytes); 1148 - US_DEBUGP(" sector_bytes = 0x%x\n", id->sector_bytes); 1149 - US_DEBUGP(" sectors = 0x%x\n", id->sectors); 1150 - US_DEBUGP(" serial_no[0] = 0x%x\n", id->serial_no[0]); 1151 - US_DEBUGP(" buf_type = 0x%x\n", id->buf_type); 1152 - US_DEBUGP(" buf_size = 0x%x\n", id->buf_size); 1153 - US_DEBUGP(" ecc_bytes = 0x%x\n", id->ecc_bytes); 1154 - US_DEBUGP(" fw_rev[0] = 0x%x\n", id->fw_rev[0]); 1155 - US_DEBUGP(" model[0] = 0x%x\n", id->model[0]); 1156 - US_DEBUGP(" max_multsect = 0x%x\n", id->max_multsect); 1157 - US_DEBUGP(" dword_io = 0x%x\n", id->dword_io); 1158 - US_DEBUGP(" capability = 0x%x\n", id->capability); 1159 - US_DEBUGP(" tPIO = 0x%x\n", id->tPIO); 1160 - US_DEBUGP(" tDMA = 0x%x\n", id->tDMA); 1161 - US_DEBUGP(" field_valid = 0x%x\n", id->field_valid); 1162 - US_DEBUGP(" cur_cyls = 0x%x\n", id->cur_cyls); 1163 - US_DEBUGP(" cur_heads = 0x%x\n", id->cur_heads); 1164 - US_DEBUGP(" cur_sectors = 0x%x\n", id->cur_sectors); 1165 - US_DEBUGP(" cur_capacity = 0x%x\n", (id->cur_capacity1 << 16) + id->cur_capacity0 ); 1166 - US_DEBUGP(" multsect = 0x%x\n", id->multsect); 1167 - US_DEBUGP(" lba_capacity = 0x%x\n", id->lba_capacity); 1168 - US_DEBUGP(" command_set_1 = 0x%x\n", id->command_set_1); 1169 - US_DEBUGP(" command_set_2 = 0x%x\n", id->command_set_2); 1195 + isd200_fix_driveid(id); 1196 + isd200_dump_driveid(id); 1170 1197 1171 1198 memset(&info->InquiryData, 0, sizeof(info->InquiryData)); 1172 1199 ··· 1150 1229 /* The length must be at least 36 (5 + 31) */ 1151 1230 info->InquiryData.AdditionalLength = 0x1F; 1152 1231 1153 - if (id->command_set_1 & COMMANDSET_MEDIA_STATUS) { 1232 + if (id[ATA_ID_COMMAND_SET_1] & COMMANDSET_MEDIA_STATUS) { 1154 1233 /* set the removable bit */ 1155 1234 info->InquiryData.DeviceTypeModifier = DEVICE_REMOVABLE; 1156 1235 info->DeviceFlags |= DF_REMOVABLE_MEDIA; 1157 1236 } 1158 1237 1159 1238 /* Fill in vendor identification fields */ 1160 - src = (__be16*)id->model; 1239 + src = (__be16 *)&id[ATA_ID_PROD]; 1161 1240 dest = (__u16*)info->InquiryData.VendorId; 1162 1241 for (i=0;i<4;i++) 1163 1242 dest[i] = be16_to_cpu(src[i]); 1164 1243 1165 - src = (__be16*)(id->model+8); 1244 + src = (__be16 *)&id[ATA_ID_PROD + 8/2]; 1166 1245 dest = (__u16*)info->InquiryData.ProductId; 1167 1246 for (i=0;i<8;i++) 1168 1247 dest[i] = be16_to_cpu(src[i]); 1169 1248 1170 - src = (__be16*)id->fw_rev; 1249 + src = (__be16 *)&id[ATA_ID_FW_REV]; 1171 1250 dest = (__u16*)info->InquiryData.ProductRevisionLevel; 1172 1251 for (i=0;i<2;i++) 1173 1252 dest[i] = be16_to_cpu(src[i]); 1174 1253 1175 1254 /* determine if it supports Media Status Notification */ 1176 - if (id->command_set_2 & COMMANDSET_MEDIA_STATUS) { 1255 + if (id[ATA_ID_COMMAND_SET_2] & COMMANDSET_MEDIA_STATUS) { 1177 1256 US_DEBUGP(" Device supports Media Status Notification\n"); 1178 1257 1179 1258 /* Indicate that it is enabled, even though it is not ··· 1222 1301 union ata_cdb * ataCdb) 1223 1302 { 1224 1303 struct isd200_info *info = (struct isd200_info *)us->extra; 1225 - struct hd_driveid *id = info->id; 1304 + u16 *id = info->id; 1226 1305 int sendToTransport = 1; 1227 1306 unsigned char sectnum, head; 1228 1307 unsigned short cylinder; ··· 1290 1369 1291 1370 US_DEBUGP(" ATA OUT - SCSIOP_READ_CAPACITY\n"); 1292 1371 1293 - if (id->capability & CAPABILITY_LBA ) { 1294 - capacity = id->lba_capacity - 1; 1295 - } else { 1296 - capacity = (id->heads * 1297 - id->cyls * 1298 - id->sectors) - 1; 1299 - } 1372 + if (ata_id_has_lba(id)) 1373 + capacity = ata_id_u32(id, ATA_ID_LBA_CAPACITY) - 1; 1374 + else 1375 + capacity = (id[ATA_ID_HEADS] * id[ATA_ID_CYLS] * 1376 + id[ATA_ID_SECTORS]) - 1; 1377 + 1300 1378 readCapacityData.LogicalBlockAddress = cpu_to_be32(capacity); 1301 1379 readCapacityData.BytesPerBlock = cpu_to_be32(0x200); 1302 1380 ··· 1312 1392 lba = be32_to_cpu(*(__be32 *)&srb->cmnd[2]); 1313 1393 blockCount = (unsigned long)srb->cmnd[7]<<8 | (unsigned long)srb->cmnd[8]; 1314 1394 1315 - if (id->capability & CAPABILITY_LBA) { 1395 + if (ata_id_has_lba(id)) { 1316 1396 sectnum = (unsigned char)(lba); 1317 1397 cylinder = (unsigned short)(lba>>8); 1318 1398 head = ATA_ADDRESS_DEVHEAD_LBA_MODE | (unsigned char)(lba>>24 & 0x0F); 1319 1399 } else { 1320 - sectnum = (unsigned char)((lba % id->sectors) + 1); 1321 - cylinder = (unsigned short)(lba / (id->sectors * 1322 - id->heads)); 1323 - head = (unsigned char)((lba / id->sectors) % 1324 - id->heads); 1400 + sectnum = (u8)((lba % id[ATA_ID_SECTORS]) + 1); 1401 + cylinder = (u16)(lba / (id[ATA_ID_SECTORS] * 1402 + id[ATA_ID_HEADS])); 1403 + head = (u8)((lba / id[ATA_ID_SECTORS]) % 1404 + id[ATA_ID_HEADS]); 1325 1405 } 1326 1406 ataCdb->generic.SignatureByte0 = info->ConfigData.ATAMajorCommand; 1327 1407 ataCdb->generic.SignatureByte1 = info->ConfigData.ATAMinorCommand; ··· 1335 1415 ataCdb->write.CylinderHighByte = (unsigned char)(cylinder>>8); 1336 1416 ataCdb->write.CylinderLowByte = (unsigned char)cylinder; 1337 1417 ataCdb->write.DeviceHeadByte = (head | ATA_ADDRESS_DEVHEAD_STD); 1338 - ataCdb->write.CommandByte = WIN_READ; 1418 + ataCdb->write.CommandByte = ATA_CMD_PIO_READ; 1339 1419 break; 1340 1420 1341 1421 case WRITE_10: ··· 1344 1424 lba = be32_to_cpu(*(__be32 *)&srb->cmnd[2]); 1345 1425 blockCount = (unsigned long)srb->cmnd[7]<<8 | (unsigned long)srb->cmnd[8]; 1346 1426 1347 - if (id->capability & CAPABILITY_LBA) { 1427 + if (ata_id_has_lba(id)) { 1348 1428 sectnum = (unsigned char)(lba); 1349 1429 cylinder = (unsigned short)(lba>>8); 1350 1430 head = ATA_ADDRESS_DEVHEAD_LBA_MODE | (unsigned char)(lba>>24 & 0x0F); 1351 1431 } else { 1352 - sectnum = (unsigned char)((lba % id->sectors) + 1); 1353 - cylinder = (unsigned short)(lba / (id->sectors * id->heads)); 1354 - head = (unsigned char)((lba / id->sectors) % id->heads); 1432 + sectnum = (u8)((lba % id[ATA_ID_SECTORS]) + 1); 1433 + cylinder = (u16)(lba / (id[ATA_ID_SECTORS] * 1434 + id[ATA_ID_HEADS])); 1435 + head = (u8)((lba / id[ATA_ID_SECTORS]) % 1436 + id[ATA_ID_HEADS]); 1355 1437 } 1356 1438 ataCdb->generic.SignatureByte0 = info->ConfigData.ATAMajorCommand; 1357 1439 ataCdb->generic.SignatureByte1 = info->ConfigData.ATAMinorCommand; ··· 1367 1445 ataCdb->write.CylinderHighByte = (unsigned char)(cylinder>>8); 1368 1446 ataCdb->write.CylinderLowByte = (unsigned char)cylinder; 1369 1447 ataCdb->write.DeviceHeadByte = (head | ATA_ADDRESS_DEVHEAD_STD); 1370 - ataCdb->write.CommandByte = WIN_WRITE; 1448 + ataCdb->write.CommandByte = ATA_CMD_PIO_WRITE; 1371 1449 break; 1372 1450 1373 1451 case ALLOW_MEDIUM_REMOVAL: ··· 1381 1459 ataCdb->generic.TransferBlockSize = 1; 1382 1460 ataCdb->generic.RegisterSelect = REG_COMMAND; 1383 1461 ataCdb->write.CommandByte = (srb->cmnd[4] & 0x1) ? 1384 - WIN_DOORLOCK : WIN_DOORUNLOCK; 1462 + ATA_CMD_MEDIA_LOCK : ATA_CMD_MEDIA_UNLOCK; 1385 1463 isd200_srb_set_bufflen(srb, 0); 1386 1464 } else { 1387 1465 US_DEBUGP(" Not removeable media, just report okay\n"); ··· 1461 1539 if (!info) 1462 1540 retStatus = ISD200_ERROR; 1463 1541 else { 1464 - info->id = (struct hd_driveid *) 1465 - kzalloc(sizeof(struct hd_driveid), GFP_KERNEL); 1542 + info->id = kzalloc(ATA_ID_WORDS * 2, GFP_KERNEL); 1466 1543 info->RegsBuf = (unsigned char *) 1467 1544 kmalloc(sizeof(info->ATARegs), GFP_KERNEL); 1468 1545 info->srb.sense_buffer =
+4 -62
include/linux/hdreg.h
··· 1 1 #ifndef _LINUX_HDREG_H 2 2 #define _LINUX_HDREG_H 3 3 4 - #ifdef __KERNEL__ 5 - #include <linux/ata.h> 6 - 7 - /* 8 - * This file contains some defines for the AT-hd-controller. 9 - * Various sources. 10 - */ 11 - 12 - /* ide.c has its own port definitions in "ide.h" */ 13 - 14 - #define HD_IRQ 14 15 - 16 - /* Hd controller regs. Ref: IBM AT Bios-listing */ 17 - #define HD_DATA 0x1f0 /* _CTL when writing */ 18 - #define HD_ERROR 0x1f1 /* see err-bits */ 19 - #define HD_NSECTOR 0x1f2 /* nr of sectors to read/write */ 20 - #define HD_SECTOR 0x1f3 /* starting sector */ 21 - #define HD_LCYL 0x1f4 /* starting cylinder */ 22 - #define HD_HCYL 0x1f5 /* high byte of starting cyl */ 23 - #define HD_CURRENT 0x1f6 /* 101dhhhh , d=drive, hhhh=head */ 24 - #define HD_STATUS 0x1f7 /* see status-bits */ 25 - #define HD_FEATURE HD_ERROR /* same io address, read=error, write=feature */ 26 - #define HD_PRECOMP HD_FEATURE /* obsolete use of this port - predates IDE */ 27 - #define HD_COMMAND HD_STATUS /* same io address, read=status, write=cmd */ 28 - 29 - #define HD_CMD 0x3f6 /* used for resets */ 30 - #define HD_ALTSTATUS 0x3f6 /* same as HD_STATUS but doesn't clear irq */ 31 - 32 - /* remainder is shared between hd.c, ide.c, ide-cd.c, and the hdparm utility */ 33 - 34 - /* Bits of HD_STATUS */ 35 - #define ERR_STAT 0x01 36 - #define INDEX_STAT 0x02 37 - #define ECC_STAT 0x04 /* Corrected error */ 38 - #define DRQ_STAT 0x08 39 - #define SEEK_STAT 0x10 40 - #define SRV_STAT 0x10 41 - #define WRERR_STAT 0x20 42 - #define READY_STAT 0x40 43 - #define BUSY_STAT 0x80 44 - 45 - /* Bits for HD_ERROR */ 46 - #define MARK_ERR 0x01 /* Bad address mark */ 47 - #define ILI_ERR 0x01 /* Illegal Length Indication (ATAPI) */ 48 - #define TRK0_ERR 0x02 /* couldn't find track 0 */ 49 - #define EOM_ERR 0x02 /* End Of Media (ATAPI) */ 50 - #define ABRT_ERR 0x04 /* Command aborted */ 51 - #define MCR_ERR 0x08 /* media change request */ 52 - #define ID_ERR 0x10 /* ID field not found */ 53 - #define MC_ERR 0x20 /* media changed */ 54 - #define ECC_ERR 0x40 /* Uncorrectable ECC error */ 55 - #define BBD_ERR 0x80 /* pre-EIDE meaning: block marked bad */ 56 - #define ICRC_ERR 0x80 /* new meaning: CRC error during transfer */ 57 - #define LFS_ERR 0xf0 /* Last Failed Sense (ATAPI) */ 58 - 59 - /* Bits of HD_NSECTOR */ 60 - #define CD 0x01 61 - #define IO 0x02 62 - #define REL 0x04 63 - #define TAG_MASK 0xf8 64 - #endif /* __KERNEL__ */ 65 - 66 4 #include <linux/types.h> 67 5 68 6 /* ··· 129 191 #define TASKFILE_INVALID 0x7fff 130 192 #endif 131 193 194 + #ifndef __KERNEL__ 132 195 /* ATA/ATAPI Commands pre T13 Spec */ 133 196 #define WIN_NOP 0x00 134 197 /* ··· 318 379 #define SECURITY_ERASE_UNIT 0xBD 319 380 #define SECURITY_FREEZE_LOCK 0xBE 320 381 #define SECURITY_DISABLE_PASSWORD 0xBF 382 + #endif /* __KERNEL__ */ 321 383 322 384 struct hd_geometry { 323 385 unsigned char heads; ··· 388 448 389 449 #define __NEW_HD_DRIVE_ID 390 450 451 + #ifndef __KERNEL__ 391 452 /* 392 453 * Structure returned by HDIO_GET_IDENTITY, as per ANSI NCITS ATA6 rev.1b spec. 393 454 * ··· 640 699 * 7:0 Signature 641 700 */ 642 701 }; 702 + #endif /* __KERNEL__ */ 643 703 644 704 /* 645 705 * IDE "nice" flags. These are used on a per drive basis to determine