From patchwork Mon Jan 27 19:09:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Gundersen X-Patchwork-Id: 3543791 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 06073C02DC for ; Mon, 27 Jan 2014 19:09:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CDF7420138 for ; Mon, 27 Jan 2014 19:09:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3A3B420123 for ; Mon, 27 Jan 2014 19:09:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753875AbaA0TJa (ORCPT ); Mon, 27 Jan 2014 14:09:30 -0500 Received: from mail-wg0-f42.google.com ([74.125.82.42]:55893 "EHLO mail-wg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753628AbaA0TJ3 (ORCPT ); Mon, 27 Jan 2014 14:09:29 -0500 Received: by mail-wg0-f42.google.com with SMTP id l18so4577276wgh.5 for ; Mon, 27 Jan 2014 11:09:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=PREVueK0+vXatH7yDFtN1GhdSE9UyQKZjMQTzdmZUeQ=; b=d1tgKO0if/dR/NnuexG2EcjqCb+jp9s2/I6RGS8OmGZvh8oXZKPX+CYjjsnD6kFmRb KhDgyXOziKqNhboYS2PAMTzyLgc9/x6xCtVYC+21tHFz3+LamygKHQhrEjBUsjprHk4B xq6BMK5tNiDU9J3Gath1VWBlUkW9Sx7j+UY3TlbhJPB/uPzUWgJc9BP9VL6ZIKpSK241 ScYg/+veA88lm+e6k7mFOmqPnyOWC2UnVSTl+g/HQU3NxzFeWCpGQJ2J1jdnZma7L5lf D3c4499DXCBKYGG2D0bBPMbBrB+hecfPplUrgxmEAmakjUdH13gFc/m9qH+OA9+6QZNO ifTg== X-Gm-Message-State: ALoCoQnSNEgXv3J1PH6RxOLWbbTMgswN/Miqzz4U8v0od/wMhK+Rq95p0EaXsQnarz5u2e8b588/ X-Received: by 10.180.91.164 with SMTP id cf4mr13162018wib.2.1390849768065; Mon, 27 Jan 2014 11:09:28 -0800 (PST) Received: from tomegun-air.redhat.com (cm-84.208.70.35.getinternet.no. [84.208.70.35]) by mx.google.com with ESMTPSA id p1sm31160853wie.1.2014.01.27.11.09.26 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 27 Jan 2014 11:09:27 -0800 (PST) From: Tom Gundersen To: linux-kernel@vger.kernel.org Cc: linux-input@vger.kernel.org, kay@vrfy.org, Tom Gundersen , Dmitry Torokhov , Greg Kroah-Hartman , Rusty Russell Subject: [RFC][PATCH] module: allow multiple calls to MODULE_DEVICE_TABLE() per module Date: Mon, 27 Jan 2014 20:09:55 +0100 Message-Id: <1390849795-2155-1-git-send-email-teg@jklm.no> X-Mailer: git-send-email 1.8.5.3 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Commit 78551277e4df5: "Input: i8042 - add PNP modaliases" had a bug, where the second call to MODULE_DEVICE_TABLE() overrode the first resulting in not all the modaliases being exposed. This fixes the problem by including the name of the device_id table in the __mod_*_device_table alias, allowing us to export several device_id tables per module. Suggested-by: Kay Sievers Cc: Dmitry Torokhov Cc: Greg Kroah-Hartman Cc: Rusty Russell Acked-by: Greg Kroah-Hartman --- include/linux/module.h | 2 +- scripts/mod/file2alias.c | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/include/linux/module.h b/include/linux/module.h index 15cd6b1..7732d76 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -143,7 +143,7 @@ extern const struct gtype##_id __mod_##gtype##_table \ #define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description) #define MODULE_DEVICE_TABLE(type,name) \ - MODULE_GENERIC_TABLE(type##_device,name) + MODULE_GENERIC_TABLE(type##__##name##_device,name) /* Version of form [:][-]. Or for CVS/RCS ID version, everything but the number is stripped. diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 2370863..6778381 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -42,7 +42,7 @@ typedef unsigned char __u8; /* This array collects all instances that use the generic do_table */ struct devtable { - const char *device_id; /* name of table, __mod__device_table. */ + const char *device_id; /* name of table, __mod___*_device_table. */ unsigned long id_size; void *function; }; @@ -146,7 +146,8 @@ static void device_id_check(const char *modname, const char *device_id, if (size % id_size || size < id_size) { fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo " - "of the size of section __mod_%s_device_table=%lu.\n" + "of the size of " + "section __mod_%s___device_table=%lu.\n" "Fix definition of struct %s_device_id " "in mod_devicetable.h\n", modname, device_id, id_size, device_id, size, device_id); @@ -1206,7 +1207,7 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, { void *symval; char *zeros = NULL; - const char *name; + const char *name, *identifier; unsigned int namelen; /* We're looking for a section relative symbol */ @@ -1217,7 +1218,7 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, if (ELF_ST_TYPE(sym->st_info) != STT_OBJECT) return; - /* All our symbols are of form __mod_XXX_device_table. */ + /* All our symbols are of form __mod____device_table. */ name = strstr(symname, "__mod_"); if (!name) return; @@ -1227,7 +1228,10 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, return; if (strcmp(name + namelen - strlen("_device_table"), "_device_table")) return; - namelen -= strlen("_device_table"); + identifier = strstr(name, "__"); + if (!identifier) + return; + namelen = identifier - name; /* Handle all-NULL symbols allocated into .bss */ if (info->sechdrs[get_secindex(info, sym)].sh_type & SHT_NOBITS) {