* Dmitry Krivenok <krivenok.dmi...@gmail.com> wrote:
> - int dev_num = minor(dev);
> + int dev_num = minor(dev2unit(dev));

Almost there. Just remove all calls to unit2minor() and minor2unit() (if
present) and replace minor() with dev2unit():

        int dev_num = 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 = 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 = make_dev(....);
        cdev->si_drv1 = sc;

Greetings,
-- 
 Ed Schouten <e...@80386.nl>
 WWW: http://80386.nl/

Attachment: pgpfWd3nM8l93.pgp
Description: PGP signature

Reply via email to