Commit a7c38f2c authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jessica Yu
Browse files

module: remove each_symbol_in_section



each_symbol_in_section just contains a trivial loop over its arguments.
Just open code the loop in the two callers.

Reviewed-by: default avatarMiroslav Benes <mbenes@suse.cz>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJessica Yu <jeyu@kernel.org>
parent 922f2a7c
Loading
Loading
Loading
Loading
+7 −22
Original line number Diff line number Diff line
@@ -428,30 +428,13 @@ extern const s32 __start___kcrctab_unused_gpl[];
#define symversion(base, idx) ((base != NULL) ? ((base) + (idx)) : NULL)
#endif

static bool each_symbol_in_section(const struct symsearch *arr,
				   unsigned int arrsize,
				   struct module *owner,
				   bool (*fn)(const struct symsearch *syms,
					      struct module *owner,
					      void *data),
				   void *data)
{
	unsigned int j;

	for (j = 0; j < arrsize; j++) {
		if (fn(&arr[j], owner, data))
			return true;
	}

	return false;
}

/* Returns true as soon as fn returns true, otherwise false. */
static bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
				    struct module *owner,
				    void *data),
			 void *data)
{
	unsigned int i;
	struct module *mod;
	static const struct symsearch arr[] = {
		{ __start___ksymtab, __stop___ksymtab, __start___kcrctab,
@@ -474,7 +457,8 @@ static bool each_symbol_section(bool (*fn)(const struct symsearch *arr,

	module_assert_mutex_or_preempt();

	if (each_symbol_in_section(arr, ARRAY_SIZE(arr), NULL, fn, data))
	for (i = 0; i < ARRAY_SIZE(arr); i++)
		if (fn(&arr[i], NULL, data))
			return true;

	list_for_each_entry_rcu(mod, &modules, list,
@@ -504,7 +488,8 @@ static bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
		if (mod->state == MODULE_STATE_UNFORMED)
			continue;

		if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
		for (i = 0; i < ARRAY_SIZE(arr); i++)
			if (fn(&arr[i], mod, data))
				return true;
	}
	return false;