[openib-general] IB/ipath - initialize diagpkt file on device init only
Roland Dreier
rdreier at cisco.com
Wed Oct 4 16:52:24 PDT 2006
I tried loading ib_ipath on one of my systems without an ipath device,
and I got the message
ib_ipath: Could not create class_dev for minor 127, ipath_diagpkt (err 19)
but I couldn't reproduce the hang of modprobe.
Anyway, taking a quick look at what caused that message showed that
the problem is that ipath_class is NULL there. And that makes sense,
because ipath_class isn't created until ipath_user_add() is called in
ipath_init_one() (which is never called if there are no devices).
So I think a correct fix is to move any global initialization like
creating ipath_class into the module_init function before probing any
devices. I don't approve of this latest patch because you do this:
> -int __init ipath_diagpkt_add(void)
> -{
> - return ipath_cdev_init(IPATH_DIAGPKT_MINOR,
> - "ipath_diagpkt", &diagpkt_file_ops,
> - &diagpkt_cdev, &diagpkt_class_dev);
> -}
> +void ipath_diagpkt_add(void)
> +{
> + if (atomic_inc_return(&diagpkt_count) == 1)
> + ipath_cdev_init(IPATH_DIAGPKT_MINOR,
> + "ipath_diagpkt", &diagpkt_file_ops,
> + &diagpkt_cdev, &diagpkt_class_dev);
> +}
which means that you've stopped checking the return value of
ipath_cdev_init(). What will happen if it fails? I would guess
everything blows up, right?
- R.
More information about the general
mailing list