Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 10 May 2010 18:32:37 +0200
From:      Ed Schouten <ed@80386.nl>
To:        Dmitry Krivenok <krivenok.dmitry@gmail.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Moving from FreeBSD7 to FreeBSD8 (cdev, minor, dev2unit)
Message-ID:  <20100510163237.GU56080@hoeg.nl>
In-Reply-To: <m2ida48cf211005070159ma464fef5h5baf0107ee6e4e88@mail.gmail.com>
References:  <m2ida48cf211005070159ma464fef5h5baf0107ee6e4e88@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--YfA6L/ars3kY+zmg
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

* Dmitry Krivenok <krivenok.dmitry@gmail.com> 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 <ed@80386.nl>
 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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100510163237.GU56080>