Changeset 598 for GPL/trunk/lib32/misc.c
- Timestamp:
- Apr 3, 2017, 4:51:56 PM (8 years ago)
- Location:
- GPL/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk
-
Property svn:mergeinfo
set to
/GPL/branches/uniaud32-2.1.x merged eligible
-
Property svn:mergeinfo
set to
-
GPL/trunk/lib32/misc.c
r530 r598 205 205 } 206 206 //****************************************************************************** 207 static struct notifier_block *reboot_notify_list = NULL;207 //static struct notifier_block *reboot_notify_list = NULL; 208 208 // No need to implement this right now. The ESS Maestro 3 driver uses it 209 209 // to call pci_unregister_driver, which is always called from the shutdown … … 412 412 //****************************************************************************** 413 413 //****************************************************************************** 414 414 #define del_timer_sync(t) del_timer(t) /* FIXME: not quite correct on SMP */ 415 int cancel_delayed_work(struct delayed_work *dwork) 416 { 417 struct work_struct *work = &dwork->work; 418 int ret; 419 420 ret = del_timer_sync(&work->timer); 421 if (ret) 422 clear_bit(0, &work->pending); 423 return ret; 424 } 425 //****************************************************************************** 426 //****************************************************************************** 427 int schedule_work(struct work_struct *works) 428 { 429 #ifndef TARGET_OS2 430 return kernel_thread(work_caller, works, 0) >= 0; 431 #else 432 return 1; 433 #endif 434 } 435 //****************************************************************************** 436 //****************************************************************************** 437 bool flush_delayed_work_sync(struct delayed_work *dwork) 438 { 439 bool ret; 440 ret = cancel_delayed_work(dwork); 441 if (ret) { 442 schedule_delayed_work(dwork, 0); 443 flush_scheduled_work(); 444 } 445 return ret; 446 } 447 //****************************************************************************** 448 //****************************************************************************** 449 static void delayed_work_timer_fn(unsigned long __data) 450 { 451 struct work_struct *work = (struct work_struct *)__data; 452 struct workqueue_struct *wq = work->wq_data; 453 454 if (wq) 455 __x_queue_work(wq, work); 456 else 457 schedule_work(work); 458 } 459 //****************************************************************************** 460 //****************************************************************************** 461 int queue_delayed_work(struct workqueue_struct *wq, struct delayed_work *dwork, unsigned long delay) 462 { 463 struct work_struct *work = &dwork->work; 464 struct timer_list *timer = &work->timer; 465 466 if (!test_and_set_bit(0, &work->pending)) { 467 work->wq_data = wq; 468 timer->expires = jiffies + delay; 469 timer->data = (unsigned long)work; 470 timer->function = delayed_work_timer_fn; 471 add_timer(timer); 472 return 1; 473 } 474 return 0; 475 } 476 //****************************************************************************** 477 //****************************************************************************** 478 /* Greatest common divisor */ 479 unsigned long gcd(unsigned long a, unsigned long b) 480 { 481 unsigned long r; 482 if (a < b) { 483 r = a; 484 a = b; 485 b = r; 486 } 487 while ((r = a % b) != 0) { 488 a = b; 489 b = r; 490 } 491 return b; 492 } 493 494 //****************************************************************************** 495 //****************************************************************************** 496 int strict_strtoul(const char *cp, unsigned int base, unsigned long *res) 497 { 498 char *tail; 499 unsigned long val; 500 size_t len; 501 502 *res = 0; 503 len = strlen(cp); 504 if (len == 0) 505 return -EINVAL; 506 507 val = simple_strtoul(cp, &tail, base); 508 if (tail == cp) 509 return -EINVAL; 510 511 if ((*tail == '\0') || 512 ((len == (size_t)(tail - cp) + 1) && (*tail == '\n'))) { 513 *res = val; 514 return 0; 515 } 516 517 return -EINVAL; 518 }
Note:
See TracChangeset
for help on using the changeset viewer.