From owner-freebsd-hackers@FreeBSD.ORG Mon May 10 16:48:26 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E64331065677 for ; Mon, 10 May 2010 16:48:26 +0000 (UTC) (envelope-from ed@hoeg.nl) Received: from mx0.hoeg.nl (mx0.hoeg.nl [178.63.0.170]) by mx1.freebsd.org (Postfix) with ESMTP id 64F908FC0A for ; Mon, 10 May 2010 16:48:26 +0000 (UTC) Received: by mx0.hoeg.nl (Postfix, from userid 1000) id CFAA52A28CF3; Mon, 10 May 2010 18:32:37 +0200 (CEST) Date: Mon, 10 May 2010 18:32:37 +0200 From: Ed Schouten To: Dmitry Krivenok Message-ID: <20100510163237.GU56080@hoeg.nl> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="YfA6L/ars3kY+zmg" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) Cc: freebsd-hackers@freebsd.org Subject: Re: Moving from FreeBSD7 to FreeBSD8 (cdev, minor, dev2unit) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2010 16:48:27 -0000 --YfA6L/ars3kY+zmg Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * Dmitry Krivenok wrote: > - int dev_num =3D minor(dev); > + int dev_num =3D minor(dev2unit(dev)); Almost there. Just remove all calls to unit2minor() and minor2unit() (if present) and replace minor() with dev2unit(): int dev_num =3D dev2unit(dev); But even better, don't use device unit numbers at all. The struct cdev already provides fields like si_drv1 and si_drv2 that can be used to store per-device data. Some drivers use constructs like these: sc =3D device_get_softc(devclass_get_device(devclass, dev2unit(cdev))); In those cases the code should just be changed to do something similar to the following: cdev =3D make_dev(....); cdev->si_drv1 =3D sc; Greetings, --=20 Ed Schouten WWW: http://80386.nl/ --YfA6L/ars3kY+zmg Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iEYEARECAAYFAkvoNSUACgkQ52SDGA2eCwUXrACfXuLNr/qg1T3aNAs2A4GaYwvm +KgAn0cBgR1yY56/u/DTJdDJ4b2nVHg3 =l2uq -----END PGP SIGNATURE----- --YfA6L/ars3kY+zmg--