From owner-freebsd-arch@FreeBSD.ORG Sun Dec 23 08:43:48 2007 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1718F16A55F; Sun, 23 Dec 2007 08:43:48 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe05.swip.net [212.247.154.129]) by mx1.freebsd.org (Postfix) with ESMTP id 564F813C45A; Sun, 23 Dec 2007 08:43:47 +0000 (UTC) (envelope-from hselasky@c2i.net) X-Cloudmark-Score: 0.000000 [] Received: from [193.217.102.3] (account mc467741@c2i.net HELO [10.0.0.105]) by mailfe05.swip.net (CommuniGate Pro SMTP 5.1.13) with ESMTPA id 641958604; Sun, 23 Dec 2007 09:43:45 +0100 From: Hans Petter Selasky To: "Poul-Henning Kamp" Date: Sun, 23 Dec 2007 09:44:27 +0100 User-Agent: KMail/1.9.7 References: <5386.1198395886@critter.freebsd.dk> In-Reply-To: <5386.1198395886@critter.freebsd.dk> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200712230944.29301.hselasky@c2i.net> Cc: alfred@freebsd.org, freebsd-arch@freebsd.org Subject: Re: More leaves on the device tree ? X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Dec 2007 08:43:48 -0000 On Sunday 23 December 2007, Poul-Henning Kamp wrote: > In message <20071222.234526.246317277.imp@bsdimp.com>, "M. Warner Losh" writes: > >In message: <200712202005.33263.hselasky@c2i.net> > > > > Hans Petter Selasky writes: > >: "make_dev" takes an additional "device_t parent_device" argument and > >: creates a child device with some magic flags set. > > > >What do you do for all the devices in /dev/ for which there is no > >device_t parent? Hi, If the parent is NULL, then no dev_t node is created. Regarding cloned devices my opinion is that they should always create a visible entry. What I have done for a while now is to create a dummy dev_t node. It is so annoying with invisible devices. Then you never know what you have got. For example "/dev/usbXXX". What I do is simply to create "/dev/usb0 " with a space in the end. This file is not openable. Really there sould be a flag for that. Then you open "/dev/usb0" instead, but this device is never created. That's the clone device. Then clones appear like "/dev/usb0.XX": /dev/usb0 % /dev/usb1 % /dev/usb2 % /dev/usb3 % /dev/usb0.00% /dev/usb1.00% /dev/usb2.00% /dev/usb3.00% > > I second Warners comments here. > > device_t is a handle for a hardware, dev_t is for a device in /dev, > they are very different thing and have no reasonable mapping between > them ([0..N]:[0..M]) I'm not saying that every make_dev() should take a device_t parent. If there is no "device_t" parent then there will be no node created. Another approach is to add something like: void device_enlist_subdev(device_t parent, dev_t sub); void device_delist_subdev(device_t parent, dev_t sub); struct device { ... LIST_HEAD(struct cdev) dv_cdev_children; ... }; struct cdev { LIST_ENTRY( .... ) dv_list; }; For example if you have 8 USB serial port adapters, then you just get 8 TTY devices like /dev/cuaUXXX . And finding out where the USB devices are actually connected could be very simple if we could put some hints perhaps in the device_t tree ? --HPS