Message ID | 20221216221703.294683-5-allenwebb@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp1227316wrn; Fri, 16 Dec 2022 14:20:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf7kGYni/rsoh91jZ1dPjzqMCXKCoqXV11qRpV6IThozrJQGlp7f1+GRrzjIzm5E2Y24GNfK X-Received: by 2002:aa7:d604:0:b0:470:4d71:6d43 with SMTP id c4-20020aa7d604000000b004704d716d43mr14009566edr.25.1671229242472; Fri, 16 Dec 2022 14:20:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671229242; cv=none; d=google.com; s=arc-20160816; b=JGJEkHg9pEOnhuDee7tNc53cWdMpDycOq7bKN5gU/KgaULQ2/nCcxuZSyJ/hSIdBy2 7hlboz30u+48lP+yj90940igNVmilhi7abp8U+YmSq3i4FDdz4oh8icIqaSYqGKWEmVx qOQEwymf/aZLHI2Sb5HBWN59bAvGpQAR1MbgG103wj9yvZ/GvzW8cNnSzoYOh5mA/ZXz FqjJPqyZbz0C+HnI/tF6C6lPc87RbZcJnavlF8i/vlXZv0sxB8u0YHZaUB/S5+VrINlw 9C6rB5LQWpOJhtInLAfNIg4RAjkypIjKmixZJfVTsv7znIrwpYHDQVAwV5hZhDXjegss G0pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=XLvu9YuJyEq4PpXLboWGHlPW5BtXq8Iaz4s/vCpOC+c=; b=ljI3IeJKJ+X+eT8lBBf5nc/RG3POcfnrNcsUFwDMHDY0TQoaLDbW503GvDUm/ksHO6 acnsD3wBd2zoyivSa+nx7C2fO21IPjeWNRRhlsd9gd155bCYdTKBBbmPeyFO8scMzRWj ubanBVbtriL1u+X0P9nYIjPYwLTuCj+oNqcvcM7v1e0XotDocKHFsIEX7ZGFUXdsMonr cMOiOIa9rnZiTwIPUoHCwmauQGW6ynvahs1DxCugYxIrMrLOP97Djvmq5StyllqNflQ3 9veJGxtNi0eNwXcC/J6m/GLfllcgHxEuIMQMbS+vR+3z40QTr9xLaimFo/Q6BzWFJGsW lkxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=e3ljpji6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t16-20020a056402525000b0046329e2724dsi4144179edd.86.2022.12.16.14.20.18; Fri, 16 Dec 2022 14:20:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=e3ljpji6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230042AbiLPWRt (ORCPT <rfc822;jeantsuru.cumc.mandola@gmail.com> + 99 others); Fri, 16 Dec 2022 17:17:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229957AbiLPWR0 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 16 Dec 2022 17:17:26 -0500 Received: from mail-io1-xd4a.google.com (mail-io1-xd4a.google.com [IPv6:2607:f8b0:4864:20::d4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3969127917 for <linux-kernel@vger.kernel.org>; Fri, 16 Dec 2022 14:17:25 -0800 (PST) Received: by mail-io1-xd4a.google.com with SMTP id a14-20020a6b660e000000b006bd37975cdfso2027071ioc.10 for <linux-kernel@vger.kernel.org>; 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=oDT+8asFkeNAmqxhl5uUjTb5309j5kkoEtdFu6oVEpWbc9Td3H4CpoT6LTS55yuzYB JHpoh6iH8SiaIfDGBL7PoGuYhl4InADiRbUzM2yUr7spC0zMtD1LFnHhvqjwrCivJXYO o/2vWWIDlYJ3/wH2dR0MnlPpZzV+ZwY4GDxS2KDdgKOM1U9dSaa3+8YOOEve3wxKfeh8 gi6svlPJZMIpuY5Sez6jalBUJS8qcX32vy9EmsyXrKQhLw4iT/m+EXk+PwlYS08NXEp5 XGz6NjqP/5fHJ+iDAT2fZxTYRUc4SVdJrkZ9b7JfOSWtj44UJ+Ewgj5gUFy2jCALLx+3 lvhQ== X-Gm-Message-State: ANoB5pny3So0zOqGSNzkDFGXdOn/KclMi8XEbN7utcU+jgy9UDDiKxcu LtmpXyVwEBdiO2ulq2zwrGYMqM+Dn972zI4= 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: <Y5IA2NYE5IaAzNby@kroah.com> <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 <allenwebb@google.com> To: "linux-modules@vger.kernel.org" <linux-modules@vger.kernel.org>, "linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org> Cc: Luis Chamberlain <mcgrof@kernel.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, "Rafael J. Wysocki" <rafael@kernel.org>, Allen Webb <allenwebb@google.com> Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752410874148235205?= X-GMAIL-MSGID: =?utf-8?q?1752410874148235205?= |
Series |
Generate modules.builtin.alias from match ids
|
|
Commit Message
Allen Webb
Dec. 16, 2022, 10:17 p.m. UTC
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@google.com>
---
scripts/mod/file2alias.c | 55 +++++++++++++++++++++++++++-------------
1 file changed, 38 insertions(+), 17 deletions(-)
Comments
Hi Allen, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on masahiroy-kbuild/fixes] [also build test WARNING on mcgrof/modules-next westeri-thunderbolt/next linus/master v6.1 next-20221216] [cannot apply to masahiroy-kbuild/for-next] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Allen-Webb/module-h-MODULE_DEVICE_TABLE-for-built-in-modules/20221217-071949 base: https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git fixes patch link: https://lore.kernel.org/r/20221216221703.294683-5-allenwebb%40google.com patch subject: [PATCH v7 4/5] file2alias.c: Implement builtin.alias generation config: powerpc-allnoconfig compiler: powerpc-linux-gcc (GCC) 12.1.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/e65dd221062ee2430d083c7a65400fe1b1fc771f git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Allen-Webb/module-h-MODULE_DEVICE_TABLE-for-built-in-modules/20221217-071949 git checkout e65dd221062ee2430d083c7a65400fe1b1fc771f # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=powerpc olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=powerpc prepare If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): scripts/mod/file2alias.c: In function 'do_pnp_card_entries': >> scripts/mod/file2alias.c:679:25: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] 679 | char acpi_id[PNP_ID_LEN]; | ^~~~ -- scripts/mod/file2alias.c: In function 'do_pnp_card_entries': >> scripts/mod/file2alias.c:679:25: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] 679 | char acpi_id[PNP_ID_LEN]; | ^~~~ vim +679 scripts/mod/file2alias.c ^1da177e4c3f41 Linus Torvalds 2005-04-16 633 0c81eed4b9d627 Kay Sievers 2008-02-21 634 /* looks like: "pnp:dD" for every device of the card */ 0c81eed4b9d627 Kay Sievers 2008-02-21 635 static void do_pnp_card_entries(void *symval, unsigned long size, 0c81eed4b9d627 Kay Sievers 2008-02-21 636 struct module *mod) ^1da177e4c3f41 Linus Torvalds 2005-04-16 637 { 6543becf26fff6 Andreas Schwab 2013-01-20 638 const unsigned long id_size = SIZE_pnp_card_device_id; 0c81eed4b9d627 Kay Sievers 2008-02-21 639 const unsigned int count = (size / id_size)-1; 0c81eed4b9d627 Kay Sievers 2008-02-21 640 unsigned int i; 0c81eed4b9d627 Kay Sievers 2008-02-21 641 0c81eed4b9d627 Kay Sievers 2008-02-21 642 device_id_check(mod->name, "pnp", size, id_size, symval); 0c81eed4b9d627 Kay Sievers 2008-02-21 643 0c81eed4b9d627 Kay Sievers 2008-02-21 644 for (i = 0; i < count; i++) { 0c81eed4b9d627 Kay Sievers 2008-02-21 645 unsigned int j; 6543becf26fff6 Andreas Schwab 2013-01-20 646 DEF_FIELD_ADDR(symval + i * id_size, pnp_card_device_id, devs); 0c81eed4b9d627 Kay Sievers 2008-02-21 647 0c81eed4b9d627 Kay Sievers 2008-02-21 648 for (j = 0; j < PNP_MAX_DEVICES; j++) { 6543becf26fff6 Andreas Schwab 2013-01-20 649 const char *id = (char *)(*devs)[j].id; 0c81eed4b9d627 Kay Sievers 2008-02-21 650 int i2, j2; 0c81eed4b9d627 Kay Sievers 2008-02-21 651 int dup = 0; 0c81eed4b9d627 Kay Sievers 2008-02-21 652 0c81eed4b9d627 Kay Sievers 2008-02-21 653 if (!id[0]) 0c81eed4b9d627 Kay Sievers 2008-02-21 654 break; 0c81eed4b9d627 Kay Sievers 2008-02-21 655 0c81eed4b9d627 Kay Sievers 2008-02-21 656 /* find duplicate, already added value */ 0c81eed4b9d627 Kay Sievers 2008-02-21 657 for (i2 = 0; i2 < i && !dup; i2++) { c2b1a9226fe7c1 Leonardo Bras 2018-10-24 658 DEF_FIELD_ADDR_VAR(symval + i2 * id_size, c2b1a9226fe7c1 Leonardo Bras 2018-10-24 659 pnp_card_device_id, c2b1a9226fe7c1 Leonardo Bras 2018-10-24 660 devs, devs_dup); 0c81eed4b9d627 Kay Sievers 2008-02-21 661 0c81eed4b9d627 Kay Sievers 2008-02-21 662 for (j2 = 0; j2 < PNP_MAX_DEVICES; j2++) { c2b1a9226fe7c1 Leonardo Bras 2018-10-24 663 const char *id2 = c2b1a9226fe7c1 Leonardo Bras 2018-10-24 664 (char *)(*devs_dup)[j2].id; ^1da177e4c3f41 Linus Torvalds 2005-04-16 665 0c81eed4b9d627 Kay Sievers 2008-02-21 666 if (!id2[0]) 0c81eed4b9d627 Kay Sievers 2008-02-21 667 break; 0c81eed4b9d627 Kay Sievers 2008-02-21 668 0c81eed4b9d627 Kay Sievers 2008-02-21 669 if (!strcmp(id, id2)) { 0c81eed4b9d627 Kay Sievers 2008-02-21 670 dup = 1; ^1da177e4c3f41 Linus Torvalds 2005-04-16 671 break; ^1da177e4c3f41 Linus Torvalds 2005-04-16 672 } 0c81eed4b9d627 Kay Sievers 2008-02-21 673 } 0c81eed4b9d627 Kay Sievers 2008-02-21 674 } 0c81eed4b9d627 Kay Sievers 2008-02-21 675 0c81eed4b9d627 Kay Sievers 2008-02-21 676 /* add an individual alias for every device entry */ e65dd221062ee2 Allen Webb 2022-12-16 677 if (dup) e65dd221062ee2 Allen Webb 2022-12-16 678 continue; 6543becf26fff6 Andreas Schwab 2013-01-20 @679 char acpi_id[PNP_ID_LEN]; 72638f598ec9f0 Kay Sievers 2009-01-08 680 int k; 72638f598ec9f0 Kay Sievers 2009-01-08 681 0c81eed4b9d627 Kay Sievers 2008-02-21 682 buf_printf(&mod->dev_table_buf, 0c81eed4b9d627 Kay Sievers 2008-02-21 683 "MODULE_ALIAS(\"pnp:d%s*\");\n", id); e65dd221062ee2 Allen Webb 2022-12-16 684 if (mod->builtin_name) e65dd221062ee2 Allen Webb 2022-12-16 685 buf_printf(&mod->modalias_buf, "alias pnp:d%s* %s\n", e65dd221062ee2 Allen Webb 2022-12-16 686 id, mod->builtin_name); 72638f598ec9f0 Kay Sievers 2009-01-08 687 72638f598ec9f0 Kay Sievers 2009-01-08 688 /* fix broken pnp bus lowercasing */ 72638f598ec9f0 Kay Sievers 2009-01-08 689 for (k = 0; k < sizeof(acpi_id); k++) 72638f598ec9f0 Kay Sievers 2009-01-08 690 acpi_id[k] = toupper(id[k]); 22454cb99fc39f Kay Sievers 2008-05-28 691 buf_printf(&mod->dev_table_buf, 72638f598ec9f0 Kay Sievers 2009-01-08 692 "MODULE_ALIAS(\"acpi*:%s:*\");\n", acpi_id); e65dd221062ee2 Allen Webb 2022-12-16 693 if (mod->builtin_name) e65dd221062ee2 Allen Webb 2022-12-16 694 buf_printf(&mod->modalias_buf, "alias acpi*:%s:* %s\n", e65dd221062ee2 Allen Webb 2022-12-16 695 acpi_id, mod->builtin_name); 0c81eed4b9d627 Kay Sievers 2008-02-21 696 } 0c81eed4b9d627 Kay Sievers 2008-02-21 697 } ^1da177e4c3f41 Linus Torvalds 2005-04-16 698 } ^1da177e4c3f41 Linus Torvalds 2005-04-16 699
Hi Allen, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on masahiroy-kbuild/fixes] [also build test WARNING on mcgrof/modules-next westeri-thunderbolt/next linus/master v6.1 next-20221216] [cannot apply to masahiroy-kbuild/for-next] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Allen-Webb/module-h-MODULE_DEVICE_TABLE-for-built-in-modules/20221217-071949 base: https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git fixes patch link: https://lore.kernel.org/r/20221216221703.294683-5-allenwebb%40google.com patch subject: [PATCH v7 4/5] file2alias.c: Implement builtin.alias generation config: x86_64-randconfig-a001 compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/e65dd221062ee2430d083c7a65400fe1b1fc771f git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Allen-Webb/module-h-MODULE_DEVICE_TABLE-for-built-in-modules/20221217-071949 git checkout e65dd221062ee2430d083c7a65400fe1b1fc771f # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 prepare If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): >> scripts/mod/file2alias.c:679:9: warning: mixing declarations and code is incompatible with standards before C99 [-Wdeclaration-after-statement] char acpi_id[PNP_ID_LEN]; ^ 1 warning generated. -- >> scripts/mod/file2alias.c:679:9: warning: mixing declarations and code is incompatible with standards before C99 [-Wdeclaration-after-statement] char acpi_id[PNP_ID_LEN]; ^ 1 warning generated. vim +679 scripts/mod/file2alias.c ^1da177e4c3f41 Linus Torvalds 2005-04-16 633 0c81eed4b9d627 Kay Sievers 2008-02-21 634 /* looks like: "pnp:dD" for every device of the card */ 0c81eed4b9d627 Kay Sievers 2008-02-21 635 static void do_pnp_card_entries(void *symval, unsigned long size, 0c81eed4b9d627 Kay Sievers 2008-02-21 636 struct module *mod) ^1da177e4c3f41 Linus Torvalds 2005-04-16 637 { 6543becf26fff6 Andreas Schwab 2013-01-20 638 const unsigned long id_size = SIZE_pnp_card_device_id; 0c81eed4b9d627 Kay Sievers 2008-02-21 639 const unsigned int count = (size / id_size)-1; 0c81eed4b9d627 Kay Sievers 2008-02-21 640 unsigned int i; 0c81eed4b9d627 Kay Sievers 2008-02-21 641 0c81eed4b9d627 Kay Sievers 2008-02-21 642 device_id_check(mod->name, "pnp", size, id_size, symval); 0c81eed4b9d627 Kay Sievers 2008-02-21 643 0c81eed4b9d627 Kay Sievers 2008-02-21 644 for (i = 0; i < count; i++) { 0c81eed4b9d627 Kay Sievers 2008-02-21 645 unsigned int j; 6543becf26fff6 Andreas Schwab 2013-01-20 646 DEF_FIELD_ADDR(symval + i * id_size, pnp_card_device_id, devs); 0c81eed4b9d627 Kay Sievers 2008-02-21 647 0c81eed4b9d627 Kay Sievers 2008-02-21 648 for (j = 0; j < PNP_MAX_DEVICES; j++) { 6543becf26fff6 Andreas Schwab 2013-01-20 649 const char *id = (char *)(*devs)[j].id; 0c81eed4b9d627 Kay Sievers 2008-02-21 650 int i2, j2; 0c81eed4b9d627 Kay Sievers 2008-02-21 651 int dup = 0; 0c81eed4b9d627 Kay Sievers 2008-02-21 652 0c81eed4b9d627 Kay Sievers 2008-02-21 653 if (!id[0]) 0c81eed4b9d627 Kay Sievers 2008-02-21 654 break; 0c81eed4b9d627 Kay Sievers 2008-02-21 655 0c81eed4b9d627 Kay Sievers 2008-02-21 656 /* find duplicate, already added value */ 0c81eed4b9d627 Kay Sievers 2008-02-21 657 for (i2 = 0; i2 < i && !dup; i2++) { c2b1a9226fe7c1 Leonardo Bras 2018-10-24 658 DEF_FIELD_ADDR_VAR(symval + i2 * id_size, c2b1a9226fe7c1 Leonardo Bras 2018-10-24 659 pnp_card_device_id, c2b1a9226fe7c1 Leonardo Bras 2018-10-24 660 devs, devs_dup); 0c81eed4b9d627 Kay Sievers 2008-02-21 661 0c81eed4b9d627 Kay Sievers 2008-02-21 662 for (j2 = 0; j2 < PNP_MAX_DEVICES; j2++) { c2b1a9226fe7c1 Leonardo Bras 2018-10-24 663 const char *id2 = c2b1a9226fe7c1 Leonardo Bras 2018-10-24 664 (char *)(*devs_dup)[j2].id; ^1da177e4c3f41 Linus Torvalds 2005-04-16 665 0c81eed4b9d627 Kay Sievers 2008-02-21 666 if (!id2[0]) 0c81eed4b9d627 Kay Sievers 2008-02-21 667 break; 0c81eed4b9d627 Kay Sievers 2008-02-21 668 0c81eed4b9d627 Kay Sievers 2008-02-21 669 if (!strcmp(id, id2)) { 0c81eed4b9d627 Kay Sievers 2008-02-21 670 dup = 1; ^1da177e4c3f41 Linus Torvalds 2005-04-16 671 break; ^1da177e4c3f41 Linus Torvalds 2005-04-16 672 } 0c81eed4b9d627 Kay Sievers 2008-02-21 673 } 0c81eed4b9d627 Kay Sievers 2008-02-21 674 } 0c81eed4b9d627 Kay Sievers 2008-02-21 675 0c81eed4b9d627 Kay Sievers 2008-02-21 676 /* add an individual alias for every device entry */ e65dd221062ee2 Allen Webb 2022-12-16 677 if (dup) e65dd221062ee2 Allen Webb 2022-12-16 678 continue; 6543becf26fff6 Andreas Schwab 2013-01-20 @679 char acpi_id[PNP_ID_LEN]; 72638f598ec9f0 Kay Sievers 2009-01-08 680 int k; 72638f598ec9f0 Kay Sievers 2009-01-08 681 0c81eed4b9d627 Kay Sievers 2008-02-21 682 buf_printf(&mod->dev_table_buf, 0c81eed4b9d627 Kay Sievers 2008-02-21 683 "MODULE_ALIAS(\"pnp:d%s*\");\n", id); e65dd221062ee2 Allen Webb 2022-12-16 684 if (mod->builtin_name) e65dd221062ee2 Allen Webb 2022-12-16 685 buf_printf(&mod->modalias_buf, "alias pnp:d%s* %s\n", e65dd221062ee2 Allen Webb 2022-12-16 686 id, mod->builtin_name); 72638f598ec9f0 Kay Sievers 2009-01-08 687 72638f598ec9f0 Kay Sievers 2009-01-08 688 /* fix broken pnp bus lowercasing */ 72638f598ec9f0 Kay Sievers 2009-01-08 689 for (k = 0; k < sizeof(acpi_id); k++) 72638f598ec9f0 Kay Sievers 2009-01-08 690 acpi_id[k] = toupper(id[k]); 22454cb99fc39f Kay Sievers 2008-05-28 691 buf_printf(&mod->dev_table_buf, 72638f598ec9f0 Kay Sievers 2009-01-08 692 "MODULE_ALIAS(\"acpi*:%s:*\");\n", acpi_id); e65dd221062ee2 Allen Webb 2022-12-16 693 if (mod->builtin_name) e65dd221062ee2 Allen Webb 2022-12-16 694 buf_printf(&mod->modalias_buf, "alias acpi*:%s:* %s\n", e65dd221062ee2 Allen Webb 2022-12-16 695 acpi_id, mod->builtin_name); 0c81eed4b9d627 Kay Sievers 2008-02-21 696 } 0c81eed4b9d627 Kay Sievers 2008-02-21 697 } ^1da177e4c3f41 Linus Torvalds 2005-04-16 698 } ^1da177e4c3f41 Linus Torvalds 2005-04-16 699
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@google.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); > } > } >
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); } }