In my driver, I do this:
static struct usb_driver g_EKEY_driver =
{
.owner = THIS_MODULE,
.name = "ekey",
.probe = EKEY_Probe,
.disconnect = EKEY_Disconnect,
.fops = &g_EKEY_fops,
.minor = USB_EKEY_MINOR_BASE,
.id_table = g_EKEY_IDS,
};
static int __init EKEY_Init(void)
{
int status; status = usb_register(&g_EKEY_driver);
if(status)
{
err(DRIVER_NAME "usb_register failed. Error number %d",
status);
return status;
} info(DRIVER_NAME " " DRIVER_VERSION " Initialized");
return 0;
}Then, after 'insmod ./ekey.o' and plug in my device, I do this:
int hDevice = open("/dev/usb/ekey0", O_RDONLY);
But, hDevice is always -1. What's wrong with my driver?Environment: Fedora Core 1, kernel 2.4.22-1.2115.nptlcustom, without devfs.
The following is the probe routine:
static void * EKEY_Probe(struct usb_device *udev, unsigned int ifnum, const struct usb_device_id *id)
{
PEKEY_DEVICE pEKEYDevice = NULL;
struct usb_interface* pInterface;
int nMinor;
dbg("Enering " __FUNCTION__);
if((udev->descriptor.idVendor != USB_EKEY_VENDOR_ID) ||
(udev->descriptor.idProduct != USB_EKEY_PRODUCT_ID)) {
return NULL;
} down(&g_MinorTableLock);
for(nMinor = 0; nMinor<MAX_DEVICES; ++nMinor)
{
if(g_MinorTable[nMinor] == NULL)
break;
}
if(nMinor >= MAX_DEVICES)
{
info("Too many devices plugged in, can not handle this device.");
goto Exit;
} pEKEYDevice = kmalloc(sizeof(EKEY_DEVICE), GFP_KERNEL);
if(pEKEYDevice == NULL)
{
err("Out of memory");
goto Exit;
}
memset(pEKEYDevice, 0x00, sizeof(EKEY_DEVICE));
g_MinorTable[nMinor] = pEKEYDevice;pInterface = &udev->actconfig->interface[ifnum];
init_MUTEX(&pEKEYDevice->Lock);
pEKEYDevice->pDevice = udev;
pEKEYDevice->pInterface = pInterface;
pEKEYDevice->nMinor = nMinor; /* let the user know what node this device is now attached to */
info("USB EKEY device now attached to EKEY%d", pEKEYDevice->nMinor);
MOD_INC_USE_COUNT;
goto Exit;
Error:
_FreeResources(pEKEYDevice);
pEKEYDevice = NULL;Exit:
up(&g_MinorTableLock);
return pEKEYDevice;
}Anyone help me?
LRD
------------------------------------------------------- This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it help you create better code? SHARE THE LOVE, and help us help YOU! Click Here: http://sourceforge.net/donate/ _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
