aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBorislav Petkov <petkovbb@googlemail.com>2008-02-05 20:57:52 -0500
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-02-05 20:57:52 -0500
commit54abf37e4236288687ee44fef2060092b42f5cec (patch)
tree56f06b870f03f34c1a01ba2db52127af5bd1adb3 /drivers
parenta1efc85f0b4d48627ef0b2aeb766a39fb4a00561 (diff)
ide-tape: remove typedef idetape_chrdev_direction_t
.. and replace it with plain enums. 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-tape.c62
1 files changed, 32 insertions, 30 deletions
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 8b6af1e0ed2d..73f06c859301 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -184,11 +184,13 @@ enum {
184/* 184/*
185 * For general magnetic tape device compatibility. 185 * For general magnetic tape device compatibility.
186 */ 186 */
187typedef enum { 187
188 idetape_direction_none, 188/* tape directions */
189 idetape_direction_read, 189enum {
190 idetape_direction_write 190 IDETAPE_DIR_NONE = (1 << 0),
191} idetape_chrdev_direction_t; 191 IDETAPE_DIR_READ = (1 << 1),
192 IDETAPE_DIR_WRITE = (1 << 2),
193};
192 194
193struct idetape_bh { 195struct idetape_bh {
194 u32 b_size; 196 u32 b_size;
@@ -324,7 +326,7 @@ typedef struct ide_tape_obj {
324 /* device name */ 326 /* device name */
325 char name[4]; 327 char name[4];
326 /* Current character device data transfer direction */ 328 /* Current character device data transfer direction */
327 idetape_chrdev_direction_t chrdev_direction; 329 u8 chrdev_dir;
328 330
329 /* 331 /*
330 * Device information 332 * Device information
@@ -1916,7 +1918,7 @@ static void idetape_init_merge_stage (idetape_tape_t *tape)
1916 struct idetape_bh *bh = tape->merge_stage->bh; 1918 struct idetape_bh *bh = tape->merge_stage->bh;
1917 1919
1918 tape->bh = bh; 1920 tape->bh = bh;
1919 if (tape->chrdev_direction == idetape_direction_write) 1921 if (tape->chrdev_dir == IDETAPE_DIR_WRITE)
1920 atomic_set(&bh->b_count, 0); 1922 atomic_set(&bh->b_count, 0);
1921 else { 1923 else {
1922 tape->b_data = bh->b_data; 1924 tape->b_data = bh->b_data;
@@ -2186,7 +2188,7 @@ static int __idetape_discard_read_pipeline (ide_drive_t *drive)
2186 unsigned long flags; 2188 unsigned long flags;
2187 int cnt; 2189 int cnt;
2188 2190
2189 if (tape->chrdev_direction != idetape_direction_read) 2191 if (tape->chrdev_dir != IDETAPE_DIR_READ)
2190 return 0; 2192 return 0;
2191 2193
2192 /* Remove merge stage. */ 2194 /* Remove merge stage. */
@@ -2201,7 +2203,7 @@ static int __idetape_discard_read_pipeline (ide_drive_t *drive)
2201 2203
2202 /* Clear pipeline flags. */ 2204 /* Clear pipeline flags. */
2203 clear_bit(IDETAPE_PIPELINE_ERROR, &tape->flags); 2205 clear_bit(IDETAPE_PIPELINE_ERROR, &tape->flags);
2204 tape->chrdev_direction = idetape_direction_none; 2206 tape->chrdev_dir = IDETAPE_DIR_NONE;
2205 2207
2206 /* Remove pipeline stages. */ 2208 /* Remove pipeline stages. */
2207 if (tape->first_stage == NULL) 2209 if (tape->first_stage == NULL)
@@ -2241,7 +2243,7 @@ static int idetape_position_tape (ide_drive_t *drive, unsigned int block, u8 par
2241 int retval; 2243 int retval;
2242 idetape_pc_t pc; 2244 idetape_pc_t pc;
2243 2245
2244 if (tape->chrdev_direction == idetape_direction_read) 2246 if (tape->chrdev_dir == IDETAPE_DIR_READ)
2245 __idetape_discard_read_pipeline(drive); 2247 __idetape_discard_read_pipeline(drive);
2246 idetape_wait_ready(drive, 60 * 5 * HZ); 2248 idetape_wait_ready(drive, 60 * 5 * HZ);
2247 idetape_create_locate_cmd(drive, &pc, block, partition, skip); 2249 idetape_create_locate_cmd(drive, &pc, block, partition, skip);
@@ -2468,7 +2470,7 @@ static void idetape_empty_write_pipeline (ide_drive_t *drive)
2468 int blocks, min; 2470 int blocks, min;
2469 struct idetape_bh *bh; 2471 struct idetape_bh *bh;
2470 2472
2471 if (tape->chrdev_direction != idetape_direction_write) { 2473 if (tape->chrdev_dir != IDETAPE_DIR_WRITE) {
2472 printk(KERN_ERR "ide-tape: bug: Trying to empty write pipeline, but we are not writing.\n"); 2474 printk(KERN_ERR "ide-tape: bug: Trying to empty write pipeline, but we are not writing.\n");
2473 return; 2475 return;
2474 } 2476 }
@@ -2511,7 +2513,7 @@ static void idetape_empty_write_pipeline (ide_drive_t *drive)
2511 tape->merge_stage = NULL; 2513 tape->merge_stage = NULL;
2512 } 2514 }
2513 clear_bit(IDETAPE_PIPELINE_ERROR, &tape->flags); 2515 clear_bit(IDETAPE_PIPELINE_ERROR, &tape->flags);
2514 tape->chrdev_direction = idetape_direction_none; 2516 tape->chrdev_dir = IDETAPE_DIR_NONE;
2515 2517
2516 /* 2518 /*
2517 * On the next backup, perform the feedback loop again. 2519 * On the next backup, perform the feedback loop again.
@@ -2555,8 +2557,8 @@ static int idetape_initiate_read (ide_drive_t *drive, int max_stages)
2555 u16 blocks = *(u16 *)&tape->caps[12]; 2557 u16 blocks = *(u16 *)&tape->caps[12];
2556 2558
2557 /* Initialize read operation */ 2559 /* Initialize read operation */
2558 if (tape->chrdev_direction != idetape_direction_read) { 2560 if (tape->chrdev_dir != IDETAPE_DIR_READ) {
2559 if (tape->chrdev_direction == idetape_direction_write) { 2561 if (tape->chrdev_dir == IDETAPE_DIR_WRITE) {
2560 idetape_empty_write_pipeline(drive); 2562 idetape_empty_write_pipeline(drive);
2561 idetape_flush_tape_buffers(drive); 2563 idetape_flush_tape_buffers(drive);
2562 } 2564 }
@@ -2566,7 +2568,7 @@ static int idetape_initiate_read (ide_drive_t *drive, int max_stages)
2566 } 2568 }
2567 if ((tape->merge_stage = __idetape_kmalloc_stage(tape, 0, 0)) == NULL) 2569 if ((tape->merge_stage = __idetape_kmalloc_stage(tape, 0, 0)) == NULL)
2568 return -ENOMEM; 2570 return -ENOMEM;
2569 tape->chrdev_direction = idetape_direction_read; 2571 tape->chrdev_dir = IDETAPE_DIR_READ;
2570 2572
2571 /* 2573 /*
2572 * Issue a read 0 command to ensure that DSC handshake 2574 * Issue a read 0 command to ensure that DSC handshake
@@ -2580,7 +2582,7 @@ static int idetape_initiate_read (ide_drive_t *drive, int max_stages)
2580 if (bytes_read < 0) { 2582 if (bytes_read < 0) {
2581 __idetape_kfree_stage(tape->merge_stage); 2583 __idetape_kfree_stage(tape->merge_stage);
2582 tape->merge_stage = NULL; 2584 tape->merge_stage = NULL;
2583 tape->chrdev_direction = idetape_direction_none; 2585 tape->chrdev_dir = IDETAPE_DIR_NONE;
2584 return bytes_read; 2586 return bytes_read;
2585 } 2587 }
2586 } 2588 }
@@ -2801,7 +2803,7 @@ static int idetape_space_over_filemarks (ide_drive_t *drive,short mt_op,int mt_c
2801 mt_count = - mt_count; 2803 mt_count = - mt_count;
2802 } 2804 }
2803 2805
2804 if (tape->chrdev_direction == idetape_direction_read) { 2806 if (tape->chrdev_dir == IDETAPE_DIR_READ) {
2805 /* 2807 /*
2806 * We have a read-ahead buffer. Scan it for crossed 2808 * We have a read-ahead buffer. Scan it for crossed
2807 * filemarks. 2809 * filemarks.
@@ -2891,7 +2893,7 @@ static ssize_t idetape_chrdev_read (struct file *file, char __user *buf,
2891 2893
2892 debug_log(DBG_CHRDEV, "Enter %s, count %Zd\n", __func__, count); 2894 debug_log(DBG_CHRDEV, "Enter %s, count %Zd\n", __func__, count);
2893 2895
2894 if (tape->chrdev_direction != idetape_direction_read) { 2896 if (tape->chrdev_dir != IDETAPE_DIR_READ) {
2895 if (test_bit(IDETAPE_DETECT_BS, &tape->flags)) 2897 if (test_bit(IDETAPE_DETECT_BS, &tape->flags))
2896 if (count > tape->tape_block_size && 2898 if (count > tape->tape_block_size &&
2897 (count % tape->tape_block_size) == 0) 2899 (count % tape->tape_block_size) == 0)
@@ -2956,8 +2958,8 @@ static ssize_t idetape_chrdev_write (struct file *file, const char __user *buf,
2956 debug_log(DBG_CHRDEV, "Enter %s, count %Zd\n", __func__, count); 2958 debug_log(DBG_CHRDEV, "Enter %s, count %Zd\n", __func__, count);
2957 2959
2958 /* Initialize write operation */ 2960 /* Initialize write operation */
2959 if (tape->chrdev_direction != idetape_direction_write) { 2961 if (tape->chrdev_dir != IDETAPE_DIR_WRITE) {
2960 if (tape->chrdev_direction == idetape_direction_read) 2962 if (tape->chrdev_dir == IDETAPE_DIR_READ)
2961 idetape_discard_read_pipeline(drive, 1); 2963 idetape_discard_read_pipeline(drive, 1);
2962 if (tape->merge_stage || tape->merge_stage_size) { 2964 if (tape->merge_stage || tape->merge_stage_size) {
2963 printk(KERN_ERR "ide-tape: merge_stage_size " 2965 printk(KERN_ERR "ide-tape: merge_stage_size "
@@ -2966,7 +2968,7 @@ static ssize_t idetape_chrdev_write (struct file *file, const char __user *buf,
2966 } 2968 }
2967 if ((tape->merge_stage = __idetape_kmalloc_stage(tape, 0, 0)) == NULL) 2969 if ((tape->merge_stage = __idetape_kmalloc_stage(tape, 0, 0)) == NULL)
2968 return -ENOMEM; 2970 return -ENOMEM;
2969 tape->chrdev_direction = idetape_direction_write; 2971 tape->chrdev_dir = IDETAPE_DIR_WRITE;
2970 idetape_init_merge_stage(tape); 2972 idetape_init_merge_stage(tape);
2971 2973
2972 /* 2974 /*
@@ -2981,7 +2983,7 @@ static ssize_t idetape_chrdev_write (struct file *file, const char __user *buf,
2981 if (retval < 0) { 2983 if (retval < 0) {
2982 __idetape_kfree_stage(tape->merge_stage); 2984 __idetape_kfree_stage(tape->merge_stage);
2983 tape->merge_stage = NULL; 2985 tape->merge_stage = NULL;
2984 tape->chrdev_direction = idetape_direction_none; 2986 tape->chrdev_dir = IDETAPE_DIR_NONE;
2985 return retval; 2987 return retval;
2986 } 2988 }
2987 } 2989 }
@@ -3187,7 +3189,7 @@ static int idetape_chrdev_ioctl(struct inode *inode, struct file *file,
3187 debug_log(DBG_CHRDEV, "Enter %s, cmd=%u\n", __func__, cmd); 3189 debug_log(DBG_CHRDEV, "Enter %s, cmd=%u\n", __func__, cmd);
3188 3190
3189 tape->restart_speed_control_req = 1; 3191 tape->restart_speed_control_req = 1;
3190 if (tape->chrdev_direction == idetape_direction_write) { 3192 if (tape->chrdev_dir == IDETAPE_DIR_WRITE) {
3191 idetape_empty_write_pipeline(drive); 3193 idetape_empty_write_pipeline(drive);
3192 idetape_flush_tape_buffers(drive); 3194 idetape_flush_tape_buffers(drive);
3193 } 3195 }
@@ -3218,7 +3220,7 @@ static int idetape_chrdev_ioctl(struct inode *inode, struct file *file,
3218 return -EFAULT; 3220 return -EFAULT;
3219 return 0; 3221 return 0;
3220 default: 3222 default:
3221 if (tape->chrdev_direction == idetape_direction_read) 3223 if (tape->chrdev_dir == IDETAPE_DIR_READ)
3222 idetape_discard_read_pipeline(drive, 1); 3224 idetape_discard_read_pipeline(drive, 1);
3223 return idetape_blkdev_ioctl(drive, cmd, arg); 3225 return idetape_blkdev_ioctl(drive, cmd, arg);
3224 } 3226 }
@@ -3296,7 +3298,7 @@ static int idetape_chrdev_open (struct inode *inode, struct file *filp)
3296 if (!test_bit(IDETAPE_ADDRESS_VALID, &tape->flags)) 3298 if (!test_bit(IDETAPE_ADDRESS_VALID, &tape->flags))
3297 (void)idetape_rewind_tape(drive); 3299 (void)idetape_rewind_tape(drive);
3298 3300
3299 if (tape->chrdev_direction != idetape_direction_read) 3301 if (tape->chrdev_dir != IDETAPE_DIR_READ)
3300 clear_bit(IDETAPE_PIPELINE_ERROR, &tape->flags); 3302 clear_bit(IDETAPE_PIPELINE_ERROR, &tape->flags);
3301 3303
3302 /* Read block size and write protect status from drive. */ 3304 /* Read block size and write protect status from drive. */
@@ -3321,7 +3323,7 @@ static int idetape_chrdev_open (struct inode *inode, struct file *filp)
3321 /* 3323 /*
3322 * Lock the tape drive door so user can't eject. 3324 * Lock the tape drive door so user can't eject.
3323 */ 3325 */
3324 if (tape->chrdev_direction == idetape_direction_none) { 3326 if (tape->chrdev_dir == IDETAPE_DIR_NONE) {
3325 if (idetape_create_prevent_cmd(drive, &pc, 1)) { 3327 if (idetape_create_prevent_cmd(drive, &pc, 1)) {
3326 if (!idetape_queue_pc_tail(drive, &pc)) { 3328 if (!idetape_queue_pc_tail(drive, &pc)) {
3327 if (tape->door_locked != DOOR_EXPLICITLY_LOCKED) 3329 if (tape->door_locked != DOOR_EXPLICITLY_LOCKED)
@@ -3369,9 +3371,9 @@ static int idetape_chrdev_release (struct inode *inode, struct file *filp)
3369 3371
3370 debug_log(DBG_CHRDEV, "Enter %s\n", __func__); 3372 debug_log(DBG_CHRDEV, "Enter %s\n", __func__);
3371 3373
3372 if (tape->chrdev_direction == idetape_direction_write) 3374 if (tape->chrdev_dir == IDETAPE_DIR_WRITE)
3373 idetape_write_release(drive, minor); 3375 idetape_write_release(drive, minor);
3374 if (tape->chrdev_direction == idetape_direction_read) { 3376 if (tape->chrdev_dir == IDETAPE_DIR_READ) {
3375 if (minor < 128) 3377 if (minor < 128)
3376 idetape_discard_read_pipeline(drive, 1); 3378 idetape_discard_read_pipeline(drive, 1);
3377 else 3379 else
@@ -3383,7 +3385,7 @@ static int idetape_chrdev_release (struct inode *inode, struct file *filp)
3383 } 3385 }
3384 if (minor < 128 && test_bit(IDETAPE_MEDIUM_PRESENT, &tape->flags)) 3386 if (minor < 128 && test_bit(IDETAPE_MEDIUM_PRESENT, &tape->flags))
3385 (void) idetape_rewind_tape(drive); 3387 (void) idetape_rewind_tape(drive);
3386 if (tape->chrdev_direction == idetape_direction_none) { 3388 if (tape->chrdev_dir == IDETAPE_DIR_NONE) {
3387 if (tape->door_locked == DOOR_LOCKED) { 3389 if (tape->door_locked == DOOR_LOCKED) {
3388 if (idetape_create_prevent_cmd(drive, &pc, 0)) { 3390 if (idetape_create_prevent_cmd(drive, &pc, 0)) {
3389 if (!idetape_queue_pc_tail(drive, &pc)) 3391 if (!idetape_queue_pc_tail(drive, &pc))
@@ -3577,7 +3579,7 @@ static void idetape_setup (ide_drive_t *drive, idetape_tape_t *tape, int minor)
3577 tape->name[0] = 'h'; 3579 tape->name[0] = 'h';
3578 tape->name[1] = 't'; 3580 tape->name[1] = 't';
3579 tape->name[2] = '0' + minor; 3581 tape->name[2] = '0' + minor;
3580 tape->chrdev_direction = idetape_direction_none; 3582 tape->chrdev_dir = IDETAPE_DIR_NONE;
3581 tape->pc = tape->pc_stack; 3583 tape->pc = tape->pc_stack;
3582 tape->max_insert_speed = 10000; 3584 tape->max_insert_speed = 10000;
3583 tape->speed_control = 1; 3585 tape->speed_control = 1;