From patchwork Fri Dec 16 22:17:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allen Webb X-Patchwork-Id: 634948 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 168E0C4332F for ; Fri, 16 Dec 2022 22:17:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229939AbiLPWRk (ORCPT ); Fri, 16 Dec 2022 17:17:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229962AbiLPWR0 (ORCPT ); Fri, 16 Dec 2022 17:17:26 -0500 Received: from mail-il1-x149.google.com (mail-il1-x149.google.com [IPv6:2607:f8b0:4864:20::149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3973427CF5 for ; Fri, 16 Dec 2022 14:17:25 -0800 (PST) Received: by mail-il1-x149.google.com with SMTP id j11-20020a056e02218b00b00304b148969dso2464937ila.13 for ; Fri, 16 Dec 2022 14:17:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=XLvu9YuJyEq4PpXLboWGHlPW5BtXq8Iaz4s/vCpOC+c=; b=e3ljpji6ioK1JmswqGeMT59i8kwd6MfvqxyKihoCalO46QZMcp+qNJ22Sa/dWGHS61 hQt7Dcyt5iYvhfhIxS1m6bBXl92EiA703yaQJ6fsCkkgwyVN8osyFtrUyR75cY1ZUBA9 krWROrvfwpL/5grEcfPSXdqmcM6dLMUIEz9IZngi0SPq+C6F/bm6m4UDENUlS2E+UW89 HiSgi2UX07+CfWBK1m25AL8+Q+DKbt6diCGA6Yp0haO7lrWhf5tptnK3ipFVWLh448Gr ED8NdLMYqYqRdSeDeVmHP83G0e6eHTb+aniw1W2rC2ClRLHS3O47uYwiwaLCj8BxeZq1 s4gQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=XLvu9YuJyEq4PpXLboWGHlPW5BtXq8Iaz4s/vCpOC+c=; b=KUc7yZrvvcczQwqs/2x6JJaJTQ4pyhB2y2AjU3XpZp0xDibWsv3H0Ogyi3ebIRq2yK Z0Tqp5kix8g14p6BWVV3TBbVLpuHm/cNmlkPwtjmaX7TTuRtRIUPKsxDd2m4HUiiw9l0 ULAMJJDfJ5x/GleD2yENPR4E9fvGAQruC/XRga6nWzII3sw7Bgm2ynlSDym+LwZB6PZQ dY2uDsEW6QEcdB6QrWhHwVAg3zHDHBKfPSgTPJD8iZgBoepU9V3LcolC6wsvPPcTbKVr Y1PrX9AyS49zHSNRzk/ZR6ayx9E9PJ17Opym1/4GLby4qm5WhVZpkXi5FgHZRpWGXpA3 98XQ== X-Gm-Message-State: ANoB5pmqTWurrfVHKbE/XH5TIka/xbgj8SsK+IMX9/37QDBJQ49Raeei yaRZkv2veU0cuca2Ox3YxU7HBENUqzJLbHg= X-Google-Smtp-Source: AA0mqf4gCzt7wLDqWtd7vb4p1P/T/LZD/uBz6gdqr23QFQNqjiefKT1o/c05gLYraaBcQacntRWFHfpND37EPes= X-Received: from allenwebb.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:12e8]) (user=allenwebb job=sendgmr) by 2002:a5e:8c10:0:b0:6e3:102d:4826 with SMTP id n16-20020a5e8c10000000b006e3102d4826mr1519940ioj.123.1671229044644; Fri, 16 Dec 2022 14:17:24 -0800 (PST) Date: Fri, 16 Dec 2022 16:17:02 -0600 In-Reply-To: <20221216221703.294683-1-allenwebb@google.com> Mime-Version: 1.0 References: <20221216221703.294683-1-allenwebb@google.com> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Message-ID: <20221216221703.294683-5-allenwebb@google.com> Subject: [PATCH v7 4/5] file2alias.c: Implement builtin.alias generation From: Allen Webb To: "linux-modules@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Cc: Luis Chamberlain , Greg Kroah-Hartman , "Rafael J. Wysocki" , Allen Webb Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org This populates the mod->modalias_buf with aliases for built-in modules when modpost is run against vmlinuz.o. Signed-off-by: Allen Webb --- 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; + + 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); } }