On Fri, Feb 17, 2006 at 04:42:43PM -0800, James Bottomley wrote: > +static void execute_in_process_context_work(void *data) > +{ > + void (*fn)(void *data); > + struct execute_work *ew = data; > + > + fn = ew->fn; > + data = ew->data; > + > + fn(data); > +} After removing kfree(), which was here in the initial implementation, this function became a thunk which does nothing useful - we can just stick fn and data directly into work_struct. > + > +/** > + * execute_in_process_context - reliably execute the routine with user context > + * @fn: the function to execute > + * @data: data to pass to the function > + * > + * Executes the function immediately if process context is available, > + * otherwise schedules the function for delayed execution. > + * > + * Returns: 0 - function was executed > + * 1 - function was scheduled for execution > + */ > +int execute_in_process_context(void (*fn)(void *data), void *data, > + struct execute_work *ew) > +{ > + if (!in_interrupt()) { > + fn(data); > + return 0; > + } > + > + INIT_WORK(&ew->work, execute_in_process_context_work, ew); > + ew->fn = fn; > + ew->data = data; > + schedule_work(&ew->work); > + > + return 1; > +} Then this becomes: int execute_in_process_context(void (*fn)(void *data), void *data, struct work_struct *work) { if (!in_interrupt()) { fn(data); return 0; } INIT_WORK(work, fn, data); schedule_work(work); return 1; } (and struct execute_work is no longer needed).
Attachment:
pgpRdCDUrKUFM.pgp
Description: PGP signature
- Follow-Ups:
- Re: [linux-usb-devel] Re: Linux 2.6.16-rc3
- From: James Bottomley <[email protected]>
- Re: [linux-usb-devel] Re: Linux 2.6.16-rc3
- References:
- Re: Linux 2.6.16-rc3
- From: James Bottomley <[email protected]>
- Re: Linux 2.6.16-rc3
- From: James Bottomley <[email protected]>
- Re: Linux 2.6.16-rc3
- From: Russell King <[email protected]>
- Re: Linux 2.6.16-rc3
- From: James Bottomley <[email protected]>
- Re: Linux 2.6.16-rc3
- From: Russell King <[email protected]>
- Re: Linux 2.6.16-rc3
- From: James Bottomley <[email protected]>
- Re: Linux 2.6.16-rc3
- From: Russell King <[email protected]>
- Re: Linux 2.6.16-rc3
- From: James Bottomley <[email protected]>
- Re: Linux 2.6.16-rc3
- From: Jens Axboe <[email protected]>
- Re: Linux 2.6.16-rc3
- From: James Bottomley <[email protected]>
- Re: Linux 2.6.16-rc3
- Prev by Date: Re: [PATCH 2/2] fix file counting
- Next by Date: Re: [PATCH 2/2] fix file counting
- Previous by thread: Re: Linux 2.6.16-rc3
- Next by thread: Re: [linux-usb-devel] Re: Linux 2.6.16-rc3
- Index(es):