2000-12-13 01:32:40

by skinbits

[permalink] [raw]
Subject: scsi_unregister_device

Hello all,

As part of our final year project, we are implementing a network based on
SCSI to use as a cheap fast eth link.

This module is made of two parts:

-sn: A scsi device that talk with the scsi mid layer
-scsinet: A network device driver that talks with sn.

We made a module based on code allready made for kernel 2.1.97, ported
it to 2.4.0test10, and put it as a module. The module allready loads,
both subsystems are initialized and the kernel dosen't crash :))

The problem happens when we try to load our module without a SCSI device
driver loaded (We use Symbios 53c8xx). When that happens, we register
sn with scsi_register_device, but when we try to init scsinet, it fails
(there are no devices to talk to, so it will fail). So, before our
module is unloaded, we try to unregister the sn device using
scsi_unregister_device. All is allright, the module get's out, but, the
usage count of the scsi_mod.o dosen't decrement. So it stays blocked in
the kernel and we can't unload it...

the relevant code is something like:

static int __init init_sc(void)
int ret;

if ((ret=scsi_register_module(MODULE_SCSI_DEV,&sn_template))!=0)
return ret;

if ((ret=register_netdev(&scsinet_template)!=0)
return ret;

return 0;

sn_template is the template for the scsi device, scsinet_template is the
template for a ehternet driver.

Anyone knows what we are doing wrong?

Pedro Semeano