lkml.org 
[lkml]   [2006]   [Feb]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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]
\
 
 \ /
  Last update: 2006-02-18 11:06    [W:0.655 / U:0.288 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site