From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753282AbbJQRPj (ORCPT ); Sat, 17 Oct 2015 13:15:39 -0400 Received: from h1446028.stratoserver.net ([85.214.92.142]:59563 "EHLO mail.ahsoftware.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753072AbbJQRPh (ORCPT ); Sat, 17 Oct 2015 13:15:37 -0400 From: Alexander Holler To: linux-kernel@vger.kernel.org Cc: Linus Torvalds , Andrew Morton , Greg Kroah-Hartman , Russell King , Grant Likely , Alexander Holler Subject: [PATCH 04/14] init: deps: order network interfaces by link order Date: Sat, 17 Oct 2015 19:14:17 +0200 Message-Id: <1445102067-11519-5-git-send-email-holler@ahsoftware.de> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1445102067-11519-1-git-send-email-holler@ahsoftware.de> References: <1445102067-11519-1-git-send-email-holler@ahsoftware.de> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to provide stable interface numbers, network interface drivers will be ordered by the link order. This is easy to accomplish by adding dependencies. Assuming three different ethernet-drivers, without any special code, the dependency graph would not require any special order inbetween them and would look like that: eth-driver-base / | \ eth-x eth-y eth-z Now we just add dependencies. With the additional dependencies the graph looks like: eth-driver-base | | | eth-x | | | | | eth-y -| | | | eth-z ---| Signed-off-by: Alexander Holler --- include/linux/driver_ids.h | 11 +++++++++++ init/dependencies.c | 9 +++++++++ 2 files changed, 20 insertions(+) diff --git a/include/linux/driver_ids.h b/include/linux/driver_ids.h index 60964fe..1133a68 100644 --- a/include/linux/driver_ids.h +++ b/include/linux/driver_ids.h @@ -15,6 +15,17 @@ enum { drvid_unused, /* To be filled */ + + /* + * Network drivers will be ordered according to the link order + * (which means not necessarily according to their appearance + * here). + * This provides stable interface numbers. + * Therefor their IDs have to be in the following block. + */ + drvid_network_drivers_start, + drvid_network_drivers_end, + drvid_max }; diff --git a/init/dependencies.c b/init/dependencies.c index b484f67..027fc4b 100644 --- a/init/dependencies.c +++ b/init/dependencies.c @@ -301,12 +301,21 @@ static int __init add_dependencies(void) static void __init build_inventory(void) { const struct _annotated_initcall *ac; + unsigned id_last_network_driver = 0; ac = __annotated_initcall_start; for (; ac < __annotated_initcall_end; ++ac) { include_node[ac->id] = true; annotated_initcall_by_drvid[ac->id] = ac; nvertices = max(nvertices, ac->id); + /* order network drivers by link order*/ + if (ac->id > drvid_network_drivers_start && + ac->id < drvid_network_drivers_end) { + if (id_last_network_driver) + add_initcall_dependency(ac->id, + id_last_network_driver); + id_last_network_driver = ac->id; + } } } -- 2.1.0