]>
Commit | Line | Data |
---|---|---|
00e5a55c BS |
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 | |
5 | Patch-mainline: yes | |
6 | References: bnc#509071 | |
7 | ||
8 | These flags used to be bit numbers and now are single bits in the | |
9 | ->atapi_flags vector. Use them properly. | |
10 | ||
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> | |
15 | --- | |
16 | drivers/ide/ide-tape.c | 44 ++++++++++++++++++++++++++------------------ | |
17 | 1 file changed, 26 insertions(+), 18 deletions(-) | |
18 | ||
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" | |
24 | "to the tape\n"); | |
25 | - clear_bit(IDE_AFLAG_ADDRESS_VALID, &drive->atapi_flags); | |
26 | + clear_bit(ilog2(IDE_AFLAG_ADDRESS_VALID), | |
27 | + &drive->atapi_flags); | |
28 | uptodate = 0; | |
29 | } else { | |
30 | debug_log(DBG_SENSE, "Block Location - %u\n", | |
31 | @@ -660,7 +661,8 @@ static void ide_tape_callback(ide_drive_ | |
32 | ||
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); | |
38 | } | |
39 | } | |
40 | ||
41 | @@ -1294,7 +1296,7 @@ static int idetape_wait_ready(ide_drive_ | |
42 | int load_attempted = 0; | |
43 | ||
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); | |
47 | timeout += jiffies; | |
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) | |
52 | return; | |
53 | ||
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); | |
61 | ||
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)) | |
65 | return 0; | |
66 | ||
67 | idetape_init_read(drive); | |
68 | @@ -1736,7 +1738,8 @@ static int idetape_space_over_filemarks( | |
69 | ||
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)) | |
75 | ++count; | |
76 | ide_tape_discard_merge_buffer(drive, 0); | |
77 | } | |
78 | @@ -1791,7 +1794,7 @@ static ssize_t idetape_chrdev_read(struc | |
79 | debug_log(DBG_CHRDEV, "Enter %s, count %Zd\n", __func__, count); | |
80 | ||
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; | |
89 | } | |
90 | finish: | |
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); | |
95 | ||
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); | |
100 | if (!retval) | |
101 | - clear_bit(IDE_AFLAG_MEDIUM_PRESENT, &drive->atapi_flags); | |
102 | + clear_bit(ilog2(IDE_AFLAG_MEDIUM_PRESENT), | |
103 | + &drive->atapi_flags); | |
104 | return retval; | |
105 | case MTNOP: | |
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) | |
109 | return -EIO; | |
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); | |
114 | } else | |
115 | - set_bit(IDE_AFLAG_DETECT_BS, &drive->atapi_flags); | |
116 | + set_bit(ilog2(IDE_AFLAG_DETECT_BS), | |
117 | + &drive->atapi_flags); | |
118 | return 0; | |
119 | case MTSEEK: | |
120 | ide_tape_discard_merge_buffer(drive, 0); | |
121 | @@ -2192,20 +2199,20 @@ static int idetape_chrdev_open(struct in | |
122 | ||
123 | filp->private_data = tape; | |
124 | ||
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)) { | |
127 | retval = -EBUSY; | |
128 | goto out_put_tape; | |
129 | } | |
130 | ||
131 | retval = idetape_wait_ready(drive, 60 * HZ); | |
132 | if (retval) { | |
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); | |
136 | goto out_put_tape; | |
137 | } | |
138 | ||
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); | |
143 | ||
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); | |
151 | retval = -EROFS; | |
152 | goto out_put_tape; | |
153 | } | |
154 | @@ -2281,7 +2288,8 @@ static int idetape_chrdev_release(struct | |
155 | ide_tape_discard_merge_buffer(drive, 1); | |
156 | } | |
157 | ||
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 | |
165 | } | |
166 | } | |
167 | } | |
168 | - clear_bit(IDE_AFLAG_BUSY, &drive->atapi_flags); | |
169 | + clear_bit(ilog2(IDE_AFLAG_BUSY), &drive->atapi_flags); | |
170 | ide_tape_put(tape); | |
171 | unlock_kernel(); | |
172 | return 0; | |
173 | @@ -2476,7 +2484,7 @@ static void idetape_setup(ide_drive_t *d | |
174 | ||
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); | |
179 | ||
180 | idetape_get_inquiry_results(drive); | |
181 | idetape_get_mode_sense_results(drive); |