From owner-freebsd-drivers@FreeBSD.ORG Mon Feb 19 17:54:29 2007 Return-Path: X-Original-To: freebsd-drivers@freebsd.org Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E65CA16AFCA for ; Mon, 19 Feb 2007 17:54:29 +0000 (UTC) (envelope-from deathjestr@gmail.com) Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.226]) by mx1.freebsd.org (Postfix) with ESMTP id A37AD13C4B5 for ; Mon, 19 Feb 2007 17:54:29 +0000 (UTC) (envelope-from deathjestr@gmail.com) Received: by wx-out-0506.google.com with SMTP id s18so2028565wxc for ; Mon, 19 Feb 2007 09:54:29 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=fsqDkMUziQphaE2TNc5n+NGBc6lw6QfjiGUgQeS6GvoFiZ2WGhWKvGn/w2XkDiZqco5R3n0EqL7422jH9J4c9ObT2wInUPpvvm+UuZM4YMwDW5+J3l7PpfxzEe95SIQ2ff1u+d5iNb1LixoLk2hYDuw5jXvbFFX3+x1f4ZZzxFA= Received: by 10.90.98.10 with SMTP id v10mr7366493agb.1171906040379; Mon, 19 Feb 2007 09:27:20 -0800 (PST) Received: by 10.90.96.6 with HTTP; Mon, 19 Feb 2007 09:27:20 -0800 (PST) Message-ID: <44b564930702190927w25047f19v75e5626c0e4065eb@mail.gmail.com> Date: Mon, 19 Feb 2007 12:27:20 -0500 From: "Michael M. Press" To: freebsd-drivers@freebsd.org In-Reply-To: <150997.27592.qm@web8315.mail.in.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <150997.27592.qm@web8315.mail.in.yahoo.com> Cc: aji abraham Subject: Re: Doudts in "softc" and "device_get_softc(dev)" X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Feb 2007 17:54:30 -0000 > > sizeof(struct xx_softc ) is 68 > sizeof(struct xx_if_softc ) is 1186 > The softc structures are not, in general, of a fixed size. They may be of different sizes for different types of devices. > > struct xx_softc *sc; > struct xx_if_softc *if_sc; > > sc_if = device_get_softc(dev); > sc = device_get_softc(device_get_parent(dev)); > > sc_if-> ..... > sc-> .... > > Both allocation uses the same function. How it > possible ? can we > access > all structure member ? > device_get_softc returns a pointer to the device's softc structure. This function probably isn't aware of what the softc structure itself looks like, but it doesn't need to be. If it needed to copy the structure it would need to know its size, but it is not copying it, it is only returning a pointer to it. You can access all members of the structure returned to you by device_get_softc.