summaryrefslogtreecommitdiff
path: root/drivers/staging/hv/osd.c
diff options
context:
space:
mode:
authorBill Pemberton <wfp5p@virginia.edu>2009-07-29 21:00:09 (GMT)
committerGreg Kroah-Hartman <gregkh@suse.de>2009-09-15 19:01:53 (GMT)
commitde65a38406bdf712abc2a845fe1f3db7d1a083ed (patch)
treecd4d9f38dd90c6bfc5a5667bc2c4fcc4481d2f8b /drivers/staging/hv/osd.c
parent949cadaa054588db0c4a3a0cfc3ac93f08fda913 (diff)
downloadlinux-fsl-qoriq-de65a38406bdf712abc2a845fe1f3db7d1a083ed.tar.xz
Staging: hv: rework use of workqueues in osd
Change the usage of workqueues to be consistant with other parts of the kernel. Signed-off-by: Bill Pemberton <wfp5p@virginia.edu> Cc: Hank Janssen <hjanssen@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/hv/osd.c')
-rw-r--r--drivers/staging/hv/osd.c66
1 files changed, 21 insertions, 45 deletions
diff --git a/drivers/staging/hv/osd.c b/drivers/staging/hv/osd.c
index ea3e226..46cdf88 100644
--- a/drivers/staging/hv/osd.c
+++ b/drivers/staging/hv/osd.c
@@ -50,11 +50,11 @@
/* Data types */
-typedef struct _WORKITEM {
+struct osd_callback_struct {
struct work_struct work;
- PFN_WORKITEM_CALLBACK callback;
- void* context;
-} WORKITEM;
+ void (*callback)(void *);
+ void *data;
+};
void BitSet(unsigned int* addr, int bit)
@@ -269,56 +269,32 @@ unsigned long Virtual2Physical(void * VirtAddr)
return pfn << PAGE_SHIFT;
}
-static void WorkItemCallback(struct work_struct *work)
+static void osd_callback_work(struct work_struct *work)
{
- WORKITEM* w = (WORKITEM*)work;
+ struct osd_callback_struct *cb = container_of(work,
+ struct osd_callback_struct,
+ work);
+ (cb->callback)(cb->data);
- w->callback(w->context);
-
- kfree(w);
-}
-
-struct workqueue_struct *WorkQueueCreate(char *name)
-{
- struct workqueue_struct *wq;
- wq = create_workqueue(name);
- if (unlikely(!wq))
- return NULL;
- return wq;
+ kfree(cb);
}
-void WorkQueueClose(struct workqueue_struct *hWorkQueue)
+int osd_schedule_callback(struct workqueue_struct *wq,
+ void (*func)(void *),
+ void *data)
{
- destroy_workqueue(hWorkQueue);
- return;
-}
+ struct osd_callback_struct *cb;
-int WorkQueueQueueWorkItem(struct workqueue_struct *hWorkQueue,
- PFN_WORKITEM_CALLBACK workItem,
- void* context)
-{
- WORKITEM* w = kmalloc(sizeof(WORKITEM), GFP_ATOMIC);
- if (!w)
+ cb = kmalloc(sizeof(*cb), GFP_KERNEL);
+ if (!cb)
{
+ printk(KERN_ERR "unable to allocate memory in osd_schedule_callback");
return -1;
}
- w->callback = workItem,
- w->context = context;
- INIT_WORK(&w->work, WorkItemCallback);
- return queue_work(hWorkQueue, &w->work);
+ cb->callback = func;
+ cb->data = data;
+ INIT_WORK(&cb->work, osd_callback_work);
+ return queue_work(wq, &cb->work);
}
-void QueueWorkItem(PFN_WORKITEM_CALLBACK workItem, void* context)
-{
- WORKITEM* w = kmalloc(sizeof(WORKITEM), GFP_ATOMIC);
- if (!w)
- {
- return;
- }
-
- w->callback = workItem,
- w->context = context;
- INIT_WORK(&w->work, WorkItemCallback);
- schedule_work(&w->work);
-}