Commit ea68d270ff55bcdfa5d07697eb68103b5b02c7bb
Committed by
Bartlomiej Zolnierkiewicz
1 parent
3b8ac5398c
Exists in
master
and in
4 other branches
ide-floppy: convert to using the new atapi_flags (take 2)
while at it, remove PC_FLAG_ZIP_DRIVE from the packed command flags altogether and query the drive type through drive->atapi_flags. v2: ide-floppy fix. There should be no functionality change resulting from this patch. [bart: IDE_FLAG_* -> IDE_AFLAG_*, dev_flags -> atapi_flags] Signed-off-by: Borislav Petkov <petkovbb@gmail.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Showing 3 changed files with 31 additions and 50 deletions Side-by-side Diff
drivers/ide/ide-atapi.c
... | ... | @@ -257,7 +257,7 @@ |
257 | 257 | } |
258 | 258 | |
259 | 259 | /* Send the actual packet */ |
260 | - if ((pc->flags & PC_FLAG_ZIP_DRIVE) == 0) | |
260 | + if ((drive->atapi_flags & IDE_AFLAG_ZIP_DRIVE) == 0) | |
261 | 261 | hwif->tp_ops->output_data(drive, NULL, rq->cmd, 12); |
262 | 262 | |
263 | 263 | return ide_started; |
... | ... | @@ -302,7 +302,8 @@ |
302 | 302 | bcount, dma); |
303 | 303 | |
304 | 304 | /* Issue the packet command */ |
305 | - if (pc->flags & PC_FLAG_DRQ_INTERRUPT) { | |
305 | + if ((pc->flags & PC_FLAG_DRQ_INTERRUPT) || | |
306 | + (drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT)) { | |
306 | 307 | ide_execute_command(drive, WIN_PACKETCMD, handler, |
307 | 308 | timeout, NULL); |
308 | 309 | return ide_started; |
drivers/ide/ide-floppy.c
... | ... | @@ -125,26 +125,10 @@ |
125 | 125 | int wp; |
126 | 126 | /* Supports format progress report */ |
127 | 127 | int srfp; |
128 | - /* Status/Action flags */ | |
129 | - unsigned long flags; | |
130 | 128 | } idefloppy_floppy_t; |
131 | 129 | |
132 | 130 | #define IDEFLOPPY_TICKS_DELAY HZ/20 /* default delay for ZIP 100 (50ms) */ |
133 | 131 | |
134 | -/* Floppy flag bits values. */ | |
135 | -enum { | |
136 | - /* DRQ interrupt device */ | |
137 | - IDEFLOPPY_FLAG_DRQ_INTERRUPT = (1 << 0), | |
138 | - /* Media may have changed */ | |
139 | - IDEFLOPPY_FLAG_MEDIA_CHANGED = (1 << 1), | |
140 | - /* Format in progress */ | |
141 | - IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS = (1 << 2), | |
142 | - /* Avoid commands not supported in Clik drive */ | |
143 | - IDEFLOPPY_FLAG_CLIK_DRIVE = (1 << 3), | |
144 | - /* Requires BH algorithm for packets */ | |
145 | - IDEFLOPPY_FLAG_ZIP_DRIVE = (1 << 4), | |
146 | -}; | |
147 | - | |
148 | 132 | /* Defines for the MODE SENSE command */ |
149 | 133 | #define MODE_SENSE_CURRENT 0x00 |
150 | 134 | #define MODE_SENSE_CHANGEABLE 0x01 |
... | ... | @@ -429,7 +413,7 @@ |
429 | 413 | * 40 and 50msec work well. idefloppy_pc_intr will not be actually |
430 | 414 | * used until after the packet is moved in about 50 msec. |
431 | 415 | */ |
432 | - if (pc->flags & PC_FLAG_ZIP_DRIVE) { | |
416 | + if (drive->atapi_flags & IDE_AFLAG_ZIP_DRIVE) { | |
433 | 417 | timeout = floppy->ticks; |
434 | 418 | expiry = &idefloppy_transfer_pc; |
435 | 419 | } else { |
... | ... | @@ -649,12 +633,6 @@ |
649 | 633 | return ide_stopped; |
650 | 634 | } |
651 | 635 | |
652 | - if (floppy->flags & IDEFLOPPY_FLAG_DRQ_INTERRUPT) | |
653 | - pc->flags |= PC_FLAG_DRQ_INTERRUPT; | |
654 | - | |
655 | - if (floppy->flags & IDEFLOPPY_FLAG_ZIP_DRIVE) | |
656 | - pc->flags |= PC_FLAG_ZIP_DRIVE; | |
657 | - | |
658 | 636 | pc->rq = rq; |
659 | 637 | |
660 | 638 | return idefloppy_issue_pc(drive, pc); |
... | ... | @@ -798,7 +776,7 @@ |
798 | 776 | switch (pc.buf[desc_start + 4] & 0x03) { |
799 | 777 | /* Clik! drive returns this instead of CAPACITY_CURRENT */ |
800 | 778 | case CAPACITY_UNFORMATTED: |
801 | - if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) | |
779 | + if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE)) | |
802 | 780 | /* |
803 | 781 | * If it is not a clik drive, break out |
804 | 782 | * (maintains previous driver behaviour) |
... | ... | @@ -844,7 +822,7 @@ |
844 | 822 | } |
845 | 823 | |
846 | 824 | /* Clik! disk does not support get_flexible_disk_page */ |
847 | - if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) | |
825 | + if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE)) | |
848 | 826 | (void) ide_floppy_get_flexible_disk_page(drive); |
849 | 827 | |
850 | 828 | set_capacity(floppy->disk, floppy->blocks * floppy->bs_factor); |
... | ... | @@ -1046,7 +1024,7 @@ |
1046 | 1024 | drive->pc_callback = ide_floppy_callback; |
1047 | 1025 | |
1048 | 1026 | if (((gcw[0] & 0x60) >> 5) == 1) |
1049 | - floppy->flags |= IDEFLOPPY_FLAG_DRQ_INTERRUPT; | |
1027 | + drive->atapi_flags |= IDE_AFLAG_DRQ_INTERRUPT; | |
1050 | 1028 | /* |
1051 | 1029 | * We used to check revisions here. At this point however I'm giving up. |
1052 | 1030 | * Just assume they are all broken, its easier. |
... | ... | @@ -1057,7 +1035,7 @@ |
1057 | 1035 | * we'll leave the limitation below for the 2.2.x tree. |
1058 | 1036 | */ |
1059 | 1037 | if (!strncmp(drive->id->model, "IOMEGA ZIP 100 ATAPI", 20)) { |
1060 | - floppy->flags |= IDEFLOPPY_FLAG_ZIP_DRIVE; | |
1038 | + drive->atapi_flags |= IDE_AFLAG_ZIP_DRIVE; | |
1061 | 1039 | /* This value will be visible in the /proc/ide/hdx/settings */ |
1062 | 1040 | floppy->ticks = IDEFLOPPY_TICKS_DELAY; |
1063 | 1041 | blk_queue_max_sectors(drive->queue, 64); |
... | ... | @@ -1069,7 +1047,7 @@ |
1069 | 1047 | */ |
1070 | 1048 | if (strncmp(drive->id->model, "IOMEGA Clik!", 11) == 0) { |
1071 | 1049 | blk_queue_max_sectors(drive->queue, 64); |
1072 | - floppy->flags |= IDEFLOPPY_FLAG_CLIK_DRIVE; | |
1050 | + drive->atapi_flags |= IDE_AFLAG_CLIK_DRIVE; | |
1073 | 1051 | } |
1074 | 1052 | |
1075 | 1053 | (void) ide_floppy_get_capacity(drive); |
... | ... | @@ -1158,7 +1136,7 @@ |
1158 | 1136 | floppy->openers++; |
1159 | 1137 | |
1160 | 1138 | if (floppy->openers == 1) { |
1161 | - floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS; | |
1139 | + drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS; | |
1162 | 1140 | /* Just in case */ |
1163 | 1141 | |
1164 | 1142 | idefloppy_init_pc(&pc); |
1165 | 1143 | |
1166 | 1144 | |
... | ... | @@ -1185,14 +1163,14 @@ |
1185 | 1163 | ret = -EROFS; |
1186 | 1164 | goto out_put_floppy; |
1187 | 1165 | } |
1188 | - floppy->flags |= IDEFLOPPY_FLAG_MEDIA_CHANGED; | |
1166 | + drive->atapi_flags |= IDE_AFLAG_MEDIA_CHANGED; | |
1189 | 1167 | /* IOMEGA Clik! drives do not support lock/unlock commands */ |
1190 | - if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) { | |
1168 | + if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE)) { | |
1191 | 1169 | idefloppy_create_prevent_cmd(&pc, 1); |
1192 | 1170 | (void) idefloppy_queue_pc_tail(drive, &pc); |
1193 | 1171 | } |
1194 | 1172 | check_disk_change(inode->i_bdev); |
1195 | - } else if (floppy->flags & IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS) { | |
1173 | + } else if (drive->atapi_flags & IDE_AFLAG_FORMAT_IN_PROGRESS) { | |
1196 | 1174 | ret = -EBUSY; |
1197 | 1175 | goto out_put_floppy; |
1198 | 1176 | } |
1199 | 1177 | |
... | ... | @@ -1215,12 +1193,12 @@ |
1215 | 1193 | |
1216 | 1194 | if (floppy->openers == 1) { |
1217 | 1195 | /* IOMEGA Clik! drives do not support lock/unlock commands */ |
1218 | - if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) { | |
1196 | + if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE)) { | |
1219 | 1197 | idefloppy_create_prevent_cmd(&pc, 0); |
1220 | 1198 | (void) idefloppy_queue_pc_tail(drive, &pc); |
1221 | 1199 | } |
1222 | 1200 | |
1223 | - floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS; | |
1201 | + drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS; | |
1224 | 1202 | } |
1225 | 1203 | |
1226 | 1204 | floppy->openers--; |
1227 | 1205 | |
1228 | 1206 | |
... | ... | @@ -1241,15 +1219,17 @@ |
1241 | 1219 | return 0; |
1242 | 1220 | } |
1243 | 1221 | |
1244 | -static int ide_floppy_lockdoor(idefloppy_floppy_t *floppy, | |
1245 | - struct ide_atapi_pc *pc, unsigned long arg, unsigned int cmd) | |
1222 | +static int ide_floppy_lockdoor(ide_drive_t *drive, struct ide_atapi_pc *pc, | |
1223 | + unsigned long arg, unsigned int cmd) | |
1246 | 1224 | { |
1225 | + idefloppy_floppy_t *floppy = drive->driver_data; | |
1226 | + | |
1247 | 1227 | if (floppy->openers > 1) |
1248 | 1228 | return -EBUSY; |
1249 | 1229 | |
1250 | 1230 | /* The IOMEGA Clik! Drive doesn't support this command - |
1251 | 1231 | * no room for an eject mechanism */ |
1252 | - if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) { | |
1232 | + if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE)) { | |
1253 | 1233 | int prevent = arg ? 1 : 0; |
1254 | 1234 | |
1255 | 1235 | if (cmd == CDROMEJECT) |
1256 | 1236 | |
1257 | 1237 | |
1258 | 1238 | |
... | ... | @@ -1270,16 +1250,17 @@ |
1270 | 1250 | static int ide_floppy_format_unit(idefloppy_floppy_t *floppy, |
1271 | 1251 | int __user *arg) |
1272 | 1252 | { |
1273 | - int blocks, length, flags, err = 0; | |
1274 | 1253 | struct ide_atapi_pc pc; |
1254 | + ide_drive_t *drive = floppy->drive; | |
1255 | + int blocks, length, flags, err = 0; | |
1275 | 1256 | |
1276 | 1257 | if (floppy->openers > 1) { |
1277 | 1258 | /* Don't format if someone is using the disk */ |
1278 | - floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS; | |
1259 | + drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS; | |
1279 | 1260 | return -EBUSY; |
1280 | 1261 | } |
1281 | 1262 | |
1282 | - floppy->flags |= IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS; | |
1263 | + drive->atapi_flags |= IDE_AFLAG_FORMAT_IN_PROGRESS; | |
1283 | 1264 | |
1284 | 1265 | /* |
1285 | 1266 | * Send ATAPI_FORMAT_UNIT to the drive. |
1286 | 1267 | |
1287 | 1268 | |
... | ... | @@ -1303,15 +1284,15 @@ |
1303 | 1284 | goto out; |
1304 | 1285 | } |
1305 | 1286 | |
1306 | - (void) idefloppy_get_sfrp_bit(floppy->drive); | |
1287 | + (void) idefloppy_get_sfrp_bit(drive); | |
1307 | 1288 | idefloppy_create_format_unit_cmd(&pc, blocks, length, flags); |
1308 | 1289 | |
1309 | - if (idefloppy_queue_pc_tail(floppy->drive, &pc)) | |
1290 | + if (idefloppy_queue_pc_tail(drive, &pc)) | |
1310 | 1291 | err = -EIO; |
1311 | 1292 | |
1312 | 1293 | out: |
1313 | 1294 | if (err) |
1314 | - floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS; | |
1295 | + drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS; | |
1315 | 1296 | return err; |
1316 | 1297 | } |
1317 | 1298 | |
... | ... | @@ -1330,7 +1311,7 @@ |
1330 | 1311 | case CDROMEJECT: |
1331 | 1312 | /* fall through */ |
1332 | 1313 | case CDROM_LOCKDOOR: |
1333 | - return ide_floppy_lockdoor(floppy, &pc, arg, cmd); | |
1314 | + return ide_floppy_lockdoor(drive, &pc, arg, cmd); | |
1334 | 1315 | case IDEFLOPPY_IOCTL_FORMAT_SUPPORTED: |
1335 | 1316 | return 0; |
1336 | 1317 | case IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY: |
... | ... | @@ -1371,8 +1352,8 @@ |
1371 | 1352 | drive->attach = 0; |
1372 | 1353 | return 0; |
1373 | 1354 | } |
1374 | - ret = !!(floppy->flags & IDEFLOPPY_FLAG_MEDIA_CHANGED); | |
1375 | - floppy->flags &= ~IDEFLOPPY_FLAG_MEDIA_CHANGED; | |
1355 | + ret = !!(drive->atapi_flags & IDE_AFLAG_MEDIA_CHANGED); | |
1356 | + drive->atapi_flags &= ~IDE_AFLAG_MEDIA_CHANGED; | |
1376 | 1357 | return ret; |
1377 | 1358 | } |
1378 | 1359 |
include/linux/ide.h