From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.4 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0CC9AC10F14 for ; Tue, 23 Apr 2019 07:06:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9C645206BA for ; Tue, 23 Apr 2019 07:06:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WrzqX6sd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725937AbfDWHGA (ORCPT ); Tue, 23 Apr 2019 03:06:00 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:37051 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725888AbfDWHF7 (ORCPT ); Tue, 23 Apr 2019 03:05:59 -0400 Received: by mail-ed1-f68.google.com with SMTP id f53so11625711ede.4 for ; Tue, 23 Apr 2019 00:05:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=GJY6qv/LtSxzFuxt6A51ZxxNLIZmwhsAgXk6GBZn9fY=; b=WrzqX6sdZPK875Y+q4RUJYi6GJAF6PKiEIzkN5GBZUEpsYi6nFOTvZle7idM94j+uv FYh6mK7rDB1JBhfAxKG8QYFj23GLqlxay20SJBTrVx3QsGkUp5m+Xvz9ZAtCUhY6hiEm FKDakp1Tk6dKaRKYTQrTxq8U8X9oHFwqZHF2oSoQqVGlbgDB6KvlVxmOTYiGRfvUmnSw r0KZV98y03gy0SI9x+scQr+j+c6y29gKvToxdZPzMQI6KyPIu4YmDGdiF22uZ/vUs/FF sBSNPVm46xAQyi9rz+SPROnvxOFgKAFzj7ustL2MvTysLFSXsKNV1ByG+aNqrP2w1kFI 9yMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=GJY6qv/LtSxzFuxt6A51ZxxNLIZmwhsAgXk6GBZn9fY=; b=TpaDxxqeGujj2Ps6CLnnjISUeR+eapc209x/dfKCrXYgkhEuG5cXySgHk8HonOdWE+ JESTbpoRubKp/cS43ABKb7YBRep3B/f1tfifuqBaqX0xpIfAMBEsStF0VBfFJQYkDFBc qL3jXPMY6f7b1dWsyQykI4bgiZGgtqiTJ1cWxfCYHpagRNVYCiiRa3PkGX2UeOplFTux 2l/SWAzsbwpxXR6H+vz7raeR30YTkq9lunRDmnLq+2U42rB9B4rzN1N3pv9DCCH0rjo9 nMBPrfJoPsJLoP0qnmtAZ+SJ4B0v+oQ7W3CW8ZGQzB0CW8pRAAAWJNAte8c3ttmoHqWR lHiA== X-Gm-Message-State: APjAAAUH7d6YEloTRtYL8cq1eGUh9/oG1kaBmU15wWP5IyYZ5BpRqpFm uJl6T4oMRCpq7cOO+OqYm6U= X-Google-Smtp-Source: APXvYqzn797Bommkx13DifieVzegDIDHN/+HBe1GbGQ4Q39uqOj1GBJWRL8dcdBeT24fWNvXnb97HA== X-Received: by 2002:a17:906:578f:: with SMTP id k15mr11604195ejq.140.1556003153730; Tue, 23 Apr 2019 00:05:53 -0700 (PDT) Received: from archlinux-i9 ([2a01:4f9:2b:2b84::2]) by smtp.gmail.com with ESMTPSA id w54sm4412621eda.85.2019.04.23.00.05.52 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 23 Apr 2019 00:05:52 -0700 (PDT) Date: Tue, 23 Apr 2019 00:05:50 -0700 From: Nathan Chancellor To: Matthias Kaehlcke Cc: stable@vger.kernel.org, Greg Kroah-Hartman , Nick Desaulniers , Masahiro Yamada Subject: Re: [Forw] [PATCH 1/2] modpost: file2alias: go back to simple devtable lookup Message-ID: <20190423070550.GA12575@archlinux-i9> References: <20190422212239.GB112750@google.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="4Ckj6UjgE2iN1+kY" Content-Disposition: inline In-Reply-To: <20190422212239.GB112750@google.com> User-Agent: Mutt/1.11.4 (2019-03-13) Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org --4Ckj6UjgE2iN1+kY Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Apr 22, 2019 at 02:22:39PM -0700, Matthias Kaehlcke wrote: > Hi, > > recent clang version rightfully barf when they come across ADD_TO_DEVTABLE: > > scripts/mod/file2alias.c:1222:1: warning: adding 'unsigned long' to > a string does not append to the string [-Wstring-plus-int] > ADD_TO_DEVTABLE("mei", mei_cl_device_id, do_mei_entry); > > scripts/mod/file2alias.c:108:13: note: expanded from macro > 'ADD_TO_DEVTABLE' > device_id + 0*sizeof((function)((const char *)NULL, > > > This can be addressed with the following upstream changes: > > f880eea68fe5 modpost: file2alias: check prototype of handler > ec91e78d378c modpost: file2alias: go back to simple devtable lookup > > Could these be added to -stable? > > This affects all versions back to 4.4 (no clang support for older > versions), though it's just a warning and the number of clang users > with older kernels is probably fairly limited. > All of the clang commits have been backported to 4.4. It would be nice to have these commits because that warning is very noisy. Note, this will not apply cleanly to 4.4, 4.9, and 4.14. I have attached mbox files with the conflicts resolved, after build testing for arm64 and x86_64. 4.19 is a clean cherry pick for me. Also added Masahiro to CC. Cheers, Nathan > Thanks > > Matthias > > ----- Forwarded message from Masahiro Yamada ----- > > Date: Thu, 22 Nov 2018 13:28:41 +0900 > From: Masahiro Yamada > To: linux-kbuild@vger.kernel.org > Cc: Jessica Yu , Rusty Russell , Mathieu Malaterre , Miguel > Ojeda , Masahiro Yamada , Michal Marek > , linux-kernel@vger.kernel.org > Subject: [PATCH 1/2] modpost: file2alias: go back to simple devtable lookup > X-Mailer: git-send-email 2.7.4 > > Commit e49ce14150c6 ("modpost: use linker section to generate table.") > was not so cool as we had expected because it ended up with ugly section > hacks when commit dd2a3acaecd7 ("mod/file2alias: make modpost compile on > darwin again") came in. > > Given a certain degree of unknowledge about the link stage of host > programs, I really want to see simple, stupid table lookup so that > this works in the same way regardless of the underlying executable > binary format. > > Signed-off-by: Masahiro Yamada > --- > > scripts/mod/file2alias.c | 144 ++++++++++++++++------------------------------- > 1 file changed, 49 insertions(+), 95 deletions(-) > > diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c > index 28a6166..7e4aede 100644 > --- a/scripts/mod/file2alias.c > +++ b/scripts/mod/file2alias.c > @@ -50,46 +50,6 @@ struct devtable { > void *function; > }; > > -#define ___cat(a,b) a ## b > -#define __cat(a,b) ___cat(a,b) > - > -/* we need some special handling for this host tool running eventually on > - * Darwin. The Mach-O section handling is a bit different than ELF section > - * handling. The differnces in detail are: > - * a) we have segments which have sections > - * b) we need a API call to get the respective section symbols */ > -#if defined(__MACH__) > -#include > - > -#define INIT_SECTION(name) do { \ > - unsigned long name ## _len; \ > - char *__cat(pstart_,name) = getsectdata("__TEXT", \ > - #name, &__cat(name,_len)); \ > - char *__cat(pstop_,name) = __cat(pstart_,name) + \ > - __cat(name, _len); \ > - __cat(__start_,name) = (void *)__cat(pstart_,name); \ > - __cat(__stop_,name) = (void *)__cat(pstop_,name); \ > - } while (0) > -#define SECTION(name) __attribute__((section("__TEXT, " #name))) > - > -struct devtable **__start___devtable, **__stop___devtable; > -#else > -#define INIT_SECTION(name) /* no-op for ELF */ > -#define SECTION(name) __attribute__((section(#name))) > - > -/* We construct a table of pointers in an ELF section (pointers generally > - * go unpadded by gcc). ld creates boundary syms for us. */ > -extern struct devtable *__start___devtable[], *__stop___devtable[]; > -#endif /* __MACH__ */ > - > -#if !defined(__used) > -# if __GNUC__ == 3 && __GNUC_MINOR__ < 3 > -# define __used __attribute__((__unused__)) > -# else > -# define __used __attribute__((__used__)) > -# endif > -#endif > - > /* Define a variable f that holds the value of field f of struct devid > * based at address m. > */ > @@ -110,16 +70,6 @@ extern struct devtable *__start___devtable[], *__stop___devtable[]; > #define DEF_FIELD_ADDR(m, devid, f) \ > DEF_FIELD_ADDR_VAR(m, devid, f, f) > > -/* Add a table entry. We test function type matches while we're here. */ > -#define ADD_TO_DEVTABLE(device_id, type, function) \ > - static struct devtable __cat(devtable,__LINE__) = { \ > - device_id + 0*sizeof((function)((const char *)NULL, \ > - (void *)NULL, \ > - (char *)NULL)), \ > - SIZE_##type, (function) }; \ > - static struct devtable *SECTION(__devtable) __used \ > - __cat(devtable_ptr,__LINE__) = &__cat(devtable,__LINE__) > - > #define ADD(str, sep, cond, field) \ > do { \ > strcat(str, sep); \ > @@ -439,7 +389,6 @@ static int do_hid_entry(const char *filename, > > return 1; > } > -ADD_TO_DEVTABLE("hid", hid_device_id, do_hid_entry); > > /* Looks like: ieee1394:venNmoNspNverN */ > static int do_ieee1394_entry(const char *filename, > @@ -464,7 +413,6 @@ static int do_ieee1394_entry(const char *filename, > add_wildcard(alias); > return 1; > } > -ADD_TO_DEVTABLE("ieee1394", ieee1394_device_id, do_ieee1394_entry); > > /* Looks like: pci:vNdNsvNsdNbcNscNiN. */ > static int do_pci_entry(const char *filename, > @@ -508,7 +456,6 @@ static int do_pci_entry(const char *filename, > add_wildcard(alias); > return 1; > } > -ADD_TO_DEVTABLE("pci", pci_device_id, do_pci_entry); > > /* looks like: "ccw:tNmNdtNdmN" */ > static int do_ccw_entry(const char *filename, > @@ -532,7 +479,6 @@ static int do_ccw_entry(const char *filename, > add_wildcard(alias); > return 1; > } > -ADD_TO_DEVTABLE("ccw", ccw_device_id, do_ccw_entry); > > /* looks like: "ap:tN" */ > static int do_ap_entry(const char *filename, > @@ -543,7 +489,6 @@ static int do_ap_entry(const char *filename, > sprintf(alias, "ap:t%02X*", dev_type); > return 1; > } > -ADD_TO_DEVTABLE("ap", ap_device_id, do_ap_entry); > > /* looks like: "css:tN" */ > static int do_css_entry(const char *filename, > @@ -554,7 +499,6 @@ static int do_css_entry(const char *filename, > sprintf(alias, "css:t%01X", type); > return 1; > } > -ADD_TO_DEVTABLE("css", css_device_id, do_css_entry); > > /* Looks like: "serio:tyNprNidNexN" */ > static int do_serio_entry(const char *filename, > @@ -574,7 +518,6 @@ static int do_serio_entry(const char *filename, > add_wildcard(alias); > return 1; > } > -ADD_TO_DEVTABLE("serio", serio_device_id, do_serio_entry); > > /* looks like: "acpi:ACPI0003" or "acpi:PNP0C0B" or "acpi:LNXVIDEO" or > * "acpi:bbsspp" (bb=base-class, ss=sub-class, pp=prog-if) > @@ -612,7 +555,6 @@ static int do_acpi_entry(const char *filename, > } > return 1; > } > -ADD_TO_DEVTABLE("acpi", acpi_device_id, do_acpi_entry); > > /* looks like: "pnp:dD" */ > static void do_pnp_device_entry(void *symval, unsigned long size, > @@ -736,7 +678,6 @@ static int do_pcmcia_entry(const char *filename, > add_wildcard(alias); > return 1; > } > -ADD_TO_DEVTABLE("pcmcia", pcmcia_device_id, do_pcmcia_entry); > > static int do_vio_entry(const char *filename, void *symval, > char *alias) > @@ -756,7 +697,6 @@ static int do_vio_entry(const char *filename, void *symval, > add_wildcard(alias); > return 1; > } > -ADD_TO_DEVTABLE("vio", vio_device_id, do_vio_entry); > > #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) > > @@ -829,7 +769,6 @@ static int do_input_entry(const char *filename, void *symval, > do_input(alias, *swbit, 0, INPUT_DEVICE_ID_SW_MAX); > return 1; > } > -ADD_TO_DEVTABLE("input", input_device_id, do_input_entry); > > static int do_eisa_entry(const char *filename, void *symval, > char *alias) > @@ -841,7 +780,6 @@ static int do_eisa_entry(const char *filename, void *symval, > strcat(alias, "*"); > return 1; > } > -ADD_TO_DEVTABLE("eisa", eisa_device_id, do_eisa_entry); > > /* Looks like: parisc:tNhvNrevNsvN */ > static int do_parisc_entry(const char *filename, void *symval, > @@ -861,7 +799,6 @@ static int do_parisc_entry(const char *filename, void *symval, > add_wildcard(alias); > return 1; > } > -ADD_TO_DEVTABLE("parisc", parisc_device_id, do_parisc_entry); > > /* Looks like: sdio:cNvNdN. */ > static int do_sdio_entry(const char *filename, > @@ -878,7 +815,6 @@ static int do_sdio_entry(const char *filename, > add_wildcard(alias); > return 1; > } > -ADD_TO_DEVTABLE("sdio", sdio_device_id, do_sdio_entry); > > /* Looks like: ssb:vNidNrevN. */ > static int do_ssb_entry(const char *filename, > @@ -895,7 +831,6 @@ static int do_ssb_entry(const char *filename, > add_wildcard(alias); > return 1; > } > -ADD_TO_DEVTABLE("ssb", ssb_device_id, do_ssb_entry); > > /* Looks like: bcma:mNidNrevNclN. */ > static int do_bcma_entry(const char *filename, > @@ -914,7 +849,6 @@ static int do_bcma_entry(const char *filename, > add_wildcard(alias); > return 1; > } > -ADD_TO_DEVTABLE("bcma", bcma_device_id, do_bcma_entry); > > /* Looks like: virtio:dNvN */ > static int do_virtio_entry(const char *filename, void *symval, > @@ -930,7 +864,6 @@ static int do_virtio_entry(const char *filename, void *symval, > add_wildcard(alias); > return 1; > } > -ADD_TO_DEVTABLE("virtio", virtio_device_id, do_virtio_entry); > > /* > * Looks like: vmbus:guid > @@ -953,7 +886,6 @@ static int do_vmbus_entry(const char *filename, void *symval, > > return 1; > } > -ADD_TO_DEVTABLE("vmbus", hv_vmbus_device_id, do_vmbus_entry); > > /* Looks like: rpmsg:S */ > static int do_rpmsg_entry(const char *filename, void *symval, > @@ -964,7 +896,6 @@ static int do_rpmsg_entry(const char *filename, void *symval, > > return 1; > } > -ADD_TO_DEVTABLE("rpmsg", rpmsg_device_id, do_rpmsg_entry); > > /* Looks like: i2c:S */ > static int do_i2c_entry(const char *filename, void *symval, > @@ -975,7 +906,6 @@ static int do_i2c_entry(const char *filename, void *symval, > > return 1; > } > -ADD_TO_DEVTABLE("i2c", i2c_device_id, do_i2c_entry); > > /* Looks like: spi:S */ > static int do_spi_entry(const char *filename, void *symval, > @@ -986,7 +916,6 @@ static int do_spi_entry(const char *filename, void *symval, > > return 1; > } > -ADD_TO_DEVTABLE("spi", spi_device_id, do_spi_entry); > > static const struct dmifield { > const char *prefix; > @@ -1041,7 +970,6 @@ static int do_dmi_entry(const char *filename, void *symval, > strcat(alias, ":"); > return 1; > } > -ADD_TO_DEVTABLE("dmi", dmi_system_id, do_dmi_entry); > > static int do_platform_entry(const char *filename, > void *symval, char *alias) > @@ -1050,7 +978,6 @@ static int do_platform_entry(const char *filename, > sprintf(alias, PLATFORM_MODULE_PREFIX "%s", *name); > return 1; > } > -ADD_TO_DEVTABLE("platform", platform_device_id, do_platform_entry); > > static int do_mdio_entry(const char *filename, > void *symval, char *alias) > @@ -1075,7 +1002,6 @@ static int do_mdio_entry(const char *filename, > > return 1; > } > -ADD_TO_DEVTABLE("mdio", mdio_device_id, do_mdio_entry); > > /* Looks like: zorro:iN. */ > static int do_zorro_entry(const char *filename, void *symval, > @@ -1086,7 +1012,6 @@ static int do_zorro_entry(const char *filename, void *symval, > ADD(alias, "i", id != ZORRO_WILDCARD, id); > return 1; > } > -ADD_TO_DEVTABLE("zorro", zorro_device_id, do_zorro_entry); > > /* looks like: "pnp:dD" */ > static int do_isapnp_entry(const char *filename, > @@ -1102,7 +1027,6 @@ static int do_isapnp_entry(const char *filename, > (function >> 12) & 0x0f, (function >> 8) & 0x0f); > return 1; > } > -ADD_TO_DEVTABLE("isapnp", isapnp_device_id, do_isapnp_entry); > > /* Looks like: "ipack:fNvNdN". */ > static int do_ipack_entry(const char *filename, > @@ -1118,7 +1042,6 @@ static int do_ipack_entry(const char *filename, > add_wildcard(alias); > return 1; > } > -ADD_TO_DEVTABLE("ipack", ipack_device_id, do_ipack_entry); > > /* > * Append a match expression for a single masked hex digit. > @@ -1189,7 +1112,6 @@ static int do_amba_entry(const char *filename, > > return 1; > } > -ADD_TO_DEVTABLE("amba", amba_id, do_amba_entry); > > /* > * looks like: "mipscdmm:tN" > @@ -1205,7 +1127,6 @@ static int do_mips_cdmm_entry(const char *filename, > sprintf(alias, "mipscdmm:t%02X*", type); > return 1; > } > -ADD_TO_DEVTABLE("mipscdmm", mips_cdmm_device_id, do_mips_cdmm_entry); > > /* LOOKS like cpu:type:x86,venVVVVfamFFFFmodMMMM:feature:*,FEAT,* > * All fields are numbers. It would be nicer to use strings for vendor > @@ -1230,7 +1151,6 @@ static int do_x86cpu_entry(const char *filename, void *symval, > sprintf(alias + strlen(alias), "%04X*", feature); > return 1; > } > -ADD_TO_DEVTABLE("x86cpu", x86_cpu_id, do_x86cpu_entry); > > /* LOOKS like cpu:type:*:feature:*FEAT* */ > static int do_cpu_entry(const char *filename, void *symval, char *alias) > @@ -1240,7 +1160,6 @@ static int do_cpu_entry(const char *filename, void *symval, char *alias) > sprintf(alias, "cpu:type:*:feature:*%04X*", feature); > return 1; > } > -ADD_TO_DEVTABLE("cpu", cpu_feature, do_cpu_entry); > > /* Looks like: mei:S:uuid:N:* */ > static int do_mei_entry(const char *filename, void *symval, > @@ -1259,7 +1178,6 @@ static int do_mei_entry(const char *filename, void *symval, > > return 1; > } > -ADD_TO_DEVTABLE("mei", mei_cl_device_id, do_mei_entry); > > /* Looks like: rapidio:vNdNavNadN */ > static int do_rio_entry(const char *filename, > @@ -1279,7 +1197,6 @@ static int do_rio_entry(const char *filename, > add_wildcard(alias); > return 1; > } > -ADD_TO_DEVTABLE("rapidio", rio_device_id, do_rio_entry); > > /* Looks like: ulpi:vNpN */ > static int do_ulpi_entry(const char *filename, void *symval, > @@ -1292,7 +1209,6 @@ static int do_ulpi_entry(const char *filename, void *symval, > > return 1; > } > -ADD_TO_DEVTABLE("ulpi", ulpi_device_id, do_ulpi_entry); > > /* Looks like: hdaudio:vNrNaN */ > static int do_hda_entry(const char *filename, void *symval, char *alias) > @@ -1309,7 +1225,6 @@ static int do_hda_entry(const char *filename, void *symval, char *alias) > add_wildcard(alias); > return 1; > } > -ADD_TO_DEVTABLE("hdaudio", hda_device_id, do_hda_entry); > > /* Looks like: sdw:mNpN */ > static int do_sdw_entry(const char *filename, void *symval, char *alias) > @@ -1324,7 +1239,6 @@ static int do_sdw_entry(const char *filename, void *symval, char *alias) > add_wildcard(alias); > return 1; > } > -ADD_TO_DEVTABLE("sdw", sdw_device_id, do_sdw_entry); > > /* Looks like: fsl-mc:vNdN */ > static int do_fsl_mc_entry(const char *filename, void *symval, > @@ -1336,7 +1250,6 @@ static int do_fsl_mc_entry(const char *filename, void *symval, > sprintf(alias, "fsl-mc:v%08Xd%s", vendor, *obj_type); > return 1; > } > -ADD_TO_DEVTABLE("fslmc", fsl_mc_device_id, do_fsl_mc_entry); > > /* Looks like: tbsvc:kSpNvNrN */ > static int do_tbsvc_entry(const char *filename, void *symval, char *alias) > @@ -1361,7 +1274,6 @@ static int do_tbsvc_entry(const char *filename, void *symval, char *alias) > add_wildcard(alias); > return 1; > } > -ADD_TO_DEVTABLE("tbsvc", tb_service_id, do_tbsvc_entry); > > /* Looks like: typec:idNmN */ > static int do_typec_entry(const char *filename, void *symval, char *alias) > @@ -1374,7 +1286,6 @@ static int do_typec_entry(const char *filename, void *symval, char *alias) > > return 1; > } > -ADD_TO_DEVTABLE("typec", typec_device_id, do_typec_entry); > > /* Does namelen bytes of name exactly match the symbol? */ > static bool sym_is(const char *name, unsigned namelen, const char *symbol) > @@ -1407,6 +1318,48 @@ static void do_table(void *symval, unsigned long size, > } > } > > +static const struct devtable devtable[] = { > + {"hid", SIZE_hid_device_id, do_hid_entry}, > + {"ieee1394", SIZE_ieee1394_device_id, do_ieee1394_entry}, > + {"pci", SIZE_pci_device_id, do_pci_entry}, > + {"ccw", SIZE_ccw_device_id, do_ccw_entry}, > + {"ap", SIZE_ap_device_id, do_ap_entry}, > + {"css", SIZE_css_device_id, do_css_entry}, > + {"serio", SIZE_serio_device_id, do_serio_entry}, > + {"acpi", SIZE_acpi_device_id, do_acpi_entry}, > + {"pcmcia", SIZE_pcmcia_device_id, do_pcmcia_entry}, > + {"vio", SIZE_vio_device_id, do_vio_entry}, > + {"input", SIZE_input_device_id, do_input_entry}, > + {"eisa", SIZE_eisa_device_id, do_eisa_entry}, > + {"parisc", SIZE_parisc_device_id, do_parisc_entry}, > + {"sdio", SIZE_sdio_device_id, do_sdio_entry}, > + {"ssb", SIZE_ssb_device_id, do_ssb_entry}, > + {"bcma", SIZE_bcma_device_id, do_bcma_entry}, > + {"virtio", SIZE_virtio_device_id, do_virtio_entry}, > + {"vmbus", SIZE_hv_vmbus_device_id, do_vmbus_entry}, > + {"rpmsg", SIZE_rpmsg_device_id, do_rpmsg_entry}, > + {"i2c", SIZE_i2c_device_id, do_i2c_entry}, > + {"spi", SIZE_spi_device_id, do_spi_entry}, > + {"dmi", SIZE_dmi_system_id, do_dmi_entry}, > + {"platform", SIZE_platform_device_id, do_platform_entry}, > + {"mdio", SIZE_mdio_device_id, do_mdio_entry}, > + {"zorro", SIZE_zorro_device_id, do_zorro_entry}, > + {"isapnp", SIZE_isapnp_device_id, do_isapnp_entry}, > + {"ipack", SIZE_ipack_device_id, do_ipack_entry}, > + {"amba", SIZE_amba_id, do_amba_entry}, > + {"mipscdmm", SIZE_mips_cdmm_device_id, do_mips_cdmm_entry}, > + {"x86cpu", SIZE_x86_cpu_id, do_x86cpu_entry}, > + {"cpu", SIZE_cpu_feature, do_cpu_entry}, > + {"mei", SIZE_mei_cl_device_id, do_mei_entry}, > + {"rapidio", SIZE_rio_device_id, do_rio_entry}, > + {"ulpi", SIZE_ulpi_device_id, do_ulpi_entry}, > + {"hdaudio", SIZE_hda_device_id, do_hda_entry}, > + {"sdw", SIZE_sdw_device_id, do_sdw_entry}, > + {"fslmc", SIZE_fsl_mc_device_id, do_fsl_mc_entry}, > + {"tbsvc", SIZE_tb_service_id, do_tbsvc_entry}, > + {"typec", SIZE_typec_device_id, do_typec_entry}, > +}; > + > /* Create MODULE_ALIAS() statements. > * At this time, we cannot write the actual output C source yet, > * so we write into the mod->dev_table_buf buffer. */ > @@ -1460,13 +1413,14 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, > else if (sym_is(name, namelen, "pnp_card")) > do_pnp_card_entries(symval, sym->st_size, mod); > else { > - struct devtable **p; > - INIT_SECTION(__devtable); > + int i; > + > + for (i = 0; i < ARRAY_SIZE(devtable); i++) { > + const struct devtable *p = &devtable[i]; > > - for (p = __start___devtable; p < __stop___devtable; p++) { > - if (sym_is(name, namelen, (*p)->device_id)) { > - do_table(symval, sym->st_size, (*p)->id_size, > - (*p)->device_id, (*p)->function, mod); > + if (sym_is(name, namelen, p->device_id)) { > + do_table(symval, sym->st_size, p->id_size, > + p->device_id, p->function, mod); > break; > } > } > -- > 2.7.4 > > > ----- End forwarded message ----- --4Ckj6UjgE2iN1+kY Content-Type: application/mbox Content-Disposition: attachment; filename="4.4.mbox" Content-Transfer-Encoding: quoted-printable =46rom 415957847a361877904a65ff670ea981ded4c9da Mon Sep 17 00:00:00 2001=0A= =46rom: Masahiro Yamada =0ADate: Thu, 22 Nov= 2018 13:28:41 +0900=0ASubject: [PATCH 4.4 1/2] modpost: file2alias: go bac= k to simple devtable=0A lookup=0A=0Acommit ec91e78d378cc5d4b43805a1227d8e04= e5dfa17d upstream.=0A=0ACommit e49ce14150c6 ("modpost: use linker section t= o generate table.")=0Awas not so cool as we had expected first; it ended up= with ugly section=0Ahacks when commit dd2a3acaecd7 ("mod/file2alias: make = modpost compile=0Aon darwin again") came in.=0A=0AGiven a certain degree of= unknowledge about the link stage of host=0Aprograms, I really want to see = simple, stupid table lookup so that=0Athis works in the same way regardless= of the underlying executable=0Aformat.=0A=0ASigned-off-by: Masahiro Yamada= =0AAcked-by: Mathieu Malaterre =0A[nc: Omit rpmsg, sdw, fslmc, tbsvc, and typec as they don't exist = here=0A Add of to avoid backporting two larger patches]=0ASigned-off-by= : Nathan Chancellor =0A---=0A scripts/mod/file2al= ias.c | 136 +++++++++++++--------------------------=0A 1 file changed, 45 i= nsertions(+), 91 deletions(-)=0A=0Adiff --git a/scripts/mod/file2alias.c b/= scripts/mod/file2alias.c=0Aindex 9f5cdd49ff0b..d0b164084225 100644=0A--- a/= scripts/mod/file2alias.c=0A+++ b/scripts/mod/file2alias.c=0A@@ -50,46 +50,6= @@ struct devtable {=0A void *function;=0A };=0A =0A-#define ___cat(a,b) = a ## b=0A-#define __cat(a,b) ___cat(a,b)=0A-=0A-/* we need some special han= dling for this host tool running eventually on=0A- * Darwin. The Mach-O sec= tion handling is a bit different than ELF section=0A- * handling. The diffe= rnces in detail are:=0A- * a) we have segments which have sections=0A- * = b) we need a API call to get the respective section symbols */=0A-#if defin= ed(__MACH__)=0A-#include =0A-=0A-#define INIT_SECTION(nam= e) do { \=0A- unsigned long name ## _len; \=0A- char *__cat(pstar= t_,name) =3D getsectdata("__TEXT", \=0A- #name, &__cat(name,_len)); \= =0A- char *__cat(pstop_,name) =3D __cat(pstart_,name) + \=0A- __cat(name= , _len); \=0A- __cat(__start_,name) =3D (void *)__cat(pstart_,name); \= =0A- __cat(__stop_,name) =3D (void *)__cat(pstop_,name); \=0A- } while (0)= =0A-#define SECTION(name) __attribute__((section("__TEXT, " #name)))=0A-= =0A-struct devtable **__start___devtable, **__stop___devtable;=0A-#else=0A-= #define INIT_SECTION(name) /* no-op for ELF */=0A-#define SECTION(name) _= _attribute__((section(#name)))=0A-=0A-/* We construct a table of pointers i= n an ELF section (pointers generally=0A- * go unpadded by gcc). ld creates= boundary syms for us. */=0A-extern struct devtable *__start___devtable[], = *__stop___devtable[];=0A-#endif /* __MACH__ */=0A-=0A-#if !defined(__used)= =0A-# if __GNUC__ =3D=3D 3 && __GNUC_MINOR__ < 3=0A-# define __used __at= tribute__((__unused__))=0A-# else=0A-# define __used __attribute__((__us= ed__))=0A-# endif=0A-#endif=0A-=0A /* Define a variable f that holds the va= lue of field f of struct devid=0A * based at address m.=0A */=0A@@ -102,1= 6 +62,6 @@ extern struct devtable *__start___devtable[], *__stop___devtable= [];=0A #define DEF_FIELD_ADDR(m, devid, f) \=0A typeof(((struct devid *)0)= ->f) *f =3D ((m) + OFF_##devid##_##f)=0A =0A-/* Add a table entry. We test= function type matches while we're here. */=0A-#define ADD_TO_DEVTABLE(devi= ce_id, type, function) \=0A- static struct devtable __cat(devtable,__LINE__= ) =3D { \=0A- device_id + 0*sizeof((function)((const char *)NULL, \=0A- = (void *)NULL, \=0A- (char *)NULL)), \=0A- SIZE_##type, (function= ) }; \=0A- static struct devtable *SECTION(__devtable) __used \=0A- __c= at(devtable_ptr,__LINE__) =3D &__cat(devtable,__LINE__)=0A-=0A #define ADD(= str, sep, cond, field) \=0A do { = \=0A strcat(str, sep)= ; \=0A@@ -388,7 +338,6 @@ static int = do_hid_entry(const char *filename,=0A =0A return 1;=0A }=0A-ADD_TO_DEVTABL= E("hid", hid_device_id, do_hid_entry);=0A =0A /* Looks like: ieee1394:venNm= oNspNverN */=0A static int do_ieee1394_entry(const char *filename,=0A@@ -41= 3,7 +362,6 @@ static int do_ieee1394_entry(const char *filename,=0A add_wi= ldcard(alias);=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("ieee1394", ieee1394_d= evice_id, do_ieee1394_entry);=0A =0A /* Looks like: pci:vNdNsvNsdNbcNscNiN.= */=0A static int do_pci_entry(const char *filename,=0A@@ -457,7 +405,6 @@ = static int do_pci_entry(const char *filename,=0A add_wildcard(alias);=0A = return 1;=0A }=0A-ADD_TO_DEVTABLE("pci", pci_device_id, do_pci_entry);=0A = =0A /* looks like: "ccw:tNmNdtNdmN" */=0A static int do_ccw_entry(const cha= r *filename,=0A@@ -481,7 +428,6 @@ static int do_ccw_entry(const char *file= name,=0A add_wildcard(alias);=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("ccw",= ccw_device_id, do_ccw_entry);=0A =0A /* looks like: "ap:tN" */=0A static i= nt do_ap_entry(const char *filename,=0A@@ -492,7 +438,6 @@ static int do_ap= _entry(const char *filename,=0A sprintf(alias, "ap:t%02X*", dev_type);=0A = return 1;=0A }=0A-ADD_TO_DEVTABLE("ap", ap_device_id, do_ap_entry);=0A =0A= /* looks like: "css:tN" */=0A static int do_css_entry(const char *filename= ,=0A@@ -503,7 +448,6 @@ static int do_css_entry(const char *filename,=0A s= printf(alias, "css:t%01X", type);=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("cs= s", css_device_id, do_css_entry);=0A =0A /* Looks like: "serio:tyNprNidNexN= " */=0A static int do_serio_entry(const char *filename,=0A@@ -523,7 +467,6 = @@ static int do_serio_entry(const char *filename,=0A add_wildcard(alias);= =0A return 1;=0A }=0A-ADD_TO_DEVTABLE("serio", serio_device_id, do_serio_e= ntry);=0A =0A /* looks like: "acpi:ACPI0003" or "acpi:PNP0C0B" or "acpi:LNX= VIDEO" or=0A * "acpi:bbsspp" (bb=3Dbase-class, ss=3Dsub-class,= pp=3Dprog-if)=0A@@ -561,7 +504,6 @@ static int do_acpi_entry(const char *f= ilename,=0A }=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("acpi", acpi_device_id= , do_acpi_entry);=0A =0A /* looks like: "pnp:dD" */=0A static void do_pnp_d= evice_entry(void *symval, unsigned long size,=0A@@ -682,7 +624,6 @@ static = int do_pcmcia_entry(const char *filename,=0A add_wildcard(alias);=0A retu= rn 1;=0A }=0A-ADD_TO_DEVTABLE("pcmcia", pcmcia_device_id, do_pcmcia_entry);= =0A =0A static int do_of_entry (const char *filename, void *symval, char *a= lias)=0A {=0A@@ -707,7 +648,6 @@ static int do_of_entry (const char *filena= me, void *symval, char *alias)=0A add_wildcard(alias);=0A return 1;=0A }= =0A-ADD_TO_DEVTABLE("of", of_device_id, do_of_entry);=0A =0A static int do_= vio_entry(const char *filename, void *symval,=0A char *alias)=0A@@ -727,7= +667,6 @@ static int do_vio_entry(const char *filename, void *symval,=0A = add_wildcard(alias);=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("vio", vio_devic= e_id, do_vio_entry);=0A =0A #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0= ]))=0A =0A@@ -800,7 +739,6 @@ static int do_input_entry(const char *filenam= e, void *symval,=0A do_input(alias, *swbit, 0, INPUT_DEVICE_ID_SW_MAX);= =0A return 1;=0A }=0A-ADD_TO_DEVTABLE("input", input_device_id, do_input_e= ntry);=0A =0A static int do_eisa_entry(const char *filename, void *symval,= =0A char *alias)=0A@@ -812,7 +750,6 @@ static int do_eisa_entry(const cha= r *filename, void *symval,=0A strcat(alias, "*");=0A return 1;=0A }=0A-A= DD_TO_DEVTABLE("eisa", eisa_device_id, do_eisa_entry);=0A =0A /* Looks like= : parisc:tNhvNrevNsvN */=0A static int do_parisc_entry(const char *filename= , void *symval,=0A@@ -832,7 +769,6 @@ static int do_parisc_entry(const char= *filename, void *symval,=0A add_wildcard(alias);=0A return 1;=0A }=0A-AD= D_TO_DEVTABLE("parisc", parisc_device_id, do_parisc_entry);=0A =0A /* Looks= like: sdio:cNvNdN. */=0A static int do_sdio_entry(const char *filename,=0A= @@ -849,7 +785,6 @@ static int do_sdio_entry(const char *filename,=0A add_= wildcard(alias);=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("sdio", sdio_device_= id, do_sdio_entry);=0A =0A /* Looks like: ssb:vNidNrevN. */=0A static int d= o_ssb_entry(const char *filename,=0A@@ -866,7 +801,6 @@ static int do_ssb_e= ntry(const char *filename,=0A add_wildcard(alias);=0A return 1;=0A }=0A-A= DD_TO_DEVTABLE("ssb", ssb_device_id, do_ssb_entry);=0A =0A /* Looks like: b= cma:mNidNrevNclN. */=0A static int do_bcma_entry(const char *filename,=0A@@= -885,7 +819,6 @@ static int do_bcma_entry(const char *filename,=0A add_wi= ldcard(alias);=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("bcma", bcma_device_id= , do_bcma_entry);=0A =0A /* Looks like: virtio:dNvN */=0A static int do_vir= tio_entry(const char *filename, void *symval,=0A@@ -901,7 +834,6 @@ static = int do_virtio_entry(const char *filename, void *symval,=0A add_wildcard(al= ias);=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("virtio", virtio_device_id, do_= virtio_entry);=0A =0A /*=0A * Looks like: vmbus:guid=0A@@ -924,7 +856,6 @@= static int do_vmbus_entry(const char *filename, void *symval,=0A =0A retu= rn 1;=0A }=0A-ADD_TO_DEVTABLE("vmbus", hv_vmbus_device_id, do_vmbus_entry);= =0A =0A /* Looks like: i2c:S */=0A static int do_i2c_entry(const char *file= name, void *symval,=0A@@ -935,7 +866,6 @@ static int do_i2c_entry(const cha= r *filename, void *symval,=0A =0A return 1;=0A }=0A-ADD_TO_DEVTABLE("i2c",= i2c_device_id, do_i2c_entry);=0A =0A /* Looks like: spi:S */=0A static int= do_spi_entry(const char *filename, void *symval,=0A@@ -946,7 +876,6 @@ sta= tic int do_spi_entry(const char *filename, void *symval,=0A =0A return 1;= =0A }=0A-ADD_TO_DEVTABLE("spi", spi_device_id, do_spi_entry);=0A =0A static= const struct dmifield {=0A const char *prefix;=0A@@ -1001,7 +930,6 @@ sta= tic int do_dmi_entry(const char *filename, void *symval,=0A strcat(alias, = ":");=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("dmi", dmi_system_id, do_dmi_en= try);=0A =0A static int do_platform_entry(const char *filename,=0A = void *symval, char *alias)=0A@@ -1010,7 +938,6 @@ static int do_platform_en= try(const char *filename,=0A sprintf(alias, PLATFORM_MODULE_PREFIX "%s", *= name);=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("platform", platform_device_id= , do_platform_entry);=0A =0A static int do_mdio_entry(const char *filename,= =0A void *symval, char *alias)=0A@@ -1035,7 +962,6 @@ static int do_mdi= o_entry(const char *filename,=0A =0A return 1;=0A }=0A-ADD_TO_DEVTABLE("md= io", mdio_device_id, do_mdio_entry);=0A =0A /* Looks like: zorro:iN. */=0A = static int do_zorro_entry(const char *filename, void *symval,=0A@@ -1046,7 = +972,6 @@ static int do_zorro_entry(const char *filename, void *symval,=0A = ADD(alias, "i", id !=3D ZORRO_WILDCARD, id);=0A return 1;=0A }=0A-ADD_TO_= DEVTABLE("zorro", zorro_device_id, do_zorro_entry);=0A =0A /* looks like: "= pnp:dD" */=0A static int do_isapnp_entry(const char *filename,=0A@@ -1062,7= +987,6 @@ static int do_isapnp_entry(const char *filename,=0A (function = >> 12) & 0x0f, (function >> 8) & 0x0f);=0A return 1;=0A }=0A-ADD_TO_DEVTAB= LE("isapnp", isapnp_device_id, do_isapnp_entry);=0A =0A /* Looks like: "ipa= ck:fNvNdN". */=0A static int do_ipack_entry(const char *filename,=0A@@ -107= 8,7 +1002,6 @@ static int do_ipack_entry(const char *filename,=0A add_wild= card(alias);=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("ipack", ipack_device_id= , do_ipack_entry);=0A =0A /*=0A * Append a match expression for a single m= asked hex digit.=0A@@ -1149,7 +1072,6 @@ static int do_amba_entry(const cha= r *filename,=0A =0A return 1;=0A }=0A-ADD_TO_DEVTABLE("amba", amba_id, do_= amba_entry);=0A =0A /*=0A * looks like: "mipscdmm:tN"=0A@@ -1165,7 +1087,6= @@ static int do_mips_cdmm_entry(const char *filename,=0A sprintf(alias, = "mipscdmm:t%02X*", type);=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("mipscdmm",= mips_cdmm_device_id, do_mips_cdmm_entry);=0A =0A /* LOOKS like cpu:type:x8= 6,venVVVVfamFFFFmodMMMM:feature:*,FEAT,*=0A * All fields are numbers. It w= ould be nicer to use strings for vendor=0A@@ -1190,7 +1111,6 @@ static int = do_x86cpu_entry(const char *filename, void *symval,=0A sprintf(alias + st= rlen(alias), "%04X*", feature);=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("x86c= pu", x86_cpu_id, do_x86cpu_entry);=0A =0A /* LOOKS like cpu:type:*:feature:= *FEAT* */=0A static int do_cpu_entry(const char *filename, void *symval, ch= ar *alias)=0A@@ -1200,7 +1120,6 @@ static int do_cpu_entry(const char *file= name, void *symval, char *alias)=0A sprintf(alias, "cpu:type:*:feature:*%0= 4X*", feature);=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("cpu", cpu_feature, d= o_cpu_entry);=0A =0A /* Looks like: mei:S:uuid:N:* */=0A static int do_mei_= entry(const char *filename, void *symval,=0A@@ -1219,7 +1138,6 @@ static in= t do_mei_entry(const char *filename, void *symval,=0A =0A return 1;=0A }= =0A-ADD_TO_DEVTABLE("mei", mei_cl_device_id, do_mei_entry);=0A =0A /* Looks= like: rapidio:vNdNavNadN */=0A static int do_rio_entry(const char *filenam= e,=0A@@ -1239,7 +1157,6 @@ static int do_rio_entry(const char *filename,=0A= add_wildcard(alias);=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("rapidio", rio= _device_id, do_rio_entry);=0A =0A /* Looks like: ulpi:vNpN */=0A static int= do_ulpi_entry(const char *filename, void *symval,=0A@@ -1252,7 +1169,6 @@ = static int do_ulpi_entry(const char *filename, void *symval,=0A =0A return= 1;=0A }=0A-ADD_TO_DEVTABLE("ulpi", ulpi_device_id, do_ulpi_entry);=0A =0A = /* Looks like: hdaudio:vNrNaN */=0A static int do_hda_entry(const char *fil= ename, void *symval, char *alias)=0A@@ -1269,7 +1185,6 @@ static int do_hda= _entry(const char *filename, void *symval, char *alias)=0A add_wildcard(al= ias);=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("hdaudio", hda_device_id, do_hd= a_entry);=0A =0A /* Does namelen bytes of name exactly match the symbol? */= =0A static bool sym_is(const char *name, unsigned namelen, const char *symb= ol)=0A@@ -1302,6 +1217,44 @@ static void do_table(void *symval, unsigned lo= ng size,=0A }=0A }=0A =0A+static const struct devtable devtable[] =3D {=0A= + {"hid", SIZE_hid_device_id, do_hid_entry},=0A+ {"ieee1394", SIZE_ieee1394= _device_id, do_ieee1394_entry},=0A+ {"pci", SIZE_pci_device_id, do_pci_entr= y},=0A+ {"ccw", SIZE_ccw_device_id, do_ccw_entry},=0A+ {"ap", SIZE_ap_devic= e_id, do_ap_entry},=0A+ {"css", SIZE_css_device_id, do_css_entry},=0A+ {"se= rio", SIZE_serio_device_id, do_serio_entry},=0A+ {"acpi", SIZE_acpi_device_= id, do_acpi_entry},=0A+ {"pcmcia", SIZE_pcmcia_device_id, do_pcmcia_entry},= =0A+ {"vio", SIZE_vio_device_id, do_vio_entry},=0A+ {"input", SIZE_input_de= vice_id, do_input_entry},=0A+ {"eisa", SIZE_eisa_device_id, do_eisa_entry},= =0A+ {"parisc", SIZE_parisc_device_id, do_parisc_entry},=0A+ {"sdio", SIZE_= sdio_device_id, do_sdio_entry},=0A+ {"ssb", SIZE_ssb_device_id, do_ssb_entr= y},=0A+ {"bcma", SIZE_bcma_device_id, do_bcma_entry},=0A+ {"virtio", SIZE_v= irtio_device_id, do_virtio_entry},=0A+ {"vmbus", SIZE_hv_vmbus_device_id, d= o_vmbus_entry},=0A+ {"i2c", SIZE_i2c_device_id, do_i2c_entry},=0A+ {"spi", = SIZE_spi_device_id, do_spi_entry},=0A+ {"dmi", SIZE_dmi_system_id, do_dmi_e= ntry},=0A+ {"platform", SIZE_platform_device_id, do_platform_entry},=0A+ {"= mdio", SIZE_mdio_device_id, do_mdio_entry},=0A+ {"zorro", SIZE_zorro_device= _id, do_zorro_entry},=0A+ {"isapnp", SIZE_isapnp_device_id, do_isapnp_entry= },=0A+ {"ipack", SIZE_ipack_device_id, do_ipack_entry},=0A+ {"amba", SIZE_a= mba_id, do_amba_entry},=0A+ {"mipscdmm", SIZE_mips_cdmm_device_id, do_mips_= cdmm_entry},=0A+ {"x86cpu", SIZE_x86_cpu_id, do_x86cpu_entry},=0A+ {"cpu", = SIZE_cpu_feature, do_cpu_entry},=0A+ {"mei", SIZE_mei_cl_device_id, do_mei_= entry},=0A+ {"rapidio", SIZE_rio_device_id, do_rio_entry},=0A+ {"ulpi", SIZ= E_ulpi_device_id, do_ulpi_entry},=0A+ {"hdaudio", SIZE_hda_device_id, do_hd= a_entry},=0A+ {"of", SIZE_of_device_id, do_of_entry},=0A+};=0A+=0A /* Creat= e MODULE_ALIAS() statements.=0A * At this time, we cannot write the actual= output C source yet,=0A * so we write into the mod->dev_table_buf buffer.= */=0A@@ -1354,13 +1307,14 @@ void handle_moddevtable(struct module *mod, s= truct elf_info *info,=0A else if (sym_is(name, namelen, "pnp_card"))=0A = do_pnp_card_entries(symval, sym->st_size, mod);=0A else {=0A- struct devt= able **p;=0A- INIT_SECTION(__devtable);=0A+ int i;=0A+=0A+ for (i =3D 0;= i < ARRAY_SIZE(devtable); i++) {=0A+ const struct devtable *p =3D &devta= ble[i];=0A =0A- for (p =3D __start___devtable; p < __stop___devtable; p++)= {=0A- if (sym_is(name, namelen, (*p)->device_id)) {=0A- do_table(symv= al, sym->st_size, (*p)->id_size,=0A- (*p)->device_id, (*p)->function, = mod);=0A+ if (sym_is(name, namelen, p->device_id)) {=0A+ do_table(symv= al, sym->st_size, p->id_size,=0A+ p->device_id, p->function, mod);=0A = break;=0A }=0A }=0A-- =0A2.21.0=0A=0A=0AFrom c6083d85692c3fb843cf2= 8ece9df62245dfca15c Mon Sep 17 00:00:00 2001=0AFrom: Masahiro Yamada =0ADate: Thu, 22 Nov 2018 13:28:42 +0900=0ASubject= : [PATCH 4.4 2/2] modpost: file2alias: check prototype of handler=0A=0Acomm= it f880eea68fe593342fa6e09be9bb661f3c297aec upstream.=0A=0AUse specific pro= totype instead of an opaque pointer so that the=0Acompiler can catch functi= on prototype mismatch.=0A=0ASigned-off-by: Masahiro Yamada =0AReviewed-by: Mathieu Malaterre =0ASigne= d-off-by: Nathan Chancellor =0A---=0A scripts/mod= /file2alias.c | 7 +++----=0A 1 file changed, 3 insertions(+), 4 deletions(-= )=0A=0Adiff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c=0Ai= ndex d0b164084225..4250d3d6f391 100644=0A--- a/scripts/mod/file2alias.c=0A+= ++ b/scripts/mod/file2alias.c=0A@@ -47,7 +47,7 @@ typedef struct {=0A struc= t devtable {=0A const char *device_id; /* name of table, __mod___*_d= evice_table. */=0A unsigned long id_size;=0A- void *function;=0A+ int (*do= _entry)(const char *filename, void *symval, char *alias);=0A };=0A =0A /* D= efine a variable f that holds the value of field f of struct devid=0A@@ -11= 98,12 +1198,11 @@ static bool sym_is(const char *name, unsigned namelen, co= nst char *symbol)=0A static void do_table(void *symval, unsigned long size,= =0A unsigned long id_size,=0A const char *device_id,=0A- = void *function,=0A+ int (*do_entry)(const char *filename, void *sym= val, char *alias),=0A struct module *mod)=0A {=0A unsigned int i;= =0A char alias[500];=0A- int (*do_entry)(const char *, void *entry, char *= alias) =3D function;=0A =0A device_id_check(mod->name, device_id, size, id= _size, symval);=0A /* Leave last one: it's the terminator. */=0A@@ -1314,7= +1313,7 @@ void handle_moddevtable(struct module *mod, struct elf_info *in= fo,=0A =0A if (sym_is(name, namelen, p->device_id)) {=0A do_table(sy= mval, sym->st_size, p->id_size,=0A- p->device_id, p->function, mod);= =0A+ p->device_id, p->do_entry, mod);=0A break;=0A }=0A }=0A-= - =0A2.21.0=0A=0A --4Ckj6UjgE2iN1+kY Content-Type: application/mbox Content-Disposition: attachment; filename="4.9.mbox" Content-Transfer-Encoding: quoted-printable =46rom 54b1993289dd423550bfe1c44d7c03d87c8cd50a Mon Sep 17 00:00:00 2001=0A= =46rom: Masahiro Yamada =0ADate: Thu, 22 Nov= 2018 13:28:41 +0900=0ASubject: [PATCH 4.9 1/2] modpost: file2alias: go bac= k to simple devtable=0A lookup=0A=0Acommit ec91e78d378cc5d4b43805a1227d8e04= e5dfa17d upstream.=0A=0ACommit e49ce14150c6 ("modpost: use linker section t= o generate table.")=0Awas not so cool as we had expected first; it ended up= with ugly section=0Ahacks when commit dd2a3acaecd7 ("mod/file2alias: make = modpost compile=0Aon darwin again") came in.=0A=0AGiven a certain degree of= unknowledge about the link stage of host=0Aprograms, I really want to see = simple, stupid table lookup so that=0Athis works in the same way regardless= of the underlying executable=0Aformat.=0A=0ASigned-off-by: Masahiro Yamada= =0AAcked-by: Mathieu Malaterre =0A[nc: Omit rpmsg, sdw, tbsvc, and typec as they don't exist here]= =0ASigned-off-by: Nathan Chancellor =0A---=0A scr= ipts/mod/file2alias.c | 136 +++++++++++++--------------------------=0A 1 fi= le changed, 45 insertions(+), 91 deletions(-)=0A=0Adiff --git a/scripts/mod= /file2alias.c b/scripts/mod/file2alias.c=0Aindex 29d6699d5a06..6e3ae94cf123= 100644=0A--- a/scripts/mod/file2alias.c=0A+++ b/scripts/mod/file2alias.c= =0A@@ -50,46 +50,6 @@ struct devtable {=0A void *function;=0A };=0A =0A-#d= efine ___cat(a,b) a ## b=0A-#define __cat(a,b) ___cat(a,b)=0A-=0A-/* we nee= d some special handling for this host tool running eventually on=0A- * Darw= in. The Mach-O section handling is a bit different than ELF section=0A- * h= andling. The differnces in detail are:=0A- * a) we have segments which hav= e sections=0A- * b) we need a API call to get the respective section symbo= ls */=0A-#if defined(__MACH__)=0A-#include =0A-=0A-#defin= e INIT_SECTION(name) do { \=0A- unsigned long name ## _len; \=0A- = char *__cat(pstart_,name) =3D getsectdata("__TEXT", \=0A- #name, &__cat(= name,_len)); \=0A- char *__cat(pstop_,name) =3D __cat(pstart_,name) + \= =0A- __cat(name, _len); \=0A- __cat(__start_,name) =3D (void *)__cat(= pstart_,name); \=0A- __cat(__stop_,name) =3D (void *)__cat(pstop_,name); \= =0A- } while (0)=0A-#define SECTION(name) __attribute__((section("__TEXT,= " #name)))=0A-=0A-struct devtable **__start___devtable, **__stop___devtabl= e;=0A-#else=0A-#define INIT_SECTION(name) /* no-op for ELF */=0A-#define SE= CTION(name) __attribute__((section(#name)))=0A-=0A-/* We construct a tabl= e of pointers in an ELF section (pointers generally=0A- * go unpadded by gc= c). ld creates boundary syms for us. */=0A-extern struct devtable *__start= ___devtable[], *__stop___devtable[];=0A-#endif /* __MACH__ */=0A-=0A-#if !d= efined(__used)=0A-# if __GNUC__ =3D=3D 3 && __GNUC_MINOR__ < 3=0A-# define= __used __attribute__((__unused__))=0A-# else=0A-# define __used __att= ribute__((__used__))=0A-# endif=0A-#endif=0A-=0A /* Define a variable f tha= t holds the value of field f of struct devid=0A * based at address m.=0A = */=0A@@ -102,16 +62,6 @@ extern struct devtable *__start___devtable[], *__s= top___devtable[];=0A #define DEF_FIELD_ADDR(m, devid, f) \=0A typeof(((str= uct devid *)0)->f) *f =3D ((m) + OFF_##devid##_##f)=0A =0A-/* Add a table e= ntry. We test function type matches while we're here. */=0A-#define ADD_TO= _DEVTABLE(device_id, type, function) \=0A- static struct devtable __cat(dev= table,__LINE__) =3D { \=0A- device_id + 0*sizeof((function)((const char *)= NULL, \=0A- (void *)NULL, \=0A- (char *)NULL)), \=0A- SIZE_##t= ype, (function) }; \=0A- static struct devtable *SECTION(__devtable) __u= sed \=0A- __cat(devtable_ptr,__LINE__) =3D &__cat(devtable,__LINE__)=0A-= =0A #define ADD(str, sep, cond, field) \=0A do= { \=0A = strcat(str, sep); \=0A@@ -431,7 +381,= 6 @@ static int do_hid_entry(const char *filename,=0A =0A return 1;=0A }= =0A-ADD_TO_DEVTABLE("hid", hid_device_id, do_hid_entry);=0A =0A /* Looks li= ke: ieee1394:venNmoNspNverN */=0A static int do_ieee1394_entry(const char *= filename,=0A@@ -456,7 +405,6 @@ static int do_ieee1394_entry(const char *fi= lename,=0A add_wildcard(alias);=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("iee= e1394", ieee1394_device_id, do_ieee1394_entry);=0A =0A /* Looks like: pci:v= NdNsvNsdNbcNscNiN. */=0A static int do_pci_entry(const char *filename,=0A@@= -500,7 +448,6 @@ static int do_pci_entry(const char *filename,=0A add_wil= dcard(alias);=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("pci", pci_device_id, d= o_pci_entry);=0A =0A /* looks like: "ccw:tNmNdtNdmN" */=0A static int do_cc= w_entry(const char *filename,=0A@@ -524,7 +471,6 @@ static int do_ccw_entry= (const char *filename,=0A add_wildcard(alias);=0A return 1;=0A }=0A-ADD_T= O_DEVTABLE("ccw", ccw_device_id, do_ccw_entry);=0A =0A /* looks like: "ap:t= N" */=0A static int do_ap_entry(const char *filename,=0A@@ -535,7 +481,6 @@= static int do_ap_entry(const char *filename,=0A sprintf(alias, "ap:t%02X*= ", dev_type);=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("ap", ap_device_id, do_= ap_entry);=0A =0A /* looks like: "css:tN" */=0A static int do_css_entry(con= st char *filename,=0A@@ -546,7 +491,6 @@ static int do_css_entry(const char= *filename,=0A sprintf(alias, "css:t%01X", type);=0A return 1;=0A }=0A-AD= D_TO_DEVTABLE("css", css_device_id, do_css_entry);=0A =0A /* Looks like: "s= erio:tyNprNidNexN" */=0A static int do_serio_entry(const char *filename,=0A= @@ -566,7 +510,6 @@ static int do_serio_entry(const char *filename,=0A add= _wildcard(alias);=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("serio", serio_devi= ce_id, do_serio_entry);=0A =0A /* looks like: "acpi:ACPI0003" or "acpi:PNP0= C0B" or "acpi:LNXVIDEO" or=0A * "acpi:bbsspp" (bb=3Dbase-class= , ss=3Dsub-class, pp=3Dprog-if)=0A@@ -604,7 +547,6 @@ static int do_acpi_en= try(const char *filename,=0A }=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("acpi= ", acpi_device_id, do_acpi_entry);=0A =0A /* looks like: "pnp:dD" */=0A sta= tic void do_pnp_device_entry(void *symval, unsigned long size,=0A@@ -725,7 = +667,6 @@ static int do_pcmcia_entry(const char *filename,=0A add_wildcard= (alias);=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("pcmcia", pcmcia_device_id, = do_pcmcia_entry);=0A =0A static int do_vio_entry(const char *filename, void= *symval,=0A char *alias)=0A@@ -745,7 +686,6 @@ static int do_vio_entry(c= onst char *filename, void *symval,=0A add_wildcard(alias);=0A return 1;= =0A }=0A-ADD_TO_DEVTABLE("vio", vio_device_id, do_vio_entry);=0A =0A #defin= e ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))=0A =0A@@ -818,7 +758,6 @@ stat= ic int do_input_entry(const char *filename, void *symval,=0A do_input(ali= as, *swbit, 0, INPUT_DEVICE_ID_SW_MAX);=0A return 1;=0A }=0A-ADD_TO_DEVTAB= LE("input", input_device_id, do_input_entry);=0A =0A static int do_eisa_ent= ry(const char *filename, void *symval,=0A char *alias)=0A@@ -830,7 +769,6= @@ static int do_eisa_entry(const char *filename, void *symval,=0A strca= t(alias, "*");=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("eisa", eisa_device_id= , do_eisa_entry);=0A =0A /* Looks like: parisc:tNhvNrevNsvN */=0A static in= t do_parisc_entry(const char *filename, void *symval,=0A@@ -850,7 +788,6 @@= static int do_parisc_entry(const char *filename, void *symval,=0A add_wil= dcard(alias);=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("parisc", parisc_device= _id, do_parisc_entry);=0A =0A /* Looks like: sdio:cNvNdN. */=0A static int = do_sdio_entry(const char *filename,=0A@@ -867,7 +804,6 @@ static int do_sdi= o_entry(const char *filename,=0A add_wildcard(alias);=0A return 1;=0A }= =0A-ADD_TO_DEVTABLE("sdio", sdio_device_id, do_sdio_entry);=0A =0A /* Looks= like: ssb:vNidNrevN. */=0A static int do_ssb_entry(const char *filename,= =0A@@ -884,7 +820,6 @@ static int do_ssb_entry(const char *filename,=0A ad= d_wildcard(alias);=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("ssb", ssb_device_= id, do_ssb_entry);=0A =0A /* Looks like: bcma:mNidNrevNclN. */=0A static in= t do_bcma_entry(const char *filename,=0A@@ -903,7 +838,6 @@ static int do_b= cma_entry(const char *filename,=0A add_wildcard(alias);=0A return 1;=0A }= =0A-ADD_TO_DEVTABLE("bcma", bcma_device_id, do_bcma_entry);=0A =0A /* Looks= like: virtio:dNvN */=0A static int do_virtio_entry(const char *filename, v= oid *symval,=0A@@ -919,7 +853,6 @@ static int do_virtio_entry(const char *f= ilename, void *symval,=0A add_wildcard(alias);=0A return 1;=0A }=0A-ADD_T= O_DEVTABLE("virtio", virtio_device_id, do_virtio_entry);=0A =0A /*=0A * Lo= oks like: vmbus:guid=0A@@ -942,7 +875,6 @@ static int do_vmbus_entry(const = char *filename, void *symval,=0A =0A return 1;=0A }=0A-ADD_TO_DEVTABLE("vm= bus", hv_vmbus_device_id, do_vmbus_entry);=0A =0A /* Looks like: i2c:S */= =0A static int do_i2c_entry(const char *filename, void *symval,=0A@@ -953,7= +885,6 @@ static int do_i2c_entry(const char *filename, void *symval,=0A = =0A return 1;=0A }=0A-ADD_TO_DEVTABLE("i2c", i2c_device_id, do_i2c_entry);= =0A =0A /* Looks like: spi:S */=0A static int do_spi_entry(const char *file= name, void *symval,=0A@@ -964,7 +895,6 @@ static int do_spi_entry(const cha= r *filename, void *symval,=0A =0A return 1;=0A }=0A-ADD_TO_DEVTABLE("spi",= spi_device_id, do_spi_entry);=0A =0A static const struct dmifield {=0A co= nst char *prefix;=0A@@ -1019,7 +949,6 @@ static int do_dmi_entry(const char= *filename, void *symval,=0A strcat(alias, ":");=0A return 1;=0A }=0A-ADD= _TO_DEVTABLE("dmi", dmi_system_id, do_dmi_entry);=0A =0A static int do_plat= form_entry(const char *filename,=0A void *symval, char *alias)=0A@@= -1028,7 +957,6 @@ static int do_platform_entry(const char *filename,=0A s= printf(alias, PLATFORM_MODULE_PREFIX "%s", *name);=0A return 1;=0A }=0A-AD= D_TO_DEVTABLE("platform", platform_device_id, do_platform_entry);=0A =0A st= atic int do_mdio_entry(const char *filename,=0A void *symval, char *ali= as)=0A@@ -1053,7 +981,6 @@ static int do_mdio_entry(const char *filename,= =0A =0A return 1;=0A }=0A-ADD_TO_DEVTABLE("mdio", mdio_device_id, do_mdio_= entry);=0A =0A /* Looks like: zorro:iN. */=0A static int do_zorro_entry(con= st char *filename, void *symval,=0A@@ -1064,7 +991,6 @@ static int do_zorro= _entry(const char *filename, void *symval,=0A ADD(alias, "i", id !=3D ZORR= O_WILDCARD, id);=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("zorro", zorro_devic= e_id, do_zorro_entry);=0A =0A /* looks like: "pnp:dD" */=0A static int do_i= sapnp_entry(const char *filename,=0A@@ -1080,7 +1006,6 @@ static int do_isa= pnp_entry(const char *filename,=0A (function >> 12) & 0x0f, (function >> = 8) & 0x0f);=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("isapnp", isapnp_device_i= d, do_isapnp_entry);=0A =0A /* Looks like: "ipack:fNvNdN". */=0A static int= do_ipack_entry(const char *filename,=0A@@ -1096,7 +1021,6 @@ static int do= _ipack_entry(const char *filename,=0A add_wildcard(alias);=0A return 1;= =0A }=0A-ADD_TO_DEVTABLE("ipack", ipack_device_id, do_ipack_entry);=0A =0A = /*=0A * Append a match expression for a single masked hex digit.=0A@@ -116= 7,7 +1091,6 @@ static int do_amba_entry(const char *filename,=0A =0A retur= n 1;=0A }=0A-ADD_TO_DEVTABLE("amba", amba_id, do_amba_entry);=0A =0A /*=0A = * looks like: "mipscdmm:tN"=0A@@ -1183,7 +1106,6 @@ static int do_mips_cdm= m_entry(const char *filename,=0A sprintf(alias, "mipscdmm:t%02X*", type);= =0A return 1;=0A }=0A-ADD_TO_DEVTABLE("mipscdmm", mips_cdmm_device_id, do_= mips_cdmm_entry);=0A =0A /* LOOKS like cpu:type:x86,venVVVVfamFFFFmodMMMM:f= eature:*,FEAT,*=0A * All fields are numbers. It would be nicer to use stri= ngs for vendor=0A@@ -1208,7 +1130,6 @@ static int do_x86cpu_entry(const cha= r *filename, void *symval,=0A sprintf(alias + strlen(alias), "%04X*", fea= ture);=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("x86cpu", x86_cpu_id, do_x86cp= u_entry);=0A =0A /* LOOKS like cpu:type:*:feature:*FEAT* */=0A static int d= o_cpu_entry(const char *filename, void *symval, char *alias)=0A@@ -1218,7 += 1139,6 @@ static int do_cpu_entry(const char *filename, void *symval, char = *alias)=0A sprintf(alias, "cpu:type:*:feature:*%04X*", feature);=0A retur= n 1;=0A }=0A-ADD_TO_DEVTABLE("cpu", cpu_feature, do_cpu_entry);=0A =0A /* L= ooks like: mei:S:uuid:N:* */=0A static int do_mei_entry(const char *filenam= e, void *symval,=0A@@ -1237,7 +1157,6 @@ static int do_mei_entry(const char= *filename, void *symval,=0A =0A return 1;=0A }=0A-ADD_TO_DEVTABLE("mei", = mei_cl_device_id, do_mei_entry);=0A =0A /* Looks like: rapidio:vNdNavNadN *= /=0A static int do_rio_entry(const char *filename,=0A@@ -1257,7 +1176,6 @@ = static int do_rio_entry(const char *filename,=0A add_wildcard(alias);=0A = return 1;=0A }=0A-ADD_TO_DEVTABLE("rapidio", rio_device_id, do_rio_entry);= =0A =0A /* Looks like: ulpi:vNpN */=0A static int do_ulpi_entry(const char = *filename, void *symval,=0A@@ -1270,7 +1188,6 @@ static int do_ulpi_entry(c= onst char *filename, void *symval,=0A =0A return 1;=0A }=0A-ADD_TO_DEVTABL= E("ulpi", ulpi_device_id, do_ulpi_entry);=0A =0A /* Looks like: hdaudio:vNr= NaN */=0A static int do_hda_entry(const char *filename, void *symval, char = *alias)=0A@@ -1287,7 +1204,6 @@ static int do_hda_entry(const char *filenam= e, void *symval, char *alias)=0A add_wildcard(alias);=0A return 1;=0A }= =0A-ADD_TO_DEVTABLE("hdaudio", hda_device_id, do_hda_entry);=0A =0A /* Look= s like: fsl-mc:vNdN */=0A static int do_fsl_mc_entry(const char *filename, = void *symval,=0A@@ -1299,7 +1215,6 @@ static int do_fsl_mc_entry(const char= *filename, void *symval,=0A sprintf(alias, "fsl-mc:v%08Xd%s", vendor, *ob= j_type);=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("fslmc", fsl_mc_device_id, d= o_fsl_mc_entry);=0A =0A /* Does namelen bytes of name exactly match the sym= bol? */=0A static bool sym_is(const char *name, unsigned namelen, const cha= r *symbol)=0A@@ -1332,6 +1247,44 @@ static void do_table(void *symval, unsi= gned long size,=0A }=0A }=0A =0A+static const struct devtable devtable[] = =3D {=0A+ {"hid", SIZE_hid_device_id, do_hid_entry},=0A+ {"ieee1394", SIZE_= ieee1394_device_id, do_ieee1394_entry},=0A+ {"pci", SIZE_pci_device_id, do_= pci_entry},=0A+ {"ccw", SIZE_ccw_device_id, do_ccw_entry},=0A+ {"ap", SIZE_= ap_device_id, do_ap_entry},=0A+ {"css", SIZE_css_device_id, do_css_entry},= =0A+ {"serio", SIZE_serio_device_id, do_serio_entry},=0A+ {"acpi", SIZE_acp= i_device_id, do_acpi_entry},=0A+ {"pcmcia", SIZE_pcmcia_device_id, do_pcmci= a_entry},=0A+ {"vio", SIZE_vio_device_id, do_vio_entry},=0A+ {"input", SIZE= _input_device_id, do_input_entry},=0A+ {"eisa", SIZE_eisa_device_id, do_eis= a_entry},=0A+ {"parisc", SIZE_parisc_device_id, do_parisc_entry},=0A+ {"sdi= o", SIZE_sdio_device_id, do_sdio_entry},=0A+ {"ssb", SIZE_ssb_device_id, do= _ssb_entry},=0A+ {"bcma", SIZE_bcma_device_id, do_bcma_entry},=0A+ {"virtio= ", SIZE_virtio_device_id, do_virtio_entry},=0A+ {"vmbus", SIZE_hv_vmbus_dev= ice_id, do_vmbus_entry},=0A+ {"i2c", SIZE_i2c_device_id, do_i2c_entry},=0A+= {"spi", SIZE_spi_device_id, do_spi_entry},=0A+ {"dmi", SIZE_dmi_system_id,= do_dmi_entry},=0A+ {"platform", SIZE_platform_device_id, do_platform_entry= },=0A+ {"mdio", SIZE_mdio_device_id, do_mdio_entry},=0A+ {"zorro", SIZE_zor= ro_device_id, do_zorro_entry},=0A+ {"isapnp", SIZE_isapnp_device_id, do_isa= pnp_entry},=0A+ {"ipack", SIZE_ipack_device_id, do_ipack_entry},=0A+ {"amba= ", SIZE_amba_id, do_amba_entry},=0A+ {"mipscdmm", SIZE_mips_cdmm_device_id,= do_mips_cdmm_entry},=0A+ {"x86cpu", SIZE_x86_cpu_id, do_x86cpu_entry},=0A+= {"cpu", SIZE_cpu_feature, do_cpu_entry},=0A+ {"mei", SIZE_mei_cl_device_id= , do_mei_entry},=0A+ {"rapidio", SIZE_rio_device_id, do_rio_entry},=0A+ {"u= lpi", SIZE_ulpi_device_id, do_ulpi_entry},=0A+ {"hdaudio", SIZE_hda_device_= id, do_hda_entry},=0A+ {"fslmc", SIZE_fsl_mc_device_id, do_fsl_mc_entry},= =0A+};=0A+=0A /* Create MODULE_ALIAS() statements.=0A * At this time, we c= annot write the actual output C source yet,=0A * so we write into the mod-= >dev_table_buf buffer. */=0A@@ -1386,13 +1339,14 @@ void handle_moddevtable= (struct module *mod, struct elf_info *info,=0A else if (sym_is(name, namel= en, "pnp_card"))=0A do_pnp_card_entries(symval, sym->st_size, mod);=0A e= lse {=0A- struct devtable **p;=0A- INIT_SECTION(__devtable);=0A+ int i;= =0A+=0A+ for (i =3D 0; i < ARRAY_SIZE(devtable); i++) {=0A+ const struct= devtable *p =3D &devtable[i];=0A =0A- for (p =3D __start___devtable; p < = __stop___devtable; p++) {=0A- if (sym_is(name, namelen, (*p)->device_id))= {=0A- do_table(symval, sym->st_size, (*p)->id_size,=0A- (*p)->devi= ce_id, (*p)->function, mod);=0A+ if (sym_is(name, namelen, p->device_id))= {=0A+ do_table(symval, sym->st_size, p->id_size,=0A+ p->device_id,= p->function, mod);=0A break;=0A }=0A }=0A-- =0A2.21.0=0A=0A=0AFro= m 4dfdd21dc87cb5085f2e4a1f413762ccba18069e Mon Sep 17 00:00:00 2001=0AFrom:= Masahiro Yamada =0ADate: Thu, 22 Nov 2018 1= 3:28:42 +0900=0ASubject: [PATCH 4.9 2/2] modpost: file2alias: check prototy= pe of handler=0A=0Acommit f880eea68fe593342fa6e09be9bb661f3c297aec upstream= =2E=0A=0AUse specific prototype instead of an opaque pointer so that the=0A= compiler can catch function prototype mismatch.=0A=0ASigned-off-by: Masahir= o Yamada =0AReviewed-by: Mathieu Malaterre <= malat@debian.org>=0ASigned-off-by: Nathan Chancellor =0A---=0A scripts/mod/file2alias.c | 7 +++----=0A 1 file changed, 3 ins= ertions(+), 4 deletions(-)=0A=0Adiff --git a/scripts/mod/file2alias.c b/scr= ipts/mod/file2alias.c=0Aindex 6e3ae94cf123..55b4c0dc2b93 100644=0A--- a/scr= ipts/mod/file2alias.c=0A+++ b/scripts/mod/file2alias.c=0A@@ -47,7 +47,7 @@ = typedef struct {=0A struct devtable {=0A const char *device_id; /* name of= table, __mod___*_device_table. */=0A unsigned long id_size;=0A- voi= d *function;=0A+ int (*do_entry)(const char *filename, void *symval, char *= alias);=0A };=0A =0A /* Define a variable f that holds the value of field f= of struct devid=0A@@ -1228,12 +1228,11 @@ static bool sym_is(const char *n= ame, unsigned namelen, const char *symbol)=0A static void do_table(void *sy= mval, unsigned long size,=0A unsigned long id_size,=0A const = char *device_id,=0A- void *function,=0A+ int (*do_entry)(const = char *filename, void *symval, char *alias),=0A struct module *mod)= =0A {=0A unsigned int i;=0A char alias[500];=0A- int (*do_entry)(const ch= ar *, void *entry, char *alias) =3D function;=0A =0A device_id_check(mod->= name, device_id, size, id_size, symval);=0A /* Leave last one: it's the te= rminator. */=0A@@ -1346,7 +1345,7 @@ void handle_moddevtable(struct module = *mod, struct elf_info *info,=0A =0A if (sym_is(name, namelen, p->device_= id)) {=0A do_table(symval, sym->st_size, p->id_size,=0A- p->device= _id, p->function, mod);=0A+ p->device_id, p->do_entry, mod);=0A br= eak;=0A }=0A }=0A-- =0A2.21.0=0A=0A --4Ckj6UjgE2iN1+kY Content-Type: application/mbox Content-Disposition: attachment; filename="4.14.mbox" Content-Transfer-Encoding: quoted-printable =46rom 8b552b4ae3582d3368003680c271a9b12c1a5348 Mon Sep 17 00:00:00 2001=0A= =46rom: Masahiro Yamada =0ADate: Thu, 22 Nov= 2018 13:28:41 +0900=0ASubject: [PATCH 4.14 1/2] modpost: file2alias: go ba= ck to simple devtable=0A lookup=0A=0Acommit ec91e78d378cc5d4b43805a1227d8e0= 4e5dfa17d upstream.=0A=0ACommit e49ce14150c6 ("modpost: use linker section = to generate table.")=0Awas not so cool as we had expected first; it ended u= p with ugly section=0Ahacks when commit dd2a3acaecd7 ("mod/file2alias: make= modpost compile=0Aon darwin again") came in.=0A=0AGiven a certain degree o= f unknowledge about the link stage of host=0Aprograms, I really want to see= simple, stupid table lookup so that=0Athis works in the same way regardles= s of the underlying executable=0Aformat.=0A=0ASigned-off-by: Masahiro Yamad= a =0AAcked-by: Mathieu Malaterre =0A[nc: Omit rpmsg, sdw, tbsvc, and typec as they do not exist here]= =0ASigned-off-by: Nathan Chancellor =0A---=0A scr= ipts/mod/file2alias.c | 136 +++++++++++++--------------------------=0A 1 fi= le changed, 45 insertions(+), 91 deletions(-)=0A=0Adiff --git a/scripts/mod= /file2alias.c b/scripts/mod/file2alias.c=0Aindex 29d6699d5a06..6e3ae94cf123= 100644=0A--- a/scripts/mod/file2alias.c=0A+++ b/scripts/mod/file2alias.c= =0A@@ -50,46 +50,6 @@ struct devtable {=0A void *function;=0A };=0A =0A-#d= efine ___cat(a,b) a ## b=0A-#define __cat(a,b) ___cat(a,b)=0A-=0A-/* we nee= d some special handling for this host tool running eventually on=0A- * Darw= in. The Mach-O section handling is a bit different than ELF section=0A- * h= andling. The differnces in detail are:=0A- * a) we have segments which hav= e sections=0A- * b) we need a API call to get the respective section symbo= ls */=0A-#if defined(__MACH__)=0A-#include =0A-=0A-#defin= e INIT_SECTION(name) do { \=0A- unsigned long name ## _len; \=0A- = char *__cat(pstart_,name) =3D getsectdata("__TEXT", \=0A- #name, &__cat(= name,_len)); \=0A- char *__cat(pstop_,name) =3D __cat(pstart_,name) + \= =0A- __cat(name, _len); \=0A- __cat(__start_,name) =3D (void *)__cat(= pstart_,name); \=0A- __cat(__stop_,name) =3D (void *)__cat(pstop_,name); \= =0A- } while (0)=0A-#define SECTION(name) __attribute__((section("__TEXT,= " #name)))=0A-=0A-struct devtable **__start___devtable, **__stop___devtabl= e;=0A-#else=0A-#define INIT_SECTION(name) /* no-op for ELF */=0A-#define SE= CTION(name) __attribute__((section(#name)))=0A-=0A-/* We construct a tabl= e of pointers in an ELF section (pointers generally=0A- * go unpadded by gc= c). ld creates boundary syms for us. */=0A-extern struct devtable *__start= ___devtable[], *__stop___devtable[];=0A-#endif /* __MACH__ */=0A-=0A-#if !d= efined(__used)=0A-# if __GNUC__ =3D=3D 3 && __GNUC_MINOR__ < 3=0A-# define= __used __attribute__((__unused__))=0A-# else=0A-# define __used __att= ribute__((__used__))=0A-# endif=0A-#endif=0A-=0A /* Define a variable f tha= t holds the value of field f of struct devid=0A * based at address m.=0A = */=0A@@ -102,16 +62,6 @@ extern struct devtable *__start___devtable[], *__s= top___devtable[];=0A #define DEF_FIELD_ADDR(m, devid, f) \=0A typeof(((str= uct devid *)0)->f) *f =3D ((m) + OFF_##devid##_##f)=0A =0A-/* Add a table e= ntry. We test function type matches while we're here. */=0A-#define ADD_TO= _DEVTABLE(device_id, type, function) \=0A- static struct devtable __cat(dev= table,__LINE__) =3D { \=0A- device_id + 0*sizeof((function)((const char *)= NULL, \=0A- (void *)NULL, \=0A- (char *)NULL)), \=0A- SIZE_##t= ype, (function) }; \=0A- static struct devtable *SECTION(__devtable) __u= sed \=0A- __cat(devtable_ptr,__LINE__) =3D &__cat(devtable,__LINE__)=0A-= =0A #define ADD(str, sep, cond, field) \=0A do= { \=0A = strcat(str, sep); \=0A@@ -431,7 +381,= 6 @@ static int do_hid_entry(const char *filename,=0A =0A return 1;=0A }= =0A-ADD_TO_DEVTABLE("hid", hid_device_id, do_hid_entry);=0A =0A /* Looks li= ke: ieee1394:venNmoNspNverN */=0A static int do_ieee1394_entry(const char *= filename,=0A@@ -456,7 +405,6 @@ static int do_ieee1394_entry(const char *fi= lename,=0A add_wildcard(alias);=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("iee= e1394", ieee1394_device_id, do_ieee1394_entry);=0A =0A /* Looks like: pci:v= NdNsvNsdNbcNscNiN. */=0A static int do_pci_entry(const char *filename,=0A@@= -500,7 +448,6 @@ static int do_pci_entry(const char *filename,=0A add_wil= dcard(alias);=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("pci", pci_device_id, d= o_pci_entry);=0A =0A /* looks like: "ccw:tNmNdtNdmN" */=0A static int do_cc= w_entry(const char *filename,=0A@@ -524,7 +471,6 @@ static int do_ccw_entry= (const char *filename,=0A add_wildcard(alias);=0A return 1;=0A }=0A-ADD_T= O_DEVTABLE("ccw", ccw_device_id, do_ccw_entry);=0A =0A /* looks like: "ap:t= N" */=0A static int do_ap_entry(const char *filename,=0A@@ -535,7 +481,6 @@= static int do_ap_entry(const char *filename,=0A sprintf(alias, "ap:t%02X*= ", dev_type);=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("ap", ap_device_id, do_= ap_entry);=0A =0A /* looks like: "css:tN" */=0A static int do_css_entry(con= st char *filename,=0A@@ -546,7 +491,6 @@ static int do_css_entry(const char= *filename,=0A sprintf(alias, "css:t%01X", type);=0A return 1;=0A }=0A-AD= D_TO_DEVTABLE("css", css_device_id, do_css_entry);=0A =0A /* Looks like: "s= erio:tyNprNidNexN" */=0A static int do_serio_entry(const char *filename,=0A= @@ -566,7 +510,6 @@ static int do_serio_entry(const char *filename,=0A add= _wildcard(alias);=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("serio", serio_devi= ce_id, do_serio_entry);=0A =0A /* looks like: "acpi:ACPI0003" or "acpi:PNP0= C0B" or "acpi:LNXVIDEO" or=0A * "acpi:bbsspp" (bb=3Dbase-class= , ss=3Dsub-class, pp=3Dprog-if)=0A@@ -604,7 +547,6 @@ static int do_acpi_en= try(const char *filename,=0A }=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("acpi= ", acpi_device_id, do_acpi_entry);=0A =0A /* looks like: "pnp:dD" */=0A sta= tic void do_pnp_device_entry(void *symval, unsigned long size,=0A@@ -725,7 = +667,6 @@ static int do_pcmcia_entry(const char *filename,=0A add_wildcard= (alias);=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("pcmcia", pcmcia_device_id, = do_pcmcia_entry);=0A =0A static int do_vio_entry(const char *filename, void= *symval,=0A char *alias)=0A@@ -745,7 +686,6 @@ static int do_vio_entry(c= onst char *filename, void *symval,=0A add_wildcard(alias);=0A return 1;= =0A }=0A-ADD_TO_DEVTABLE("vio", vio_device_id, do_vio_entry);=0A =0A #defin= e ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))=0A =0A@@ -818,7 +758,6 @@ stat= ic int do_input_entry(const char *filename, void *symval,=0A do_input(ali= as, *swbit, 0, INPUT_DEVICE_ID_SW_MAX);=0A return 1;=0A }=0A-ADD_TO_DEVTAB= LE("input", input_device_id, do_input_entry);=0A =0A static int do_eisa_ent= ry(const char *filename, void *symval,=0A char *alias)=0A@@ -830,7 +769,6= @@ static int do_eisa_entry(const char *filename, void *symval,=0A strca= t(alias, "*");=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("eisa", eisa_device_id= , do_eisa_entry);=0A =0A /* Looks like: parisc:tNhvNrevNsvN */=0A static in= t do_parisc_entry(const char *filename, void *symval,=0A@@ -850,7 +788,6 @@= static int do_parisc_entry(const char *filename, void *symval,=0A add_wil= dcard(alias);=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("parisc", parisc_device= _id, do_parisc_entry);=0A =0A /* Looks like: sdio:cNvNdN. */=0A static int = do_sdio_entry(const char *filename,=0A@@ -867,7 +804,6 @@ static int do_sdi= o_entry(const char *filename,=0A add_wildcard(alias);=0A return 1;=0A }= =0A-ADD_TO_DEVTABLE("sdio", sdio_device_id, do_sdio_entry);=0A =0A /* Looks= like: ssb:vNidNrevN. */=0A static int do_ssb_entry(const char *filename,= =0A@@ -884,7 +820,6 @@ static int do_ssb_entry(const char *filename,=0A ad= d_wildcard(alias);=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("ssb", ssb_device_= id, do_ssb_entry);=0A =0A /* Looks like: bcma:mNidNrevNclN. */=0A static in= t do_bcma_entry(const char *filename,=0A@@ -903,7 +838,6 @@ static int do_b= cma_entry(const char *filename,=0A add_wildcard(alias);=0A return 1;=0A }= =0A-ADD_TO_DEVTABLE("bcma", bcma_device_id, do_bcma_entry);=0A =0A /* Looks= like: virtio:dNvN */=0A static int do_virtio_entry(const char *filename, v= oid *symval,=0A@@ -919,7 +853,6 @@ static int do_virtio_entry(const char *f= ilename, void *symval,=0A add_wildcard(alias);=0A return 1;=0A }=0A-ADD_T= O_DEVTABLE("virtio", virtio_device_id, do_virtio_entry);=0A =0A /*=0A * Lo= oks like: vmbus:guid=0A@@ -942,7 +875,6 @@ static int do_vmbus_entry(const = char *filename, void *symval,=0A =0A return 1;=0A }=0A-ADD_TO_DEVTABLE("vm= bus", hv_vmbus_device_id, do_vmbus_entry);=0A =0A /* Looks like: i2c:S */= =0A static int do_i2c_entry(const char *filename, void *symval,=0A@@ -953,7= +885,6 @@ static int do_i2c_entry(const char *filename, void *symval,=0A = =0A return 1;=0A }=0A-ADD_TO_DEVTABLE("i2c", i2c_device_id, do_i2c_entry);= =0A =0A /* Looks like: spi:S */=0A static int do_spi_entry(const char *file= name, void *symval,=0A@@ -964,7 +895,6 @@ static int do_spi_entry(const cha= r *filename, void *symval,=0A =0A return 1;=0A }=0A-ADD_TO_DEVTABLE("spi",= spi_device_id, do_spi_entry);=0A =0A static const struct dmifield {=0A co= nst char *prefix;=0A@@ -1019,7 +949,6 @@ static int do_dmi_entry(const char= *filename, void *symval,=0A strcat(alias, ":");=0A return 1;=0A }=0A-ADD= _TO_DEVTABLE("dmi", dmi_system_id, do_dmi_entry);=0A =0A static int do_plat= form_entry(const char *filename,=0A void *symval, char *alias)=0A@@= -1028,7 +957,6 @@ static int do_platform_entry(const char *filename,=0A s= printf(alias, PLATFORM_MODULE_PREFIX "%s", *name);=0A return 1;=0A }=0A-AD= D_TO_DEVTABLE("platform", platform_device_id, do_platform_entry);=0A =0A st= atic int do_mdio_entry(const char *filename,=0A void *symval, char *ali= as)=0A@@ -1053,7 +981,6 @@ static int do_mdio_entry(const char *filename,= =0A =0A return 1;=0A }=0A-ADD_TO_DEVTABLE("mdio", mdio_device_id, do_mdio_= entry);=0A =0A /* Looks like: zorro:iN. */=0A static int do_zorro_entry(con= st char *filename, void *symval,=0A@@ -1064,7 +991,6 @@ static int do_zorro= _entry(const char *filename, void *symval,=0A ADD(alias, "i", id !=3D ZORR= O_WILDCARD, id);=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("zorro", zorro_devic= e_id, do_zorro_entry);=0A =0A /* looks like: "pnp:dD" */=0A static int do_i= sapnp_entry(const char *filename,=0A@@ -1080,7 +1006,6 @@ static int do_isa= pnp_entry(const char *filename,=0A (function >> 12) & 0x0f, (function >> = 8) & 0x0f);=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("isapnp", isapnp_device_i= d, do_isapnp_entry);=0A =0A /* Looks like: "ipack:fNvNdN". */=0A static int= do_ipack_entry(const char *filename,=0A@@ -1096,7 +1021,6 @@ static int do= _ipack_entry(const char *filename,=0A add_wildcard(alias);=0A return 1;= =0A }=0A-ADD_TO_DEVTABLE("ipack", ipack_device_id, do_ipack_entry);=0A =0A = /*=0A * Append a match expression for a single masked hex digit.=0A@@ -116= 7,7 +1091,6 @@ static int do_amba_entry(const char *filename,=0A =0A retur= n 1;=0A }=0A-ADD_TO_DEVTABLE("amba", amba_id, do_amba_entry);=0A =0A /*=0A = * looks like: "mipscdmm:tN"=0A@@ -1183,7 +1106,6 @@ static int do_mips_cdm= m_entry(const char *filename,=0A sprintf(alias, "mipscdmm:t%02X*", type);= =0A return 1;=0A }=0A-ADD_TO_DEVTABLE("mipscdmm", mips_cdmm_device_id, do_= mips_cdmm_entry);=0A =0A /* LOOKS like cpu:type:x86,venVVVVfamFFFFmodMMMM:f= eature:*,FEAT,*=0A * All fields are numbers. It would be nicer to use stri= ngs for vendor=0A@@ -1208,7 +1130,6 @@ static int do_x86cpu_entry(const cha= r *filename, void *symval,=0A sprintf(alias + strlen(alias), "%04X*", fea= ture);=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("x86cpu", x86_cpu_id, do_x86cp= u_entry);=0A =0A /* LOOKS like cpu:type:*:feature:*FEAT* */=0A static int d= o_cpu_entry(const char *filename, void *symval, char *alias)=0A@@ -1218,7 += 1139,6 @@ static int do_cpu_entry(const char *filename, void *symval, char = *alias)=0A sprintf(alias, "cpu:type:*:feature:*%04X*", feature);=0A retur= n 1;=0A }=0A-ADD_TO_DEVTABLE("cpu", cpu_feature, do_cpu_entry);=0A =0A /* L= ooks like: mei:S:uuid:N:* */=0A static int do_mei_entry(const char *filenam= e, void *symval,=0A@@ -1237,7 +1157,6 @@ static int do_mei_entry(const char= *filename, void *symval,=0A =0A return 1;=0A }=0A-ADD_TO_DEVTABLE("mei", = mei_cl_device_id, do_mei_entry);=0A =0A /* Looks like: rapidio:vNdNavNadN *= /=0A static int do_rio_entry(const char *filename,=0A@@ -1257,7 +1176,6 @@ = static int do_rio_entry(const char *filename,=0A add_wildcard(alias);=0A = return 1;=0A }=0A-ADD_TO_DEVTABLE("rapidio", rio_device_id, do_rio_entry);= =0A =0A /* Looks like: ulpi:vNpN */=0A static int do_ulpi_entry(const char = *filename, void *symval,=0A@@ -1270,7 +1188,6 @@ static int do_ulpi_entry(c= onst char *filename, void *symval,=0A =0A return 1;=0A }=0A-ADD_TO_DEVTABL= E("ulpi", ulpi_device_id, do_ulpi_entry);=0A =0A /* Looks like: hdaudio:vNr= NaN */=0A static int do_hda_entry(const char *filename, void *symval, char = *alias)=0A@@ -1287,7 +1204,6 @@ static int do_hda_entry(const char *filenam= e, void *symval, char *alias)=0A add_wildcard(alias);=0A return 1;=0A }= =0A-ADD_TO_DEVTABLE("hdaudio", hda_device_id, do_hda_entry);=0A =0A /* Look= s like: fsl-mc:vNdN */=0A static int do_fsl_mc_entry(const char *filename, = void *symval,=0A@@ -1299,7 +1215,6 @@ static int do_fsl_mc_entry(const char= *filename, void *symval,=0A sprintf(alias, "fsl-mc:v%08Xd%s", vendor, *ob= j_type);=0A return 1;=0A }=0A-ADD_TO_DEVTABLE("fslmc", fsl_mc_device_id, d= o_fsl_mc_entry);=0A =0A /* Does namelen bytes of name exactly match the sym= bol? */=0A static bool sym_is(const char *name, unsigned namelen, const cha= r *symbol)=0A@@ -1332,6 +1247,44 @@ static void do_table(void *symval, unsi= gned long size,=0A }=0A }=0A =0A+static const struct devtable devtable[] = =3D {=0A+ {"hid", SIZE_hid_device_id, do_hid_entry},=0A+ {"ieee1394", SIZE_= ieee1394_device_id, do_ieee1394_entry},=0A+ {"pci", SIZE_pci_device_id, do_= pci_entry},=0A+ {"ccw", SIZE_ccw_device_id, do_ccw_entry},=0A+ {"ap", SIZE_= ap_device_id, do_ap_entry},=0A+ {"css", SIZE_css_device_id, do_css_entry},= =0A+ {"serio", SIZE_serio_device_id, do_serio_entry},=0A+ {"acpi", SIZE_acp= i_device_id, do_acpi_entry},=0A+ {"pcmcia", SIZE_pcmcia_device_id, do_pcmci= a_entry},=0A+ {"vio", SIZE_vio_device_id, do_vio_entry},=0A+ {"input", SIZE= _input_device_id, do_input_entry},=0A+ {"eisa", SIZE_eisa_device_id, do_eis= a_entry},=0A+ {"parisc", SIZE_parisc_device_id, do_parisc_entry},=0A+ {"sdi= o", SIZE_sdio_device_id, do_sdio_entry},=0A+ {"ssb", SIZE_ssb_device_id, do= _ssb_entry},=0A+ {"bcma", SIZE_bcma_device_id, do_bcma_entry},=0A+ {"virtio= ", SIZE_virtio_device_id, do_virtio_entry},=0A+ {"vmbus", SIZE_hv_vmbus_dev= ice_id, do_vmbus_entry},=0A+ {"i2c", SIZE_i2c_device_id, do_i2c_entry},=0A+= {"spi", SIZE_spi_device_id, do_spi_entry},=0A+ {"dmi", SIZE_dmi_system_id,= do_dmi_entry},=0A+ {"platform", SIZE_platform_device_id, do_platform_entry= },=0A+ {"mdio", SIZE_mdio_device_id, do_mdio_entry},=0A+ {"zorro", SIZE_zor= ro_device_id, do_zorro_entry},=0A+ {"isapnp", SIZE_isapnp_device_id, do_isa= pnp_entry},=0A+ {"ipack", SIZE_ipack_device_id, do_ipack_entry},=0A+ {"amba= ", SIZE_amba_id, do_amba_entry},=0A+ {"mipscdmm", SIZE_mips_cdmm_device_id,= do_mips_cdmm_entry},=0A+ {"x86cpu", SIZE_x86_cpu_id, do_x86cpu_entry},=0A+= {"cpu", SIZE_cpu_feature, do_cpu_entry},=0A+ {"mei", SIZE_mei_cl_device_id= , do_mei_entry},=0A+ {"rapidio", SIZE_rio_device_id, do_rio_entry},=0A+ {"u= lpi", SIZE_ulpi_device_id, do_ulpi_entry},=0A+ {"hdaudio", SIZE_hda_device_= id, do_hda_entry},=0A+ {"fslmc", SIZE_fsl_mc_device_id, do_fsl_mc_entry},= =0A+};=0A+=0A /* Create MODULE_ALIAS() statements.=0A * At this time, we c= annot write the actual output C source yet,=0A * so we write into the mod-= >dev_table_buf buffer. */=0A@@ -1386,13 +1339,14 @@ void handle_moddevtable= (struct module *mod, struct elf_info *info,=0A else if (sym_is(name, namel= en, "pnp_card"))=0A do_pnp_card_entries(symval, sym->st_size, mod);=0A e= lse {=0A- struct devtable **p;=0A- INIT_SECTION(__devtable);=0A+ int i;= =0A+=0A+ for (i =3D 0; i < ARRAY_SIZE(devtable); i++) {=0A+ const struct= devtable *p =3D &devtable[i];=0A =0A- for (p =3D __start___devtable; p < = __stop___devtable; p++) {=0A- if (sym_is(name, namelen, (*p)->device_id))= {=0A- do_table(symval, sym->st_size, (*p)->id_size,=0A- (*p)->devi= ce_id, (*p)->function, mod);=0A+ if (sym_is(name, namelen, p->device_id))= {=0A+ do_table(symval, sym->st_size, p->id_size,=0A+ p->device_id,= p->function, mod);=0A break;=0A }=0A }=0A-- =0A2.21.0=0A=0A=0AFro= m ebc14110f93859807854b00d4ec86d702190bbe3 Mon Sep 17 00:00:00 2001=0AFrom:= Masahiro Yamada =0ADate: Thu, 22 Nov 2018 1= 3:28:42 +0900=0ASubject: [PATCH 4.14 2/2] modpost: file2alias: check protot= ype of handler=0A=0Acommit f880eea68fe593342fa6e09be9bb661f3c297aec upstrea= m.=0A=0AUse specific prototype instead of an opaque pointer so that the=0Ac= ompiler can catch function prototype mismatch.=0A=0ASigned-off-by: Masahiro= Yamada =0AReviewed-by: Mathieu Malaterre =0ASigned-off-by: Nathan Chancellor =0A---=0A scripts/mod/file2alias.c | 7 +++----=0A 1 file changed, 3 inse= rtions(+), 4 deletions(-)=0A=0Adiff --git a/scripts/mod/file2alias.c b/scri= pts/mod/file2alias.c=0Aindex 6e3ae94cf123..55b4c0dc2b93 100644=0A--- a/scri= pts/mod/file2alias.c=0A+++ b/scripts/mod/file2alias.c=0A@@ -47,7 +47,7 @@ t= ypedef struct {=0A struct devtable {=0A const char *device_id; /* name of = table, __mod___*_device_table. */=0A unsigned long id_size;=0A- void= *function;=0A+ int (*do_entry)(const char *filename, void *symval, char *a= lias);=0A };=0A =0A /* Define a variable f that holds the value of field f = of struct devid=0A@@ -1228,12 +1228,11 @@ static bool sym_is(const char *na= me, unsigned namelen, const char *symbol)=0A static void do_table(void *sym= val, unsigned long size,=0A unsigned long id_size,=0A const c= har *device_id,=0A- void *function,=0A+ int (*do_entry)(const c= har *filename, void *symval, char *alias),=0A struct module *mod)=0A= {=0A unsigned int i;=0A char alias[500];=0A- int (*do_entry)(const char = *, void *entry, char *alias) =3D function;=0A =0A device_id_check(mod->nam= e, device_id, size, id_size, symval);=0A /* Leave last one: it's the termi= nator. */=0A@@ -1346,7 +1345,7 @@ void handle_moddevtable(struct module *mo= d, struct elf_info *info,=0A =0A if (sym_is(name, namelen, p->device_id)= ) {=0A do_table(symval, sym->st_size, p->id_size,=0A- p->device_id= , p->function, mod);=0A+ p->device_id, p->do_entry, mod);=0A break= ;=0A }=0A }=0A-- =0A2.21.0=0A=0A --4Ckj6UjgE2iN1+kY--