Re: try_then_request_module

Ingo Oeser (ingo.oeser@informatik.tu-chemnitz.de)
Mon, 19 May 2003 11:08:32 +0200


Hi Rusty,
hi LKML,

On Mon, May 19, 2003 at 11:41:20AM +1000, Rusty Russell wrote:
> If someone is feeling eager, many callers could change to
> try_then_request_module(), eg:

[search || request_module]

Many implementation do this with a search and retry the search
(if clever with a goto and a flag variable to save kernel size)
after module loading.

All that implemented in the search routine, which you have to
supply anyway.

So try_then_request_module() will consolidate the the
branch or in the worst case just duplicating that code
everywhere (depends on wether you implement it as a non-inline
function or define).

Usally this is all as simple as:

int module_loaded_flag=0;
retry_with_module_loaded:

/* search code */

if (!module_loaded_flag && !found) {
module_loaded_flag=1;
if (!request_module(bla))
goto retry_with_module_loaded;
}
return found;

which is very space effecient and also still readable.

Regards

Ingo Oeser
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/