aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBorislav Petkov <petkovbb@googlemail.com>2008-07-23 13:56:01 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-23 13:56:01 -0400
commitea68d270ff55bcdfa5d07697eb68103b5b02c7bb (patch)
tree68bcb3f721b95cca5b1fb0891e7490af19de55e5 /drivers
parent3b8ac5398ca8137b41aa5da4d9fad89153450aaa (diff)
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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ide/ide-atapi.c5
-rw-r--r--drivers/ide/ide-floppy.c73
2 files changed, 30 insertions, 48 deletions
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index f848010c15a5..711a5f6d35e4 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -257,7 +257,7 @@ ide_startstop_t ide_transfer_pc(ide_drive_t *drive, struct ide_atapi_pc *pc,
257 } 257 }
258 258
259 /* Send the actual packet */ 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 hwif->tp_ops->output_data(drive, NULL, rq->cmd, 12); 261 hwif->tp_ops->output_data(drive, NULL, rq->cmd, 12);
262 262
263 return ide_started; 263 return ide_started;
@@ -302,7 +302,8 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, struct ide_atapi_pc *pc,
302 bcount, dma); 302 bcount, dma);
303 303
304 /* Issue the packet command */ 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 ide_execute_command(drive, WIN_PACKETCMD, handler, 307 ide_execute_command(drive, WIN_PACKETCMD, handler,
307 timeout, NULL); 308 timeout, NULL);
308 return ide_started; 309 return ide_started;
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index cbf84f2e9cce..3d8e6dd0f41e 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -125,26 +125,10 @@ typedef struct ide_floppy_obj {
125 int wp; 125 int wp;
126 /* Supports format progress report */ 126 /* Supports format progress report */
127 int srfp; 127 int srfp;
128 /* Status/Action flags */
129 unsigned long flags;
130} idefloppy_floppy_t; 128} idefloppy_floppy_t;
131 129
132#define IDEFLOPPY_TICKS_DELAY HZ/20 /* default delay for ZIP 100 (50ms) */ 130#define IDEFLOPPY_TICKS_DELAY HZ/20 /* default delay for ZIP 100 (50ms) */
133 131
134/* Floppy flag bits values. */
135enum {
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/* Defines for the MODE SENSE command */ 132/* Defines for the MODE SENSE command */
149#define MODE_SENSE_CURRENT 0x00 133#define MODE_SENSE_CURRENT 0x00
150#define MODE_SENSE_CHANGEABLE 0x01 134#define MODE_SENSE_CHANGEABLE 0x01
@@ -429,7 +413,7 @@ static ide_startstop_t idefloppy_start_pc_transfer(ide_drive_t *drive)
429 * 40 and 50msec work well. idefloppy_pc_intr will not be actually 413 * 40 and 50msec work well. idefloppy_pc_intr will not be actually
430 * used until after the packet is moved in about 50 msec. 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 timeout = floppy->ticks; 417 timeout = floppy->ticks;
434 expiry = &idefloppy_transfer_pc; 418 expiry = &idefloppy_transfer_pc;
435 } else { 419 } else {
@@ -649,12 +633,6 @@ static ide_startstop_t idefloppy_do_request(ide_drive_t *drive,
649 return ide_stopped; 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 pc->rq = rq; 636 pc->rq = rq;
659 637
660 return idefloppy_issue_pc(drive, pc); 638 return idefloppy_issue_pc(drive, pc);
@@ -798,7 +776,7 @@ static int ide_floppy_get_capacity(ide_drive_t *drive)
798 switch (pc.buf[desc_start + 4] & 0x03) { 776 switch (pc.buf[desc_start + 4] & 0x03) {
799 /* Clik! drive returns this instead of CAPACITY_CURRENT */ 777 /* Clik! drive returns this instead of CAPACITY_CURRENT */
800 case CAPACITY_UNFORMATTED: 778 case CAPACITY_UNFORMATTED:
801 if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) 779 if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE))
802 /* 780 /*
803 * If it is not a clik drive, break out 781 * If it is not a clik drive, break out
804 * (maintains previous driver behaviour) 782 * (maintains previous driver behaviour)
@@ -844,7 +822,7 @@ static int ide_floppy_get_capacity(ide_drive_t *drive)
844 } 822 }
845 823
846 /* Clik! disk does not support get_flexible_disk_page */ 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 (void) ide_floppy_get_flexible_disk_page(drive); 826 (void) ide_floppy_get_flexible_disk_page(drive);
849 827
850 set_capacity(floppy->disk, floppy->blocks * floppy->bs_factor); 828 set_capacity(floppy->disk, floppy->blocks * floppy->bs_factor);
@@ -1046,7 +1024,7 @@ static void idefloppy_setup(ide_drive_t *drive, idefloppy_floppy_t *floppy)
1046 drive->pc_callback = ide_floppy_callback; 1024 drive->pc_callback = ide_floppy_callback;
1047 1025
1048 if (((gcw[0] & 0x60) >> 5) == 1) 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 * We used to check revisions here. At this point however I'm giving up. 1029 * We used to check revisions here. At this point however I'm giving up.
1052 * Just assume they are all broken, its easier. 1030 * Just assume they are all broken, its easier.
@@ -1057,7 +1035,7 @@ static void idefloppy_setup(ide_drive_t *drive, idefloppy_floppy_t *floppy)
1057 * we'll leave the limitation below for the 2.2.x tree. 1035 * we'll leave the limitation below for the 2.2.x tree.
1058 */ 1036 */
1059 if (!strncmp(drive->id->model, "IOMEGA ZIP 100 ATAPI", 20)) { 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 /* This value will be visible in the /proc/ide/hdx/settings */ 1039 /* This value will be visible in the /proc/ide/hdx/settings */
1062 floppy->ticks = IDEFLOPPY_TICKS_DELAY; 1040 floppy->ticks = IDEFLOPPY_TICKS_DELAY;
1063 blk_queue_max_sectors(drive->queue, 64); 1041 blk_queue_max_sectors(drive->queue, 64);
@@ -1069,7 +1047,7 @@ static void idefloppy_setup(ide_drive_t *drive, idefloppy_floppy_t *floppy)
1069 */ 1047 */
1070 if (strncmp(drive->id->model, "IOMEGA Clik!", 11) == 0) { 1048 if (strncmp(drive->id->model, "IOMEGA Clik!", 11) == 0) {
1071 blk_queue_max_sectors(drive->queue, 64); 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 (void) ide_floppy_get_capacity(drive); 1053 (void) ide_floppy_get_capacity(drive);
@@ -1158,7 +1136,7 @@ static int idefloppy_open(struct inode *inode, struct file *filp)
1158 floppy->openers++; 1136 floppy->openers++;
1159 1137
1160 if (floppy->openers == 1) { 1138 if (floppy->openers == 1) {
1161 floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS; 1139 drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS;
1162 /* Just in case */ 1140 /* Just in case */
1163 1141
1164 idefloppy_init_pc(&pc); 1142 idefloppy_init_pc(&pc);
@@ -1185,14 +1163,14 @@ static int idefloppy_open(struct inode *inode, struct file *filp)
1185 ret = -EROFS; 1163 ret = -EROFS;
1186 goto out_put_floppy; 1164 goto out_put_floppy;
1187 } 1165 }
1188 floppy->flags |= IDEFLOPPY_FLAG_MEDIA_CHANGED; 1166 drive->atapi_flags |= IDE_AFLAG_MEDIA_CHANGED;
1189 /* IOMEGA Clik! drives do not support lock/unlock commands */ 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 idefloppy_create_prevent_cmd(&pc, 1); 1169 idefloppy_create_prevent_cmd(&pc, 1);
1192 (void) idefloppy_queue_pc_tail(drive, &pc); 1170 (void) idefloppy_queue_pc_tail(drive, &pc);
1193 } 1171 }
1194 check_disk_change(inode->i_bdev); 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 ret = -EBUSY; 1174 ret = -EBUSY;
1197 goto out_put_floppy; 1175 goto out_put_floppy;
1198 } 1176 }
@@ -1215,12 +1193,12 @@ static int idefloppy_release(struct inode *inode, struct file *filp)
1215 1193
1216 if (floppy->openers == 1) { 1194 if (floppy->openers == 1) {
1217 /* IOMEGA Clik! drives do not support lock/unlock commands */ 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 idefloppy_create_prevent_cmd(&pc, 0); 1197 idefloppy_create_prevent_cmd(&pc, 0);
1220 (void) idefloppy_queue_pc_tail(drive, &pc); 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 floppy->openers--; 1204 floppy->openers--;
@@ -1241,15 +1219,17 @@ static int idefloppy_getgeo(struct block_device *bdev, struct hd_geometry *geo)
1241 return 0; 1219 return 0;
1242} 1220}
1243 1221
1244static int ide_floppy_lockdoor(idefloppy_floppy_t *floppy, 1222static int ide_floppy_lockdoor(ide_drive_t *drive, struct ide_atapi_pc *pc,
1245 struct ide_atapi_pc *pc, unsigned long arg, unsigned int cmd) 1223 unsigned long arg, unsigned int cmd)
1246{ 1224{
1225 idefloppy_floppy_t *floppy = drive->driver_data;
1226
1247 if (floppy->openers > 1) 1227 if (floppy->openers > 1)
1248 return -EBUSY; 1228 return -EBUSY;
1249 1229
1250 /* The IOMEGA Clik! Drive doesn't support this command - 1230 /* The IOMEGA Clik! Drive doesn't support this command -
1251 * no room for an eject mechanism */ 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 int prevent = arg ? 1 : 0; 1233 int prevent = arg ? 1 : 0;
1254 1234
1255 if (cmd == CDROMEJECT) 1235 if (cmd == CDROMEJECT)
@@ -1270,16 +1250,17 @@ static int ide_floppy_lockdoor(idefloppy_floppy_t *floppy,
1270static int ide_floppy_format_unit(idefloppy_floppy_t *floppy, 1250static int ide_floppy_format_unit(idefloppy_floppy_t *floppy,
1271 int __user *arg) 1251 int __user *arg)
1272{ 1252{
1273 int blocks, length, flags, err = 0;
1274 struct ide_atapi_pc pc; 1253 struct ide_atapi_pc pc;
1254 ide_drive_t *drive = floppy->drive;
1255 int blocks, length, flags, err = 0;
1275 1256
1276 if (floppy->openers > 1) { 1257 if (floppy->openers > 1) {
1277 /* Don't format if someone is using the disk */ 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 return -EBUSY; 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 * Send ATAPI_FORMAT_UNIT to the drive. 1266 * Send ATAPI_FORMAT_UNIT to the drive.
@@ -1303,15 +1284,15 @@ static int ide_floppy_format_unit(idefloppy_floppy_t *floppy,
1303 goto out; 1284 goto out;
1304 } 1285 }
1305 1286
1306 (void) idefloppy_get_sfrp_bit(floppy->drive); 1287 (void) idefloppy_get_sfrp_bit(drive);
1307 idefloppy_create_format_unit_cmd(&pc, blocks, length, flags); 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 err = -EIO; 1291 err = -EIO;
1311 1292
1312out: 1293out:
1313 if (err) 1294 if (err)
1314 floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS; 1295 drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS;
1315 return err; 1296 return err;
1316} 1297}
1317 1298
@@ -1330,7 +1311,7 @@ static int idefloppy_ioctl(struct inode *inode, struct file *file,
1330 case CDROMEJECT: 1311 case CDROMEJECT:
1331 /* fall through */ 1312 /* fall through */
1332 case CDROM_LOCKDOOR: 1313 case CDROM_LOCKDOOR:
1333 return ide_floppy_lockdoor(floppy, &pc, arg, cmd); 1314 return ide_floppy_lockdoor(drive, &pc, arg, cmd);
1334 case IDEFLOPPY_IOCTL_FORMAT_SUPPORTED: 1315 case IDEFLOPPY_IOCTL_FORMAT_SUPPORTED:
1335 return 0; 1316 return 0;
1336 case IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY: 1317 case IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY:
@@ -1371,8 +1352,8 @@ static int idefloppy_media_changed(struct gendisk *disk)
1371 drive->attach = 0; 1352 drive->attach = 0;
1372 return 0; 1353 return 0;
1373 } 1354 }
1374 ret = !!(floppy->flags & IDEFLOPPY_FLAG_MEDIA_CHANGED); 1355 ret = !!(drive->atapi_flags & IDE_AFLAG_MEDIA_CHANGED);
1375 floppy->flags &= ~IDEFLOPPY_FLAG_MEDIA_CHANGED; 1356 drive->atapi_flags &= ~IDE_AFLAG_MEDIA_CHANGED;
1376 return ret; 1357 return ret;
1377} 1358}
1378 1359