Subversion Repositories f9daq

Compare Revisions

Ignore whitespace Rev 9 → Rev 11

/pcivme-3.2/driver/fops.c
349,7 → 349,7
u32 adr;
int err;
 
PRINTK(KERN_DEBUG "%s : CmdMachine()\n", DEVICE_NAME);
//PRINTK(KERN_DEBUG "%s : CmdMachine()\n", DEVICE_NAME);
 
// loop through the init (or deinit) list
while (psInitElement->bDestination != STOP)
402,7 → 402,7
int err;
PCIVME_INIT_ELEMENT *element = init->sVie;
 
PRINTK(KERN_DEBUG "%s : init_hardware()\n", DEVICE_NAME);
PRINTK(KERN_INFO "%s : init_hardware()\n", DEVICE_NAME);
 
err = CmdMachine(pd, element);
if (err)
621,7 → 621,7
u16 intCSR = readw((const volatile void *) pd->pPCIADAIntCSR);
int status = 0;
 
PRINTK(KERN_DEBUG "%s : VMEMM_RESET()\n", DEVICE_NAME);
PRINTK(KERN_INFO "%s : VMEMM_RESET()\n", DEVICE_NAME);
 
// am I connected and switched on??
if ((cntrl & 0x0980) == 0x0980)
801,8 → 801,17
return 0;
}
 
/*
static long pcivme_compat_ioctl(struct file *pFile, unsigned int cmd, unsigned long arg){
PRINTK(KERN_DEBUG "%s : pcivme_compat_ioctl(0x%08x), size = %d\n", DEVICE_NAME, cmd, _IOC_SIZE(cmd));
return pcivme_ioctl(NULL, pFile, cmd,arg);
}
*/
 
static long pcivme_unlocked_ioctl(struct file *pFile, unsigned int cmd, unsigned long arg){
long retval=0;
 
 
#if HAVE_UNLOCKED_IOCTL
struct mutex fs_mutex;
mutex_init(&fs_mutex);
811,6 → 820,7
lock_kernel();
#endif
 
PRINTK(KERN_DEBUG "%s : pcivme_unlocked_ioctl(0x%08x), size = %d\n", DEVICE_NAME, cmd, _IOC_SIZE(cmd));
retval = pcivme_ioctl(NULL, pFile, cmd,arg);
 
#if HAVE_UNLOCKED_IOCTL
818,6 → 828,7
#else
unlock_kernel();
#endif
 
return retval;
}
 
825,10 → 836,10
{
DEVICE_OBJ *pd = 0;
DEVICE_OBJ *desc = 0;
int nMinor = MINOR(pInode->i_rdev);
int nMinor = MINOR(pInode->i_rdev);
struct list_head *ptr;
 
PRINTK(KERN_DEBUG "%s : pcivme_open(), %d, %d, scanning %d devices\n", DEVICE_NAME, major(pInode->i_rdev), nMinor, drv.count);
PRINTK(KERN_DEBUG "%s : pcivme_open(), %d, scanning %d devices\n", DEVICE_NAME, nMinor, drv.count);
 
/* search for device */
for (ptr = drv.devList.next; ptr != &drv.devList; ptr = ptr->next)
839,7 → 850,7
{
if (test_connection(pd))
{
printk(KERN_ERR "%s : connection test for module %d failed!\n", DEVICE_NAME, pd->cModuleNumber);
printk(KERN_ERR "%s : pcivme_open() connection test for module %d failed!\n", DEVICE_NAME, pd->cModuleNumber);
pd->bConnected = 0;
}
else
850,7 → 861,7
}
}
else
PRINTK(KERN_DEBUG "%s : module %d not connected!\n", DEVICE_NAME, nMinor);
PRINTK(KERN_DEBUG "%s pcivme_open(): module %d not connected!\n", DEVICE_NAME, nMinor);
}
 
if (desc)
871,7 → 882,7
pp->AlignmentCheck = MisalignmentForByteAccess;
pFile->private_data = (void *)pp;
 
PRINTK(KERN_DEBUG "%s : found VMEMM module with number %d.\n", DEVICE_NAME, nMinor);
PRINTK(KERN_DEBUG "%s : pcivme_open() found VMEMM module with number %d.\n", DEVICE_NAME, nMinor);
 
if (!pd->nOpenCounter)
{
878,7 → 889,7
err = CmdMachine(pd, init_element);
if (err)
{
printk(KERN_ERR "%s : default init failed with err = %d!\n", DEVICE_NAME, err);
printk(KERN_ERR "%s : pcivme_open() default init failed with err = %d!\n", DEVICE_NAME, err);
kfree_s(pp, sizeof(*pp)); // FREE(pFile->private_data);
return err;
}
888,7 → 899,7
}
else
{
printk(KERN_ERR "%s : No VMEMM module found.\n", DEVICE_NAME);
printk(KERN_ERR "%s pcivme_open(): No VMEMM module found.\n", DEVICE_NAME);
return -ENODEV;
}
 
900,7 → 911,7
{
PATH_OBJ *pp;
 
PRINTK(KERN_DEBUG "%s : release()\n", DEVICE_NAME);
PRINTK(KERN_DEBUG "%s : pcivme_release()\n", DEVICE_NAME);
 
if (pFile->private_data)
{
1016,32 → 1027,43
}
 
 
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
struct file_operations pcivme_fops =
// http://learninglinuxkernel.in/writing-char-driver-for-linux-kernel-2-6/
// http://appusajeev.wordpress.com/2011/06/18/writing-a-linux-character-device-driver/
loff_t pcivme_lseek(struct file* filep, loff_t offset, int whence)
{
NULL, /* lseek */
pcivme_read, /* read */
pcivme_write, /* write */
NULL, /* readdir */
NULL, /* select */
pcivme_ioctl, /* ioctl */
NULL, /* mmap */
pcivme_open, /* open */
NULL, /* flush */
pcivme_release, /* release */
};
#else
 
PRINTK(KERN_DEBUG "%s : pcivme_lseek(0x%08x, %d)\n", DEVICE_NAME, (u32) offset, whence);
switch (whence) {
case 0: /* SEEK_SET */
filep->f_pos = offset;
break;
case 1: /* SEEK_CUR */
filep->f_pos += offset;
break;
case 2: /* SEEK_END */
return -EINVAL;
default:
return -EINVAL;
};
 
return filep->f_pos;
}
 
 
 
struct file_operations pcivme_fops =
{
.llseek = pcivme_lseek, /* lseek */
.read = pcivme_read, /* read */
.write = pcivme_write, /* write */
// .compat_ioctl = pcivme_compat_ioctl, /* ioctl */
.unlocked_ioctl = pcivme_unlocked_ioctl, /* ioctl */
.open = pcivme_open, /* open */
.release = pcivme_release, /* release */
};
#endif