Message ID | 20221219204619.2205248-6-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 c7csp2607469wrn; Mon, 19 Dec 2022 12:47:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf5+sgInUPN+WfSunSDduIsRdnHV08HVu8/DzQakq+SApR5m5A6uuMbc5za9owwpcj8EAsWI X-Received: by 2002:a05:6a20:12d6:b0:a7:8ce5:6fc6 with SMTP id v22-20020a056a2012d600b000a78ce56fc6mr63315573pzg.13.1671482866570; Mon, 19 Dec 2022 12:47:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671482866; cv=none; d=google.com; s=arc-20160816; b=v2NBer0QHZ37iglshSoQoCgfGB/5pgKl9dan2tO03dnE/vwquExYZPLZE9beXCcHwa LK4/H+7SzwzUXKiu5vbtTH+ZYJ3JKXispEKdbGV5hdg7FBoSFSriWvuebAjGBGhGTcsy WUC/WJT3DG9Q9uMXJ4ve79erzuLLlw1+p7Nr1Wpjbl1bX7RZ4Ovh5Nt84ZONjjwGOQq3 pE19/DrcSgx06DIWaEtMirRKQGYnLg4SgQ4ScuHMHDunMmg2JDh75GGX9KWM+9oaAs+o 8yDZqwRil0Pd6DrzS5jshFodaIJIAj5Df6M8AWHP0nX7EPf0EII4PQ+eWc7PuJFaLY/c LK4g== 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=8H+688P7vbFiGJ1BQ5c1Gn7u2rmje2kOlAqfxbXizp0=; b=mpsdKSSVhfCLh2pJKV+nTPJPalzuN53eWa0qYoQuurfsZe+dXwpYHuE232iHXtLaBj mwG6ySt2RIzcVs7b6u7mT84l6z8hMVyQ0xcMsblwv5pXWriVKtUk4ID656Y7hsGMklED vS7BgO9Jb5oOxtjaxOGhD3DYCj0fprjd+zSMcNgC1xTvg/zGuMzKtA91jv8RUBUWdZnV pmX+YXJOINhKNuU+rWXS+LfiC4UKwdey03tsT6K4ffUM/RJIfPGQqeSqVbCW55imY6mP tfa4G02CrkSw8wpKErXlNyfo4xlkRO/PjznubjSmZoFLM4qTUjx1vHigniIR1aMAaJ0r Bj9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=hlLpYyCA; 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 f19-20020a631013000000b0046fc9e82c99si12249361pgl.206.2022.12.19.12.47.32; Mon, 19 Dec 2022 12:47:46 -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=hlLpYyCA; 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 S232725AbiLSUqr (ORCPT <rfc822;abdi.embedded@gmail.com> + 99 others); Mon, 19 Dec 2022 15:46:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232656AbiLSUq2 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 19 Dec 2022 15:46:28 -0500 Received: from mail-il1-x14a.google.com (mail-il1-x14a.google.com [IPv6:2607:f8b0:4864:20::14a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E874E12A82 for <linux-kernel@vger.kernel.org>; Mon, 19 Dec 2022 12:46:27 -0800 (PST) Received: by mail-il1-x14a.google.com with SMTP id a10-20020a056e02180a00b0030bc09c6b94so900011ilv.6 for <linux-kernel@vger.kernel.org>; Mon, 19 Dec 2022 12:46:27 -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=8H+688P7vbFiGJ1BQ5c1Gn7u2rmje2kOlAqfxbXizp0=; b=hlLpYyCAQfl+MIvWNIXiPjtfE2Ac9W/jMEeedSCc9xOWKwW8B4pnGdF4IrFSo4ZBbv E0gMdAmwR7I2MkjyCMWTmbVPWclTfr6tnZ8k8i2JtR5E6sFpnzv4ALxFqm/Yg//ALMBj VA2NhNpbG+MNilIgP8azk/Y+U+Eg39zrLR35qwyKASquB12Lzlmt1kYibif8x3X8XD09 Cx0sWfwFTnuv15KXRd6ZlkspXo67DUuXIIrosUuK6Qq0MvNccg12PFiaAQ8yk7eYipN3 NHcCXdo5BCJM7j/CPt0n37dnA8/jrNrV+D0ULQjUKpNQGwqpb+kmo0RyJWJvqhA3Qrmb v8hQ== 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=8H+688P7vbFiGJ1BQ5c1Gn7u2rmje2kOlAqfxbXizp0=; b=8FYL9wohK9JWx65ityPMUYIyNrTla9iSCm7ehJaWZyBdgksES8kZEZzal3RgaSrgY1 f46xORSH/t//BC3jZNNiAXLlCOH7gccZ0U1yAPRvpBWX6n9ctkPPjtJueQu+X2PbiOHq Ssvy0A8Ohx5bAQfHWMndpUnfKEm38/oPipEVLx+O2UC+d7ftGCk3LkxUYmHrHDS6gdsM fkAqt1d5dLcMpWlM+TvKsJiZgXlO82lBhNOMXp7Ifv3Th9ri2Qy/H5ElaSyNckehcGhg tXLNJ4fHz2VsP0S+Wo0kTUjdo6yduEFeKi5xOSkAaXp2HTxz3jsa7R2IV06oB+Dbkoen aQqg== X-Gm-Message-State: ANoB5pmlFz3Cq2OV2YkN9nHJtVacwHtqSiwcgqjaYC07+imWbqMpbPn7 10l5yrtM+/YDGBSHWLFK5au1zlRgInDHU/w= X-Received: from allenwebb.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:12e8]) (user=allenwebb job=sendgmr) by 2002:a6b:db1a:0:b0:6e2:f383:f68d with SMTP id t26-20020a6bdb1a000000b006e2f383f68dmr2494390ioc.75.1671482787431; Mon, 19 Dec 2022 12:46:27 -0800 (PST) Date: Mon, 19 Dec 2022 14:46:13 -0600 In-Reply-To: <20221219204619.2205248-1-allenwebb@google.com> Mime-Version: 1.0 References: <20221219191855.2010466-1-allenwebb@google.com> <20221219204619.2205248-1-allenwebb@google.com> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Message-ID: <20221219204619.2205248-6-allenwebb@google.com> Subject: [PATCH v9 05/10] module.h: MODULE_DEVICE_TABLE for built-in modules 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=unavailable 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?1752410910230946689?= X-GMAIL-MSGID: =?utf-8?q?1752676818395313541?= |
Series |
Generate modules.builtin.alias from match ids
|
|
Commit Message
Allen Webb
Dec. 19, 2022, 8:46 p.m. UTC
Implement MODULE_DEVICE_TABLE for build-in modules to make it possible
to generate a builtin.alias file to complement modules.alias.
Signed-off-by: Allen Webb <allenwebb@google.com>
---
include/linux/module.h | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
Comments
On Mon, Dec 19, 2022 at 02:46:13PM -0600, Allen Webb wrote: > Implement MODULE_DEVICE_TABLE for build-in modules to make it possible > to generate a builtin.alias file to complement modules.alias. > > Signed-off-by: Allen Webb <allenwebb@google.com> > --- > include/linux/module.h | 15 ++++++++++++++- > 1 file changed, 14 insertions(+), 1 deletion(-) > > diff --git a/include/linux/module.h b/include/linux/module.h > index ec61fb53979a..3d1b04ca6350 100644 > --- a/include/linux/module.h > +++ b/include/linux/module.h > @@ -243,7 +243,20 @@ extern void cleanup_module(void); > extern typeof(name) __mod_##type##__##name##_device_table \ > __attribute__ ((unused, alias(__stringify(name)))) > #else /* !MODULE */ > -#define MODULE_DEVICE_TABLE(type, name) > +/* > + * The names may not be unique for built-in modules, so include the module name > + * to guarantee uniqueness. What "names" are you referring to here with the words, "The names"? And built-in modules have the same rules as external names, they have to be unique so I do not understand the problem you are trying to solve here, which means you need to describe it better in both the changelog text and the comment. > + * > + * Note that extern is needed because modpost reads these symbols to generate > + * modalias entries for each match id in each device table. They are not used > + * at runtime. This comment isn't explaining much about what the #define is to be used for, is it? confused, greg k-h
On Tue, Dec 20, 2022 at 12:45 AM Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote: > > On Mon, Dec 19, 2022 at 02:46:13PM -0600, Allen Webb wrote: > > Implement MODULE_DEVICE_TABLE for build-in modules to make it possible > > to generate a builtin.alias file to complement modules.alias. > > > > Signed-off-by: Allen Webb <allenwebb@google.com> > > --- > > include/linux/module.h | 15 ++++++++++++++- > > 1 file changed, 14 insertions(+), 1 deletion(-) > > > > diff --git a/include/linux/module.h b/include/linux/module.h > > index ec61fb53979a..3d1b04ca6350 100644 > > --- a/include/linux/module.h > > +++ b/include/linux/module.h > > @@ -243,7 +243,20 @@ extern void cleanup_module(void); > > extern typeof(name) __mod_##type##__##name##_device_table \ > > __attribute__ ((unused, alias(__stringify(name)))) > > #else /* !MODULE */ > > -#define MODULE_DEVICE_TABLE(type, name) > > +/* > > + * The names may not be unique for built-in modules, so include the module name > > + * to guarantee uniqueness. > > What "names" are you referring to here with the words, "The names"? > > And built-in modules have the same rules as external names, they have to > be unique so I do not understand the problem you are trying to solve > here, which means you need to describe it better in both the changelog > text and the comment. I changed the comment to: /* * Creates an alias so file2alias.c can find device table for built in modules. * * The module name is included for two reasons: * - Adding the module name to the alias avoids creating two aliases with the * same name. Historically MODULE_DEVICE_TABLE was a no-op for built-in * modules, so there was nothing to stop different modules from having the * same device table name and consequently the same alias when building as a * module. * - The module name is needed by files2alias.c to associate a particular * device table with its associated module since files2alias would otherwise * see the module name as `vmlinuz.o` for built-in modules. */ > > > + * > > + * Note that extern is needed because modpost reads these symbols to generate > > + * modalias entries for each match id in each device table. They are not used > > + * at runtime. > > This comment isn't explaining much about what the #define is to be used > for, is it? I will drop this. I originally added the comment because Christophe Leroy said: "'extern' keyword is pointless of function prototypes and deprecated. Don't add new occurences." This is clearly not a typical function prototype and the guidance from: https://www.kernel.org/doc/html/latest/process/coding-style.html#function-prototypes should not apply. > > confused, > > greg k-h
diff --git a/include/linux/module.h b/include/linux/module.h index ec61fb53979a..3d1b04ca6350 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -243,7 +243,20 @@ extern void cleanup_module(void); extern typeof(name) __mod_##type##__##name##_device_table \ __attribute__ ((unused, alias(__stringify(name)))) #else /* !MODULE */ -#define MODULE_DEVICE_TABLE(type, name) +/* + * The names may not be unique for built-in modules, so include the module name + * to guarantee uniqueness. + * + * Note that extern is needed because modpost reads these symbols to generate + * modalias entries for each match id in each device table. They are not used + * at runtime. + */ +#define MODULE_DEVICE_TABLE(type, name) \ +extern void *CONCATENATE( \ + CONCATENATE(__mod_##type##__##name##__, \ + __KBUILD_MODNAME), \ + _device_table) \ + __attribute__ ((unused, alias(__stringify(name)))) #endif /* Version of form [<epoch>:]<version>[-<extra-version>].