[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2c8c3839-f4cf-dc28-3865-99dabdf4b87d@csgroup.eu>
Date: Sat, 17 Dec 2022 10:13:35 +0000
From: Christophe Leroy <christophe.leroy@...roup.eu>
To: Allen Webb <allenwebb@...gle.com>,
"linux-modules@...r.kernel.org" <linux-modules@...r.kernel.org>,
"linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
CC: Luis Chamberlain <mcgrof@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J. Wysocki" <rafael@...nel.org>
Subject: Re: [PATCH v7 4/5] file2alias.c: Implement builtin.alias generation
Le 16/12/2022 à 23:17, Allen Webb a écrit :
> This populates the mod->modalias_buf with aliases for built-in modules
> when modpost is run against vmlinuz.o.
>
> Signed-off-by: Allen Webb <allenwebb@...gle.com>
> ---
> scripts/mod/file2alias.c | 55 +++++++++++++++++++++++++++-------------
> 1 file changed, 38 insertions(+), 17 deletions(-)
>
> diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
> index 458e41ae0f5f1..8ed08154b3d81 100644
> --- a/scripts/mod/file2alias.c
> +++ b/scripts/mod/file2alias.c
> @@ -232,6 +232,8 @@ static void do_usb_entry(void *symval,
> add_wildcard(alias);
> buf_printf(&mod->dev_table_buf,
> "MODULE_ALIAS(\"%s\");\n", alias);
> + if (mod->builtin_name)
> + buf_printf(&mod->modalias_buf, "alias %s %s\n", alias, mod->builtin_name);
> }
>
> /* Handles increment/decrement of BCD formatted integers */
> @@ -376,9 +378,13 @@ static void do_of_entry_multi(void *symval, struct module *mod)
> *tmp = '_';
>
> buf_printf(&mod->dev_table_buf, "MODULE_ALIAS(\"%s\");\n", alias);
> + if (mod->builtin_name)
> + buf_printf(&mod->modalias_buf, "alias %s %s\n", alias, mod->builtin_name);
> strcat(alias, "C");
> add_wildcard(alias);
> buf_printf(&mod->dev_table_buf, "MODULE_ALIAS(\"%s\");\n", alias);
> + if (mod->builtin_name)
> + buf_printf(&mod->modalias_buf, "alias %s %s\n", alias, mod->builtin_name);
> }
>
> static void do_of_table(void *symval, unsigned long size,
> @@ -610,12 +616,18 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
>
> buf_printf(&mod->dev_table_buf,
> "MODULE_ALIAS(\"pnp:d%s*\");\n", *id);
> + if (mod->builtin_name)
> + buf_printf(&mod->modalias_buf, "alias pnp:d%s* %s\n",
> + *id, mod->builtin_name);
>
> /* fix broken pnp bus lowercasing */
> for (j = 0; j < sizeof(acpi_id); j++)
> acpi_id[j] = toupper((*id)[j]);
> buf_printf(&mod->dev_table_buf,
> "MODULE_ALIAS(\"acpi*:%s:*\");\n", acpi_id);
> + if (mod->builtin_name)
> + buf_printf(&mod->modalias_buf, "alias acpi*:%s:* %s\n",
> + acpi_id, mod->builtin_name);
> }
> }
>
> @@ -662,19 +674,25 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
> }
>
> /* add an individual alias for every device entry */
> - if (!dup) {
> - char acpi_id[PNP_ID_LEN];
> - int k;
> -
> - buf_printf(&mod->dev_table_buf,
> - "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
> -
> - /* fix broken pnp bus lowercasing */
> - for (k = 0; k < sizeof(acpi_id); k++)
> - acpi_id[k] = toupper(id[k]);
> - buf_printf(&mod->dev_table_buf,
> - "MODULE_ALIAS(\"acpi*:%s:*\");\n", acpi_id);
> - }
> + if (dup)
> + continue;
> + char acpi_id[PNP_ID_LEN];
> + int k;
No declarations in the middle of a block. Put declarations before code.
> +
> + buf_printf(&mod->dev_table_buf,
> + "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
> + if (mod->builtin_name)
> + buf_printf(&mod->modalias_buf, "alias pnp:d%s* %s\n",
> + id, mod->builtin_name);
> +
> + /* fix broken pnp bus lowercasing */
> + for (k = 0; k < sizeof(acpi_id); k++)
> + acpi_id[k] = toupper(id[k]);
> + buf_printf(&mod->dev_table_buf,
> + "MODULE_ALIAS(\"acpi*:%s:*\");\n", acpi_id);
> + if (mod->builtin_name)
> + buf_printf(&mod->modalias_buf, "alias acpi*:%s:* %s\n",
> + acpi_id, mod->builtin_name);
> }
> }
> }
> @@ -1476,10 +1494,13 @@ static void do_table(void *symval, unsigned long size,
> size -= id_size;
>
> for (i = 0; i < size; i += id_size) {
> - if (do_entry(mod->name, symval+i, alias)) {
> - buf_printf(&mod->dev_table_buf,
> - "MODULE_ALIAS(\"%s\");\n", alias);
> - }
> + if (!do_entry(mod->name, symval + i, alias))
> + continue;
> + buf_printf(&mod->dev_table_buf, "MODULE_ALIAS(\"%s\");\n", alias);
> + if (!mod->builtin_name)
> + continue;
> + buf_printf(&mod->modalias_buf, "alias %s %s\n", alias,
> + mod->builtin_name);
> }
> }
>
Powered by blists - more mailing lists