From: David Howells <dhowells@redhat.com>
To: torvalds@osdl.org, akpm@osdl.org
Cc: dhowells@redhat.com, linux-kernel@vger.kernel.org
Subject: [PATCH 2/5] WorkStruct: Typedef the work function prototype [try #2]
Date: Wed, 22 Nov 2006 13:02:27 +0000 [thread overview]
Message-ID: <20061122130227.24778.13919.stgit@warthog.cambridge.redhat.com> (raw)
In-Reply-To: <20061122130222.24778.62947.stgit@warthog.cambridge.redhat.com>
Define a type for the work function prototype. It's not only kept in the
work_struct struct, it's also passed as an argument to several functions.
This makes it easier to change it.
Signed-Off-By: David Howells <dhowells@redhat.com>
---
drivers/block/floppy.c | 4 ++--
include/linux/workqueue.h | 9 +++++----
kernel/workqueue.c | 6 +++---
3 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 9e6d3a8..5a14fac 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -996,7 +996,7 @@ static DECLARE_WORK(floppy_work, NULL, N
static void schedule_bh(void (*handler) (void))
{
- PREPARE_WORK(&floppy_work, (void (*)(void *))handler, NULL);
+ PREPARE_WORK(&floppy_work, (work_func_t)handler, NULL);
schedule_work(&floppy_work);
}
@@ -1008,7 +1008,7 @@ static void cancel_activity(void)
spin_lock_irqsave(&floppy_lock, flags);
do_floppy = NULL;
- PREPARE_WORK(&floppy_work, (void *)empty, NULL);
+ PREPARE_WORK(&floppy_work, (work_func_t)empty, NULL);
del_timer(&fd_timer);
spin_unlock_irqrestore(&floppy_lock, flags);
}
diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
index 9faacca..cef40b2 100644
--- a/include/linux/workqueue.h
+++ b/include/linux/workqueue.h
@@ -11,10 +11,12 @@ #include <linux/bitops.h>
struct workqueue_struct;
+typedef void (*work_func_t)(void *data);
+
struct work_struct {
unsigned long pending;
struct list_head entry;
- void (*func)(void *);
+ work_func_t func;
void *data;
void *wq_data;
};
@@ -91,7 +93,7 @@ extern int FASTCALL(schedule_work(struct
extern int FASTCALL(schedule_delayed_work(struct delayed_work *work, unsigned long delay));
extern int schedule_delayed_work_on(int cpu, struct delayed_work *work, unsigned long delay);
-extern int schedule_on_each_cpu(void (*func)(void *info), void *info);
+extern int schedule_on_each_cpu(work_func_t func, void *info);
extern void flush_scheduled_work(void);
extern int current_is_keventd(void);
extern int keventd_up(void);
@@ -100,8 +102,7 @@ extern void init_workqueues(void);
void cancel_rearming_delayed_work(struct delayed_work *work);
void cancel_rearming_delayed_workqueue(struct workqueue_struct *,
struct delayed_work *);
-int execute_in_process_context(void (*fn)(void *), void *,
- struct execute_work *);
+int execute_in_process_context(work_func_t fn, void *, struct execute_work *);
/*
* Kill off a pending schedule_delayed_work(). Note that the work callback
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 44fc54b..1e9d61e 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -217,7 +217,7 @@ static void run_workqueue(struct cpu_wor
while (!list_empty(&cwq->worklist)) {
struct work_struct *work = list_entry(cwq->worklist.next,
struct work_struct, entry);
- void (*f) (void *) = work->func;
+ work_func_t f = work->func;
void *data = work->data;
list_del_init(cwq->worklist.next);
@@ -513,7 +513,7 @@ EXPORT_SYMBOL(schedule_delayed_work_on);
*
* schedule_on_each_cpu() is very slow.
*/
-int schedule_on_each_cpu(void (*func)(void *info), void *info)
+int schedule_on_each_cpu(work_func_t func, void *info)
{
int cpu;
struct work_struct *works;
@@ -578,7 +578,7 @@ EXPORT_SYMBOL(cancel_rearming_delayed_wo
* Returns: 0 - function was executed
* 1 - function was scheduled for execution
*/
-int execute_in_process_context(void (*fn)(void *data), void *data,
+int execute_in_process_context(work_func_t fn, void *data,
struct execute_work *ew)
{
if (!in_interrupt()) {
next prev parent reply other threads:[~2006-11-22 13:05 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-22 13:02 [PATCH 0/5] WorkStruct: Shrink work_struct by two thirds David Howells
2006-11-22 13:02 ` [PATCH 1/5] WorkStruct: Separate delayable and non-delayable events. [try #2] David Howells
2006-11-22 13:02 ` David Howells [this message]
2006-11-22 13:02 ` [PATCH 3/5] WorkStruct: Merge the pending bit into the wq_data pointer " David Howells
2006-11-22 16:32 ` Randy Dunlap
2006-11-22 13:02 ` [PATCH 4/5] WorkStruct: Pass the work_struct pointer instead of context data " David Howells
2006-11-22 15:02 ` [PATCH 0/5] WorkStruct: Shrink work_struct by two thirds David Howells
2006-11-22 21:20 ` Andrew Morton
2006-11-23 11:44 ` David Howells
2006-11-23 17:25 ` Linus Torvalds
2006-11-23 20:01 ` David Howells
2006-11-23 21:04 ` David Howells
2006-11-23 21:40 ` Andrew Morton
2006-11-23 14:59 ` David Howells
2006-11-23 16:01 ` Stefan Richter
2006-12-05 19:52 ` GIT pull on work_struct reduction tree David Howells
2006-12-05 20:16 ` Andrew Morton
2006-12-05 21:05 ` Stefan Richter
2006-12-05 21:41 ` David Howells
2006-12-06 15:06 ` David Howells
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20061122130227.24778.13919.stgit@warthog.cambridge.redhat.com \
--to=dhowells@redhat.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®