Rev 3480 | Rev 4104 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3480 | Rev 3482 | ||
---|---|---|---|
Line 834... | Line 834... | ||
834 | } |
834 | } |
835 | 835 | ||
Line 836... | Line -... | ||
836 | - | ||
837 | - | ||
838 | void __stdcall run_workqueue(struct workqueue_struct *cwq) |
- | |
839 | { |
- | |
840 | unsigned long irqflags; |
- | |
841 | - | ||
842 | // dbgprintf("wq: %x head %x, next %x\n", |
- | |
843 | // cwq, &cwq->worklist, cwq->worklist.next); |
- | |
844 | - | ||
845 | spin_lock_irqsave(&cwq->lock, irqflags); |
- | |
846 | - | ||
847 | while (!list_empty(&cwq->worklist)) |
- | |
848 | { |
- | |
849 | struct work_struct *work = list_entry(cwq->worklist.next, |
- | |
850 | struct work_struct, entry); |
- | |
851 | work_func_t f = work->func; |
- | |
852 | list_del_init(cwq->worklist.next); |
- | |
853 | // dbgprintf("head %x, next %x\n", |
- | |
854 | // &cwq->worklist, cwq->worklist.next); |
- | |
855 | - | ||
856 | spin_unlock_irqrestore(&cwq->lock, irqflags); |
- | |
857 | f(work); |
- | |
858 | spin_lock_irqsave(&cwq->lock, irqflags); |
- | |
859 | } |
- | |
860 | - | ||
861 | spin_unlock_irqrestore(&cwq->lock, irqflags); |
- | |
862 | } |
- | |
863 | - | ||
864 | - | ||
865 | static inline |
- | |
866 | int __queue_work(struct workqueue_struct *wq, |
- | |
867 | struct work_struct *work) |
- | |
868 | { |
- | |
869 | unsigned long flags; |
- | |
870 | - | ||
871 | // dbgprintf("wq: %x, work: %x\n", |
- | |
872 | // wq, work ); |
- | |
873 | - | ||
874 | if(!list_empty(&work->entry)) |
- | |
875 | return 0; |
- | |
876 | - | ||
877 | spin_lock_irqsave(&wq->lock, flags); |
- | |
878 | - | ||
Line 879... | Line -... | ||
879 | if(list_empty(&wq->worklist)) |
- | |
Line 880... | Line -... | ||
880 | TimerHs(0,0, run_workqueue, wq); |
- | |
881 | - | ||
882 | list_add_tail(&work->entry, &wq->worklist); |
- | |
Line 883... | Line -... | ||
883 | - | ||
884 | spin_unlock_irqrestore(&wq->lock, flags); |
- | |
885 | // dbgprintf("wq: %x head %x, next %x\n", |
- | |
886 | // wq, &wq->worklist, wq->worklist.next); |
- | |
887 | - | ||
888 | return 1; |
- | |
889 | }; |
- | |
Line 890... | Line -... | ||
890 | - | ||
891 | bool queue_work(struct workqueue_struct *wq, struct work_struct *work) |
- | |
892 | { |
- | |
893 | return __queue_work(wq, work); |
- | |
Line 894... | Line -... | ||
894 | } |
- | |
895 | - | ||
Line 896... | Line -... | ||
896 | - | ||
897 | void __stdcall delayed_work_timer_fn(unsigned long __data) |
- | |
Line 898... | Line -... | ||
898 | { |
- | |
899 | struct delayed_work *dwork = (struct delayed_work *)__data; |
- | |
900 | struct workqueue_struct *wq = dwork->work.data; |
- | |
901 | - | ||
902 | // dbgprintf("wq: %x, work: %x\n", |
- | |
903 | // wq, &dwork->work ); |
- | |
904 | - | ||
905 | __queue_work(wq, &dwork->work); |
- | |
906 | } |
- | |
907 | - | ||
908 | - | ||
909 | int queue_delayed_work_on(struct workqueue_struct *wq, |
- | |
910 | struct delayed_work *dwork, unsigned long delay) |
- | |
911 | { |
- | |
912 | struct work_struct *work = &dwork->work; |
- | |
913 | - | ||
914 | work->data = wq; |
- | |
915 | TimerHs(0,0, delayed_work_timer_fn, dwork); |
- | |
916 | return 1; |
- | |
917 | } |
- | |
918 | - | ||
919 | int queue_delayed_work(struct workqueue_struct *wq, |
- | |
920 | struct delayed_work *dwork, unsigned long delay) |
- | |
921 | { |
- | |
922 | u32 flags; |
- | |
923 | - | ||
924 | // dbgprintf("wq: %x, work: %x\n", |
- | |
925 | // wq, &dwork->work ); |
- | |
926 | - | ||
927 | if (delay == 0) |
- | |
928 | return __queue_work(wq, &dwork->work); |
- | |
929 | - | ||
930 | return queue_delayed_work_on(wq, dwork, delay); |
- | |
931 | } |
- | |
932 | - | ||
933 | - | ||
934 | struct workqueue_struct *alloc_workqueue(const char *fmt, |
- | |
935 | unsigned int flags, |
- | |
936 | int max_active) |
- | |
937 | { |
- | |
938 | struct workqueue_struct *wq; |
- | |
939 | - | ||
940 | wq = kzalloc(sizeof(*wq),0); |
836 | |
Line 941... | Line 837... | ||
941 | if (!wq) |
837 | |
942 | goto err; |
838 | |
943 | 839 | ||
Line 1026... | Line 922... | ||
1026 | list_del_init(&wait->task_list); |
922 | list_del_init(&wait->task_list); |
1027 | return 1; |
923 | return 1; |
1028 | }>24); |
924 | } |
1029 | 925 | ||
Line -... | Line 926... | ||
- | 926 | unsigned int hweight16(unsigned int w) |
|
- | 927 | { |
|
- | 928 | unsigned int res = w - ((w >> 1) & 0x5555); |
|
- | 929 | res = (res & 0x3333) + ((res >> 2) & 0x3333); |
|
- | 930 | res = (res + (res >> 4)) & 0x0F0F; |
|
- | 931 | return (res + (res >> 8)) & 0x00FF; |
|
- | 932 | } |
|
Line -... | Line 933... | ||
- | 933 | ||
- | 934 | ||
- | 935 | unsigned long round_jiffies_up_relative(unsigned long j) |
|
- | 936 | { |
|
- | 937 | unsigned long j0 = GetTimerTicks(); |
|
- | 938 | ||
- | 939 | /* Use j0 because jiffies might change while we run */ |