Messages in this thread | | | Date | Sat, 18 Feb 2006 13:03:44 +0300 | From | Sergey Vlasov <> | Subject | Re: [linux-usb-devel] Re: Linux 2.6.16-rc3 |
| |
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). [unhandled content-type:application/pgp-signature] | |