From patchwork Tue Jan 28 13:42:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Gundersen X-Patchwork-Id: 3546881 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 01DC59F2E9 for ; Tue, 28 Jan 2014 13:42:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AC5582015A for ; Tue, 28 Jan 2014 13:42:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BB49A20149 for ; Tue, 28 Jan 2014 13:42:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754706AbaA1NmJ (ORCPT ); Tue, 28 Jan 2014 08:42:09 -0500 Received: from mail-ee0-f53.google.com ([74.125.83.53]:36290 "EHLO mail-ee0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754574AbaA1NmI (ORCPT ); Tue, 28 Jan 2014 08:42:08 -0500 Received: by mail-ee0-f53.google.com with SMTP id t10so238677eei.26 for ; Tue, 28 Jan 2014 05:42:06 -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:in-reply-to :references; bh=XQKw6njeeoG7UlT9fwj9CHBxBbBV6wT2EPolN8T/I5k=; b=LZOkl+kjQNXmqtAPyxmQPlLGFcAFelXmM9jCAtawhhBNE9Rb1Q+KxJd8ALZasnBe+Q ZP+yf07MX0pUqv0vC10XtoshzmiptXcbOXNNij+aVJx9z3eqIaAQz7whZOXzSVufL/FN zHRLZ8N+dW59YSTns+WV45IlbOsa1UtoEBAfuuGZYCtDh+nNQC2WhTfM7m5lguyCmwM+ UHBrU4EOP+Sy+SFwgB/wfGKYxEGFcaxO/y3Rukj/b3/WDpui7z3IcZr7RGbC60kNZSTr UfecSnmUX0F0AQpYJ4HrNJeqkh3YBdcnWqex7iYTthf6FnDCOuzAKB/VxIjjmQNSKZz8 sVQw== X-Gm-Message-State: ALoCoQnD+ZfzjeoKxPVklH4Kupm6ObGWymvzu9zXdaZv8W+1V9DnGLSwQ9ZmKcfvUqcF9praXyLN X-Received: by 10.14.209.129 with SMTP id s1mr1874937eeo.21.1390916526487; Tue, 28 Jan 2014 05:42:06 -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 n7sm55857504eef.5.2014.01.28.05.42.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Jan 2014 05:42:05 -0800 (PST) From: Tom Gundersen To: linux-kernel@vger.kernel.org Cc: linux-input@vger.kernel.org, kay@vrfy.org, Tom Gundersen , Dmitry Torokhov , Rusty Russell Subject: [PATCH] module: allow multiple calls to MODULE_DEVICE_TABLE() per module Date: Tue, 28 Jan 2014 14:42:26 +0100 Message-Id: <1390916546-27155-1-git-send-email-teg@jklm.no> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <87k3dkzy4t.fsf@rustcorp.com.au> References: <87k3dkzy4t.fsf@rustcorp.com.au> 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 Acked-by: Greg Kroah-Hartman Cc: Dmitry Torokhov Cc: Rusty Russell Signed-off-by: Tom Gundersen --- 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) {