1 From 49d8078ad1c3dca5b11ce18391bf6bd9af9acdf5 Mon Sep 17 00:00:00 2001
2 From: Borislav Petkov <petkovbb@googlemail.com>
3 Date: Sun, 7 Jun 2009 15:37:06 +0200
4 Subject: ide-tape: fix IDE_AFLAG_* atomic accesses
8 These flags used to be bit numbers and now are single bits in the
9 ->atapi_flags vector. Use them properly.
11 Spotted-by: Jiri Slaby <jirislaby@gmail.com>
12 Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
13 Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
14 Signed-off-by: Jiri Slaby <jslaby@suse.cz>
16 drivers/ide/ide-tape.c | 44 ++++++++++++++++++++++++++------------------
17 1 file changed, 26 insertions(+), 18 deletions(-)
19 --- a/drivers/ide/ide-tape.c
20 +++ b/drivers/ide/ide-tape.c
21 @@ -652,7 +652,8 @@ static void ide_tape_callback(ide_drive_
22 if (readpos[0] & 0x4) {
23 printk(KERN_INFO "ide-tape: Block location is unknown"
25 - clear_bit(IDE_AFLAG_ADDRESS_VALID, &drive->atapi_flags);
26 + clear_bit(ilog2(IDE_AFLAG_ADDRESS_VALID),
27 + &drive->atapi_flags);
30 debug_log(DBG_SENSE, "Block Location - %u\n",
31 @@ -660,7 +661,8 @@ static void ide_tape_callback(ide_drive_
33 tape->partition = readpos[1];
34 tape->first_frame = be32_to_cpup((__be32 *)&readpos[4]);
35 - set_bit(IDE_AFLAG_ADDRESS_VALID, &drive->atapi_flags);
36 + set_bit(ilog2(IDE_AFLAG_ADDRESS_VALID),
37 + &drive->atapi_flags);
41 @@ -1294,7 +1296,7 @@ static int idetape_wait_ready(ide_drive_
42 int load_attempted = 0;
44 /* Wait for the tape to become ready */
45 - set_bit(IDE_AFLAG_MEDIUM_PRESENT, &drive->atapi_flags);
46 + set_bit(ilog2(IDE_AFLAG_MEDIUM_PRESENT), &drive->atapi_flags);
48 while (time_before(jiffies, timeout)) {
49 idetape_create_test_unit_ready_cmd(&pc);
50 @@ -1387,7 +1389,7 @@ static void __ide_tape_discard_merge_buf
51 if (tape->chrdev_dir != IDETAPE_DIR_READ)
54 - clear_bit(IDE_AFLAG_FILEMARK, &drive->atapi_flags);
55 + clear_bit(ilog2(IDE_AFLAG_FILEMARK), &drive->atapi_flags);
56 tape->merge_bh_size = 0;
57 if (tape->merge_bh != NULL) {
58 ide_tape_kfree_buffer(tape);
59 @@ -1626,7 +1628,7 @@ static int idetape_add_chrdev_read_reque
60 debug_log(DBG_PROCS, "Enter %s, %d blocks\n", __func__, blocks);
62 /* If we are at a filemark, return a read length of 0 */
63 - if (test_bit(IDE_AFLAG_FILEMARK, &drive->atapi_flags))
64 + if (test_bit(ilog2(IDE_AFLAG_FILEMARK), &drive->atapi_flags))
67 idetape_init_read(drive);
68 @@ -1736,7 +1738,8 @@ static int idetape_space_over_filemarks(
70 if (tape->chrdev_dir == IDETAPE_DIR_READ) {
71 tape->merge_bh_size = 0;
72 - if (test_and_clear_bit(IDE_AFLAG_FILEMARK, &drive->atapi_flags))
73 + if (test_and_clear_bit(ilog2(IDE_AFLAG_FILEMARK),
74 + &drive->atapi_flags))
76 ide_tape_discard_merge_buffer(drive, 0);
78 @@ -1791,7 +1794,7 @@ static ssize_t idetape_chrdev_read(struc
79 debug_log(DBG_CHRDEV, "Enter %s, count %Zd\n", __func__, count);
81 if (tape->chrdev_dir != IDETAPE_DIR_READ) {
82 - if (test_bit(IDE_AFLAG_DETECT_BS, &drive->atapi_flags))
83 + if (test_bit(ilog2(IDE_AFLAG_DETECT_BS), &drive->atapi_flags))
84 if (count > tape->blk_size &&
85 (count % tape->blk_size) == 0)
86 tape->user_bs_factor = count / tape->blk_size;
87 @@ -1831,7 +1834,8 @@ static ssize_t idetape_chrdev_read(struc
88 tape->merge_bh_size = bytes_read-temp;
91 - if (!actually_read && test_bit(IDE_AFLAG_FILEMARK, &drive->atapi_flags)) {
92 + if (!actually_read && test_bit(ilog2(IDE_AFLAG_FILEMARK),
93 + &drive->atapi_flags)) {
94 debug_log(DBG_SENSE, "%s: spacing over filemark\n", tape->name);
96 idetape_space_over_filemarks(drive, MTFSF, 1);
97 @@ -2017,7 +2021,8 @@ static int idetape_mtioctop(ide_drive_t
98 !IDETAPE_LU_LOAD_MASK);
99 retval = idetape_queue_pc_tail(drive, &pc);
101 - clear_bit(IDE_AFLAG_MEDIUM_PRESENT, &drive->atapi_flags);
102 + clear_bit(ilog2(IDE_AFLAG_MEDIUM_PRESENT),
103 + &drive->atapi_flags);
106 ide_tape_discard_merge_buffer(drive, 0);
107 @@ -2040,9 +2045,11 @@ static int idetape_mtioctop(ide_drive_t
108 mt_count % tape->blk_size)
110 tape->user_bs_factor = mt_count / tape->blk_size;
111 - clear_bit(IDE_AFLAG_DETECT_BS, &drive->atapi_flags);
112 + clear_bit(ilog2(IDE_AFLAG_DETECT_BS),
113 + &drive->atapi_flags);
115 - set_bit(IDE_AFLAG_DETECT_BS, &drive->atapi_flags);
116 + set_bit(ilog2(IDE_AFLAG_DETECT_BS),
117 + &drive->atapi_flags);
120 ide_tape_discard_merge_buffer(drive, 0);
121 @@ -2192,20 +2199,20 @@ static int idetape_chrdev_open(struct in
123 filp->private_data = tape;
125 - if (test_and_set_bit(IDE_AFLAG_BUSY, &drive->atapi_flags)) {
126 + if (test_and_set_bit(ilog2(IDE_AFLAG_BUSY), &drive->atapi_flags)) {
131 retval = idetape_wait_ready(drive, 60 * HZ);
133 - clear_bit(IDE_AFLAG_BUSY, &drive->atapi_flags);
134 + clear_bit(ilog2(IDE_AFLAG_BUSY), &drive->atapi_flags);
135 printk(KERN_ERR "ide-tape: %s: drive not ready\n", tape->name);
139 idetape_read_position(drive);
140 - if (!test_bit(IDE_AFLAG_ADDRESS_VALID, &drive->atapi_flags))
141 + if (!test_bit(ilog2(IDE_AFLAG_ADDRESS_VALID), &drive->atapi_flags))
142 (void)idetape_rewind_tape(drive);
144 /* Read block size and write protect status from drive. */
145 @@ -2221,7 +2228,7 @@ static int idetape_chrdev_open(struct in
146 if (tape->write_prot) {
147 if ((filp->f_flags & O_ACCMODE) == O_WRONLY ||
148 (filp->f_flags & O_ACCMODE) == O_RDWR) {
149 - clear_bit(IDE_AFLAG_BUSY, &drive->atapi_flags);
150 + clear_bit(ilog2(IDE_AFLAG_BUSY), &drive->atapi_flags);
154 @@ -2281,7 +2288,8 @@ static int idetape_chrdev_release(struct
155 ide_tape_discard_merge_buffer(drive, 1);
158 - if (minor < 128 && test_bit(IDE_AFLAG_MEDIUM_PRESENT, &drive->atapi_flags))
159 + if (minor < 128 && test_bit(ilog2(IDE_AFLAG_MEDIUM_PRESENT),
160 + &drive->atapi_flags))
161 (void) idetape_rewind_tape(drive);
162 if (tape->chrdev_dir == IDETAPE_DIR_NONE) {
163 if (tape->door_locked == DOOR_LOCKED) {
164 @@ -2291,7 +2299,7 @@ static int idetape_chrdev_release(struct
168 - clear_bit(IDE_AFLAG_BUSY, &drive->atapi_flags);
169 + clear_bit(ilog2(IDE_AFLAG_BUSY), &drive->atapi_flags);
173 @@ -2476,7 +2484,7 @@ static void idetape_setup(ide_drive_t *d
175 /* Command packet DRQ type */
176 if (((gcw[0] & 0x60) >> 5) == 1)
177 - set_bit(IDE_AFLAG_DRQ_INTERRUPT, &drive->atapi_flags);
178 + set_bit(ilog2(IDE_AFLAG_DRQ_INTERRUPT), &drive->atapi_flags);
180 idetape_get_inquiry_results(drive);
181 idetape_get_mode_sense_results(drive);