From patchwork Mon Dec 19 19:18:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allen Webb X-Patchwork-Id: 635401 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 56874C4332F for ; Mon, 19 Dec 2022 19:19:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232701AbiLSTT0 (ORCPT ); Mon, 19 Dec 2022 14:19:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232410AbiLSTTJ (ORCPT ); Mon, 19 Dec 2022 14:19:09 -0500 Received: from mail-io1-xd49.google.com (mail-io1-xd49.google.com [IPv6:2607:f8b0:4864:20::d49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 277DD120B6 for ; Mon, 19 Dec 2022 11:19:08 -0800 (PST) Received: by mail-io1-xd49.google.com with SMTP id n23-20020a056602341700b00689fc6dbfd6so4454125ioz.8 for ; Mon, 19 Dec 2022 11:19:08 -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=cjGe6fxSS7cTt3mra7vAbJD0wH3tbfNYD/FCvl4NRMk=; b=FwO+EN0GRH6yMNy3i+aRaQi4k6ltrzQBDq0j2HgKcM4M/i0+GG/Tmh4ilo2ihykEDy Z3DOBVb7Hmq/tEN1Fv7roWQ+ePXHhHxxxbUSha5Tue3vGD0YSCIw5CdxZJ10vUa7j4sz /DDGenrw2NvJi/Pse/FoKztr5v6NXg/S7iy9zlEKswHs50EeHpMw/wCmWIvNVAAl/sJQ nVcs8jSLbqOYsGA7sZaPExqgzl0/OLlwn7nJM5YDweKk2lSBKB2VNh6AdN/9jDCPPRDt k8HINHwwMp2JVSAhC7XTE1zZqkTsd+OcFG5w7tdcU20hhKaWWMZrWhIcKMp2nvsSChQ9 4WzA== 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=cjGe6fxSS7cTt3mra7vAbJD0wH3tbfNYD/FCvl4NRMk=; b=raKgnVvyLJ3kBl1zl9+nEuuCKZLMxSft2tN0W/Bkpz757pMfDajmuyaFzrdFQX1O2l ffzGNV9XKJmB9DRELLLxekTph22qWmek9YA6h1PeiyEK5f6k7Bd3MweAoiZv+kYi/m9b 5xGXakfBiZJ8su/RYHiEWgjHAfXW8RxEpsIEd9+yNbb/8sdkDCgNJeZHfCn/7uPcDhq8 eyj8IkaqA26WYRVo2RHbb8CmddtSXfSG9NovBQpScvIAtiNxzuy+akATryien6kis0T4 Y+HWbsEL23fTeCMFOf5YhY5gHYqGeTjZ8HJeavMyP8YlNqCtsF0Z9wNrhkcuvP5boadj qodw== X-Gm-Message-State: AFqh2kpiBlsDdXpVuTBGhMeLzKp9ma+vsZjAu5sFeoYIb63RgsY529Oy DQB3jq9I0ftbR6wEftfLb6fTeEY1kde9vms= X-Google-Smtp-Source: AMrXdXtEWFR5m+TguTy7DMteh2YUscW21cjm7GoJQqd4O805GlSojiqfl7ZGAJOibTR3VFOZRn9mfAPK7+rMVYU= X-Received: from allenwebb.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:12e8]) (user=allenwebb job=sendgmr) by 2002:a05:6e02:2207:b0:30b:c336:8a83 with SMTP id j7-20020a056e02220700b0030bc3368a83mr61889ilf.92.1671477547452; Mon, 19 Dec 2022 11:19:07 -0800 (PST) Date: Mon, 19 Dec 2022 13:18:54 -0600 In-Reply-To: <20221219191855.2010466-1-allenwebb@google.com> Mime-Version: 1.0 References: <20221216221703.294683-1-allenwebb@google.com> <20221219191855.2010466-1-allenwebb@google.com> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Message-ID: <20221219191855.2010466-9-allenwebb@google.com> Subject: [PATCH v8 8/9] 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 e41ff8de7a876..e840cb51281a4 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); } } @@ -637,6 +649,8 @@ static void do_pnp_card_entries(void *symval, unsigned long size, const char *id = (char *)(*devs)[j].id; int i2, j2; int dup = 0; + char acpi_id[PNP_ID_LEN]; + int k; if (!id[0]) break; @@ -662,19 +676,23 @@ 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; + + 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); } }