aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/esas2r/esas2r_disc.c
diff options
context:
space:
mode:
authorBradley Grove <bgrove@attotech.com>2013-10-01 14:26:01 -0400
committerJames Bottomley <JBottomley@Parallels.com>2013-10-25 04:58:59 -0400
commit9588d24e36003b53f76e43b4fadfc5b35207be04 (patch)
treef07e3a9eff31669e00473fae824cccaad9e65996 /drivers/scsi/esas2r/esas2r_disc.c
parenta1f7177a1bc68cf43ed7f5a50c9a7220b0e1662f (diff)
[SCSI] esas2r: Directly call kernel functions for atomic bit operations
Previously the code embedded the kernel's test_bit/clear_bit functions in wrappers that accepted u32 parameters. The wrapper cast these parameters to longs before passing them to the kernel's bit functions. This did not work properly on platforms with 64-bit longs. Signed-off-by: Bradley Grove <bgrove@attotech.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/esas2r/esas2r_disc.c')
-rw-r--r--drivers/scsi/esas2r/esas2r_disc.c55
1 files changed, 25 insertions, 30 deletions
diff --git a/drivers/scsi/esas2r/esas2r_disc.c b/drivers/scsi/esas2r/esas2r_disc.c
index dec6c334ce3e..1c079f4300a5 100644
--- a/drivers/scsi/esas2r/esas2r_disc.c
+++ b/drivers/scsi/esas2r/esas2r_disc.c
@@ -86,9 +86,9 @@ void esas2r_disc_initialize(struct esas2r_adapter *a)
86 86
87 esas2r_trace_enter(); 87 esas2r_trace_enter();
88 88
89 esas2r_lock_clear_flags(&a->flags, AF_DISC_IN_PROG); 89 clear_bit(AF_DISC_IN_PROG, &a->flags);
90 esas2r_lock_clear_flags(&a->flags2, AF2_DEV_SCAN); 90 clear_bit(AF2_DEV_SCAN, &a->flags2);
91 esas2r_lock_clear_flags(&a->flags2, AF2_DEV_CNT_OK); 91 clear_bit(AF2_DEV_CNT_OK, &a->flags2);
92 92
93 a->disc_start_time = jiffies_to_msecs(jiffies); 93 a->disc_start_time = jiffies_to_msecs(jiffies);
94 a->disc_wait_time = nvr->dev_wait_time * 1000; 94 a->disc_wait_time = nvr->dev_wait_time * 1000;
@@ -107,7 +107,8 @@ void esas2r_disc_initialize(struct esas2r_adapter *a)
107 107
108 a->general_req.interrupt_cx = NULL; 108 a->general_req.interrupt_cx = NULL;
109 109
110 if (a->flags & (AF_CHPRST_DETECTED | AF_POWER_MGT)) { 110 if (test_bit(AF_CHPRST_DETECTED, &a->flags) ||
111 test_bit(AF_POWER_MGT, &a->flags)) {
111 if (a->prev_dev_cnt == 0) { 112 if (a->prev_dev_cnt == 0) {
112 /* Don't bother waiting if there is nothing to wait 113 /* Don't bother waiting if there is nothing to wait
113 * for. 114 * for.
@@ -212,9 +213,7 @@ void esas2r_disc_check_complete(struct esas2r_adapter *a)
212 || a->disc_wait_cnt == 0)) { 213 || a->disc_wait_cnt == 0)) {
213 /* After three seconds of waiting, schedule a scan. */ 214 /* After three seconds of waiting, schedule a scan. */
214 if (time >= 3000 215 if (time >= 3000
215 && !(esas2r_lock_set_flags(&a->flags2, 216 && !test_and_set_bit(AF2_DEV_SCAN, &a->flags2)) {
216 AF2_DEV_SCAN) &
217 ilog2(AF2_DEV_SCAN))) {
218 spin_lock_irqsave(&a->mem_lock, flags); 217 spin_lock_irqsave(&a->mem_lock, flags);
219 esas2r_disc_queue_event(a, DCDE_DEV_SCAN); 218 esas2r_disc_queue_event(a, DCDE_DEV_SCAN);
220 spin_unlock_irqrestore(&a->mem_lock, flags); 219 spin_unlock_irqrestore(&a->mem_lock, flags);
@@ -228,18 +227,14 @@ void esas2r_disc_check_complete(struct esas2r_adapter *a)
228 * We are done waiting...we think. Adjust the wait time to 227 * We are done waiting...we think. Adjust the wait time to
229 * consume events after the count is met. 228 * consume events after the count is met.
230 */ 229 */
231 if (!(esas2r_lock_set_flags(&a->flags2, AF2_DEV_CNT_OK) 230 if (!test_and_set_bit(AF2_DEV_CNT_OK, &a->flags2))
232 & ilog2(AF2_DEV_CNT_OK)))
233 a->disc_wait_time = time + 3000; 231 a->disc_wait_time = time + 3000;
234 232
235 /* If we haven't done a full scan yet, do it now. */ 233 /* If we haven't done a full scan yet, do it now. */
236 if (!(esas2r_lock_set_flags(&a->flags2, 234 if (!test_and_set_bit(AF2_DEV_SCAN, &a->flags2)) {
237 AF2_DEV_SCAN) &
238 ilog2(AF2_DEV_SCAN))) {
239 spin_lock_irqsave(&a->mem_lock, flags); 235 spin_lock_irqsave(&a->mem_lock, flags);
240 esas2r_disc_queue_event(a, DCDE_DEV_SCAN); 236 esas2r_disc_queue_event(a, DCDE_DEV_SCAN);
241 spin_unlock_irqrestore(&a->mem_lock, flags); 237 spin_unlock_irqrestore(&a->mem_lock, flags);
242
243 esas2r_trace_exit(); 238 esas2r_trace_exit();
244 return; 239 return;
245 } 240 }
@@ -253,9 +248,7 @@ void esas2r_disc_check_complete(struct esas2r_adapter *a)
253 return; 248 return;
254 } 249 }
255 } else { 250 } else {
256 if (!(esas2r_lock_set_flags(&a->flags2, 251 if (!test_and_set_bit(AF2_DEV_SCAN, &a->flags2)) {
257 AF2_DEV_SCAN) &
258 ilog2(AF2_DEV_SCAN))) {
259 spin_lock_irqsave(&a->mem_lock, flags); 252 spin_lock_irqsave(&a->mem_lock, flags);
260 esas2r_disc_queue_event(a, DCDE_DEV_SCAN); 253 esas2r_disc_queue_event(a, DCDE_DEV_SCAN);
261 spin_unlock_irqrestore(&a->mem_lock, flags); 254 spin_unlock_irqrestore(&a->mem_lock, flags);
@@ -265,8 +258,8 @@ void esas2r_disc_check_complete(struct esas2r_adapter *a)
265 /* We want to stop waiting for devices. */ 258 /* We want to stop waiting for devices. */
266 a->disc_wait_time = 0; 259 a->disc_wait_time = 0;
267 260
268 if ((a->flags & AF_DISC_POLLED) 261 if (test_bit(AF_DISC_POLLED, &a->flags) &&
269 && (a->flags & AF_DISC_IN_PROG)) { 262 test_bit(AF_DISC_IN_PROG, &a->flags)) {
270 /* 263 /*
271 * Polled discovery is still pending so continue the active 264 * Polled discovery is still pending so continue the active
272 * discovery until it is done. At that point, we will stop 265 * discovery until it is done. At that point, we will stop
@@ -280,14 +273,14 @@ void esas2r_disc_check_complete(struct esas2r_adapter *a)
280 * driven; i.e. There is no transition. 273 * driven; i.e. There is no transition.
281 */ 274 */
282 esas2r_disc_fix_curr_requests(a); 275 esas2r_disc_fix_curr_requests(a);
283 esas2r_lock_clear_flags(&a->flags, AF_DISC_PENDING); 276 clear_bit(AF_DISC_PENDING, &a->flags);
284 277
285 /* 278 /*
286 * We have deferred target state changes until now because we 279 * We have deferred target state changes until now because we
287 * don't want to report any removals (due to the first arrival) 280 * don't want to report any removals (due to the first arrival)
288 * until the device wait time expires. 281 * until the device wait time expires.
289 */ 282 */
290 esas2r_lock_set_flags(&a->flags, AF_PORT_CHANGE); 283 set_bit(AF_PORT_CHANGE, &a->flags);
291 } 284 }
292 285
293 esas2r_trace_exit(); 286 esas2r_trace_exit();
@@ -308,7 +301,8 @@ void esas2r_disc_queue_event(struct esas2r_adapter *a, u8 disc_evt)
308 * Don't start discovery before or during polled discovery. if we did, 301 * Don't start discovery before or during polled discovery. if we did,
309 * we would have a deadlock if we are in the ISR already. 302 * we would have a deadlock if we are in the ISR already.
310 */ 303 */
311 if (!(a->flags & (AF_CHPRST_PENDING | AF_DISC_POLLED))) 304 if (!test_bit(AF_CHPRST_PENDING, &a->flags) &&
305 !test_bit(AF_DISC_POLLED, &a->flags))
312 esas2r_disc_start_port(a); 306 esas2r_disc_start_port(a);
313 307
314 esas2r_trace_exit(); 308 esas2r_trace_exit();
@@ -322,7 +316,7 @@ bool esas2r_disc_start_port(struct esas2r_adapter *a)
322 316
323 esas2r_trace_enter(); 317 esas2r_trace_enter();
324 318
325 if (a->flags & AF_DISC_IN_PROG) { 319 if (test_bit(AF_DISC_IN_PROG, &a->flags)) {
326 esas2r_trace_exit(); 320 esas2r_trace_exit();
327 321
328 return false; 322 return false;
@@ -330,7 +324,7 @@ bool esas2r_disc_start_port(struct esas2r_adapter *a)
330 324
331 /* If there is a discovery waiting, process it. */ 325 /* If there is a discovery waiting, process it. */
332 if (dc->disc_evt) { 326 if (dc->disc_evt) {
333 if ((a->flags & AF_DISC_POLLED) 327 if (test_bit(AF_DISC_POLLED, &a->flags)
334 && a->disc_wait_time == 0) { 328 && a->disc_wait_time == 0) {
335 /* 329 /*
336 * We are doing polled discovery, but we no longer want 330 * We are doing polled discovery, but we no longer want
@@ -347,7 +341,7 @@ bool esas2r_disc_start_port(struct esas2r_adapter *a)
347 341
348 esas2r_hdebug("disc done"); 342 esas2r_hdebug("disc done");
349 343
350 esas2r_lock_set_flags(&a->flags, AF_PORT_CHANGE); 344 set_bit(AF_PORT_CHANGE, &a->flags);
351 345
352 esas2r_trace_exit(); 346 esas2r_trace_exit();
353 347
@@ -356,10 +350,10 @@ bool esas2r_disc_start_port(struct esas2r_adapter *a)
356 350
357 /* Handle the discovery context */ 351 /* Handle the discovery context */
358 esas2r_trace("disc_evt: %d", dc->disc_evt); 352 esas2r_trace("disc_evt: %d", dc->disc_evt);
359 esas2r_lock_set_flags(&a->flags, AF_DISC_IN_PROG); 353 set_bit(AF_DISC_IN_PROG, &a->flags);
360 dc->flags = 0; 354 dc->flags = 0;
361 355
362 if (a->flags & AF_DISC_POLLED) 356 if (test_bit(AF_DISC_POLLED, &a->flags))
363 dc->flags |= DCF_POLLED; 357 dc->flags |= DCF_POLLED;
364 358
365 rq->interrupt_cx = dc; 359 rq->interrupt_cx = dc;
@@ -379,7 +373,7 @@ bool esas2r_disc_start_port(struct esas2r_adapter *a)
379 } 373 }
380 374
381 /* Continue interrupt driven discovery */ 375 /* Continue interrupt driven discovery */
382 if (!(a->flags & AF_DISC_POLLED)) 376 if (!test_bit(AF_DISC_POLLED, &a->flags))
383 ret = esas2r_disc_continue(a, rq); 377 ret = esas2r_disc_continue(a, rq);
384 else 378 else
385 ret = true; 379 ret = true;
@@ -453,10 +447,10 @@ static bool esas2r_disc_continue(struct esas2r_adapter *a,
453 /* Discovery is done...for now. */ 447 /* Discovery is done...for now. */
454 rq->interrupt_cx = NULL; 448 rq->interrupt_cx = NULL;
455 449
456 if (!(a->flags & AF_DISC_PENDING)) 450 if (!test_bit(AF_DISC_PENDING, &a->flags))
457 esas2r_disc_fix_curr_requests(a); 451 esas2r_disc_fix_curr_requests(a);
458 452
459 esas2r_lock_clear_flags(&a->flags, AF_DISC_IN_PROG); 453 clear_bit(AF_DISC_IN_PROG, &a->flags);
460 454
461 /* Start the next discovery. */ 455 /* Start the next discovery. */
462 return esas2r_disc_start_port(a); 456 return esas2r_disc_start_port(a);
@@ -480,7 +474,8 @@ static bool esas2r_disc_start_request(struct esas2r_adapter *a,
480 474
481 spin_lock_irqsave(&a->queue_lock, flags); 475 spin_lock_irqsave(&a->queue_lock, flags);
482 476
483 if (!(a->flags & (AF_CHPRST_PENDING | AF_FLASHING))) 477 if (!test_bit(AF_CHPRST_PENDING, &a->flags) &&
478 !test_bit(AF_FLASHING, &a->flags))
484 esas2r_disc_local_start_request(a, rq); 479 esas2r_disc_local_start_request(a, rq);
485 else 480 else
486 list_add_tail(&rq->req_list, &a->defer_list); 481 list_add_tail(&rq->req_list, &a->defer_list);