From: Masahiro Yamada <masahiroy@kernel.org>
To: linux-kbuild@vger.kernel.org
Cc: Masahiro Yamada <masahiroy@kernel.org>,
Daniel Gomez <da.gomez@samsung.com>,
Luis Chamberlain <mcgrof@kernel.org>,
Nathan Chancellor <nathan@kernel.org>,
Nicolas Schier <nicolas@fjasle.eu>,
Petr Pavlu <petr.pavlu@suse.com>,
Sami Tolvanen <samitolvanen@google.com>,
linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org
Subject: [PATCH 14/15] modpost: rename alias symbol for MODULE_DEVICE_TABLE()
Date: Wed, 20 Nov 2024 08:56:52 +0900 [thread overview]
Message-ID: <20241119235705.1576946-14-masahiroy@kernel.org> (raw)
In-Reply-To: <20241119235705.1576946-1-masahiroy@kernel.org>
This commit renames the alias symbol, __mod_<type>__<name>_device_table
to __mod_device_table__<type>__<name>.
This change simplifies the code slightly, as there is no longer a need
to check both the prefix and suffix.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
include/linux/module.h | 2 +-
scripts/mod/file2alias.c | 17 +++++++----------
2 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/include/linux/module.h b/include/linux/module.h
index 88ecc5e9f523..3dd79a3d0cbf 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -247,7 +247,7 @@ extern void cleanup_module(void);
#ifdef MODULE
/* Creates an alias so file2alias.c can find device table. */
#define MODULE_DEVICE_TABLE(type, name) \
-extern typeof(name) __mod_##type##__##name##_device_table \
+extern typeof(name) __mod_device_table__##type##__##name \
__attribute__ ((unused, alias(__stringify(name))))
#else /* !MODULE */
#define MODULE_DEVICE_TABLE(type, name)
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index 2374737b9d22..b1291cc7bd80 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -121,7 +121,7 @@ typedef struct {
#include "../../include/linux/mod_devicetable.h"
struct devtable {
- const char *device_id; /* name of table, __mod_<name>__*_device_table. */
+ const char *device_id;
unsigned long id_size;
void (*do_entry)(struct module *mod, void *symval);
};
@@ -188,7 +188,7 @@ static void device_id_check(const char *modname, const char *device_id,
int i;
if (size % id_size || size < id_size) {
- fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo of the size of section __mod_%s__<identifier>_device_table=%lu.\n"
+ fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo of the size of section __mod_device_table__%s__<identifier>=%lu.\n"
"Fix definition of struct %s_device_id in mod_devicetable.h\n",
modname, device_id, id_size, device_id, size, device_id);
}
@@ -1503,6 +1503,7 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
char *zeros = NULL;
const char *type, *name;
size_t typelen;
+ static const char *prefix = "__mod_device_table__";
/* We're looking for a section relative symbol */
if (!sym->st_shndx || get_secindex(info, sym) >= info->num_sections)
@@ -1512,15 +1513,11 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
if (ELF_ST_TYPE(sym->st_info) != STT_OBJECT)
return;
- /* All our symbols are of form __mod_<type>__<name>_device_table. */
- if (!strstarts(symname, "__mod_"))
- return;
- type = symname + strlen("__mod_");
- typelen = strlen(type);
- if (typelen < strlen("_device_table"))
- return;
- if (strcmp(type + typelen - strlen("_device_table"), "_device_table"))
+ /* All our symbols are of form __mod_device_table__<type>__<name>. */
+ if (!strstarts(symname, prefix))
return;
+ type = symname + strlen(prefix);
+
name = strstr(type, "__");
if (!name)
return;
--
2.43.0
next prev parent reply other threads:[~2024-11-19 23:57 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-19 23:56 [PATCH 01/15] modpost: remove incorrect code in do_eisa_entry() Masahiro Yamada
2024-11-19 23:56 ` [PATCH 02/15] modpost: remove unnecessary check in do_acpi_entry() Masahiro Yamada
2024-11-19 23:56 ` [PATCH 03/15] modpost: introduce module_alias_printf() helper Masahiro Yamada
2024-11-20 2:37 ` Masahiro Yamada
2024-11-19 23:56 ` [PATCH 04/15] modpost: deduplicate MODULE_ALIAS() for all drivers Masahiro Yamada
2024-11-19 23:56 ` [PATCH 05/15] modpost: remove DEF_FIELD_ADDR_VAR() macro Masahiro Yamada
2024-11-19 23:56 ` [PATCH 06/15] modpost: pass (struct module *) to do_*_entry() functions Masahiro Yamada
2024-11-19 23:56 ` [PATCH 07/15] modpost: call module_alias_printf() from all " Masahiro Yamada
2024-11-19 23:56 ` [PATCH 08/15] modpost: convert do_pnp_card_entries() to a generic handler Masahiro Yamada
2024-11-19 23:56 ` [PATCH 09/15] modpost: convert do_pnp_device_entry() " Masahiro Yamada
2024-11-19 23:56 ` [PATCH 10/15] modpost: convert do_of_table() " Masahiro Yamada
2024-11-19 23:56 ` [PATCH 11/15] modpost: convert do_usb_table() " Masahiro Yamada
2024-11-19 23:56 ` [PATCH 12/15] modpost: move strstarts() to modpost.h Masahiro Yamada
2024-11-19 23:56 ` [PATCH 13/15] modpost: rename variables in handle_moddevtable() Masahiro Yamada
2024-11-19 23:56 ` Masahiro Yamada [this message]
2024-11-19 23:56 ` [PATCH 15/15] modpost: improve error messages in device_id_check() Masahiro Yamada
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241119235705.1576946-14-masahiroy@kernel.org \
--to=masahiroy@kernel.org \
--cc=da.gomez@samsung.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=nathan@kernel.org \
--cc=nicolas@fjasle.eu \
--cc=petr.pavlu@suse.com \
--cc=samitolvanen@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®