From owner-freebsd-drivers@FreeBSD.ORG Sat Sep 14 18:09:07 2013 Return-Path: Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 592155F7 for ; Sat, 14 Sep 2013 18:09:07 +0000 (UTC) (envelope-from lnrdpss@gmail.com) Received: from mail-vc0-x230.google.com (mail-vc0-x230.google.com [IPv6:2607:f8b0:400c:c03::230]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 1B32C225E for ; Sat, 14 Sep 2013 18:09:07 +0000 (UTC) Received: by mail-vc0-f176.google.com with SMTP id lf11so1831759vcb.7 for ; Sat, 14 Sep 2013 11:09:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=4vXgSw+M1KKHxNIT0nm6KlTVCYak3HNY3d7bt81Z4ww=; b=FV7pDrZHhPKauvwOOBppHIWX0xVqU4j2oUtbZzQdfz1j+Xq1n5iG3vujzqKny/btDl Hon1zNU3q7devFgwkyW0BwYr7+A7LS6oOURuwaYC99jtd8Iv1u+FMNWUG3j32zBFpb/R YLwCrS2PwtHeTecw8lWgDbrWeLxClXNBTcpINB4yPHvvckjD7byxumQdezGDkhdlhlr8 V7PinnoM37aBfrrdXkBr3z/lfTW2e2RtwopwPVEZDNj3x+DivCa6Z6+0YKtRsstD4qJe BQnUPm2C/UwKBNZu/8Mz7xpA2kNTCRTxyxtQA1XA1oT2pYoDqf1R+uAghTuek+uyPO/C RlMQ== MIME-Version: 1.0 X-Received: by 10.52.232.165 with SMTP id tp5mr15168554vdc.11.1379182146189; Sat, 14 Sep 2013 11:09:06 -0700 (PDT) Received: by 10.221.17.130 with HTTP; Sat, 14 Sep 2013 11:09:06 -0700 (PDT) Date: Sat, 14 Sep 2013 14:09:06 -0400 Message-ID: Subject: Device hierarchy From: Leonardo Passos To: freebsd-drivers@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Sep 2013 18:09:07 -0000 Hi all, I am checking some code from the FreeBSD repository, and I came across a situation that I could not explain, at least from the existing documentation. Looking at sys/dev/ata/ata-raid.c in the 9.1 release, I see the following module declaration (line 4616): static moduledata_t ata_raid_moduledata = { "ataraid", ata_raid_module_event_handler, NULL }; DECLARE_MODULE(ata, ata_raid_moduledata, SI_SUB_RAID, SI_ORDER_FIRST); MODULE_VERSION(ataraid, 1); MODULE_DEPEND(ataraid, ata, 1, 1, 1); MODULE_DEPEND(ataraid, ad, 1, 1, 1); The name of the module, as specified in DECLARE_MODULE, is ata, but the name provided in the moduledata_t instance is "ataraid". According to the documentation of DECLARE_MODULE, the name field in the structure instance (2nd parameter) is the official module name. So, it is correct to assume that passing "ata" as the first parameter in DECLARE_MODULE is an error, as it does not match "ataraid", or is it the case that such name is a "don't care" field, as FreeBSD takes the name as given by the moduledata_t instance? Another weird situation appears in sys/dev/ata-isa.c (line 201): static driver_t ata_isa_driver = { "ata", ata_isa_methods, sizeof(struct ata_channel), }; DRIVER_MODULE(ata, isa, ata_isa_driver, ata_devclass, 0, 0); MODULE_DEPEND(ata, ata, 1, 1, 1); Here, the driver module name is set to "ata", and later, it is stated that ata depends on ata. Is the dependency referring to another ata module, at a different level in the driver stacking? How are these names and dependencies resolved? Thanks, Leonardo.