public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: linux-kbuild@vger.kernel.org
Cc: Masahiro Yamada <masahiroy@kernel.org>,
	Nathan Chancellor <nathan@kernel.org>,
	Nicolas Schier <nicolas@fjasle.eu>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 08/15] modpost: convert do_pnp_card_entries() to a generic handler
Date: Wed, 20 Nov 2024 08:56:46 +0900	[thread overview]
Message-ID: <20241119235705.1576946-8-masahiroy@kernel.org> (raw)
In-Reply-To: <20241119235705.1576946-1-masahiroy@kernel.org>

do_pnp_card_entries() no longer needs to iterate over the
pnp_card_device_id array.

Convert it to a generic ->do_entry() handler.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/mod/file2alias.c | 39 ++++++++++++++-------------------------
 1 file changed, 14 insertions(+), 25 deletions(-)

diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index 10da84599c1a..eabf702ef1a2 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -649,34 +649,24 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
 }
 
 /* looks like: "pnp:dD" for every device of the card */
-static void do_pnp_card_entries(void *symval, unsigned long size,
-				struct module *mod)
+static void do_pnp_card_entry(struct module *mod, void *symval)
 {
-	const unsigned long id_size = SIZE_pnp_card_device_id;
-	const unsigned int count = (size / id_size)-1;
-	unsigned int i;
+	DEF_FIELD_ADDR(symval, pnp_card_device_id, devs);
 
-	device_id_check(mod->name, "pnp", size, id_size, symval);
+	for (unsigned int i = 0; i < PNP_MAX_DEVICES; i++) {
+		const char *id = (char *)(*devs)[i].id;
+		char acpi_id[PNP_ID_LEN];
 
-	for (i = 0; i < count; i++) {
-		unsigned int j;
-		DEF_FIELD_ADDR(symval + i * id_size, pnp_card_device_id, devs);
+		if (!id[0])
+			break;
 
-		for (j = 0; j < PNP_MAX_DEVICES; j++) {
-			const char *id = (char *)(*devs)[j].id;
-			char acpi_id[PNP_ID_LEN];
+		/* fix broken pnp bus lowercasing */
+		for (unsigned int j = 0; j < sizeof(acpi_id); j++)
+			acpi_id[j] = toupper(id[j]);
 
-			if (!id[0])
-				break;
-
-			/* add an individual alias for every device entry */
-			module_alias_printf(mod, false, "pnp:d%s*", id);
-
-			/* fix broken pnp bus lowercasing */
-			for (int k = 0; k < sizeof(acpi_id); k++)
-				acpi_id[k] = toupper(id[k]);
-			module_alias_printf(mod, false, "acpi*:%s:*", acpi_id);
-		}
+		/* add an individual alias for every device entry */
+		module_alias_printf(mod, false, "pnp:d%s*", id);
+		module_alias_printf(mod, false, "acpi*:%s:*", acpi_id);
 	}
 }
 
@@ -1539,6 +1529,7 @@ static const struct devtable devtable[] = {
 	{"cdx", SIZE_cdx_device_id, do_cdx_entry},
 	{"vchiq", SIZE_vchiq_device_id, do_vchiq_entry},
 	{"coreboot", SIZE_coreboot_device_id, do_coreboot_entry},
+	{"pnp_card", SIZE_pnp_card_device_id, do_pnp_card_entry},
 };
 
 /* Create MODULE_ALIAS() statements.
@@ -1589,8 +1580,6 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
 		do_of_table(symval, sym->st_size, mod);
 	else if (sym_is(name, namelen, "pnp"))
 		do_pnp_device_entry(symval, sym->st_size, mod);
-	else if (sym_is(name, namelen, "pnp_card"))
-		do_pnp_card_entries(symval, sym->st_size, mod);
 	else {
 		int i;
 
-- 
2.43.0


  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 ` Masahiro Yamada [this message]
2024-11-19 23:56 ` [PATCH 09/15] modpost: convert do_pnp_device_entry() to a generic handler 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 ` [PATCH 14/15] modpost: rename alias symbol for MODULE_DEVICE_TABLE() Masahiro Yamada
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-8-masahiroy@kernel.org \
    --to=masahiroy@kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nathan@kernel.org \
    --cc=nicolas@fjasle.eu \
    /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