CMP EMBEDDED.COM

Login | Register     Welcome Guest   IPS  
HOME DESIGN PRODUCTS COLUMNS E-LEARNING CONFERENCES CODE FORUMS/BLOGS NEWSLETTERS CONTACT FEATURES RSS RSS

Listing 6 CIO-CTR05 module ioctl() function

static int ctr05_ioctl(struct inode *iNode, struct file *filePtr,
unsigned int cmd, LONG arg)
{
int size = _IOC_SIZE(cmd);
int err = 0;
if (_IOC_TYPE(cmd) != IOCTL_MAGIC) return -EINVAL;
if (_IOC_NR(cmd) > IOCTL_MAXNR) return -EINVAL;
if (_IOC_DIR(cmd) & _IOC_READ) 
{
err = verify_area(VERIFY_WRITE, (void *)arg, size);
} 
else if (_IOC_DIR(cmd) & _IOC_WRITE) 
{
err =
verify_area(VERIFY_READ, (void *)arg, size);
}
if( err ) return( err );
if ( cmd == WAIT_FOR_INTERRUPT ) 
{
arm_counter( 1, 11 );
interruptible_sleep_on( &int_wq );
return( 0 );
} 
else 
{
return( -EINVAL );
}
}
Embedded.com Career Center
Ready for a change?
SEARCH JOBS

Browse all jobs

SPONSOR
RECENT JOB POSTINGS





 :