www.pudn.com > EXT.rar > simpleD.c


/*
* Copyright (C) 2004 Gexin TECH
* <zhaozhenfeng@263.net>
*
This file just for GX-ARM9-2410EP

Sat Feb 7 2004 Zhen-feng Zhao <zhaozhenfeng@263.net>
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file COPYING in the main directory of this archive
* for more details.
*/

#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/interrupt.h> /* for in_interrupt */
#include <linux/timer.h>
#include <linux/init.h>
#include <linux/delay.h> /* for udelay */
#include <linux/modversions.h>

#include <linux/version.h>
#include <asm/io.h>
#include <asm/irq.h>
#include <asm/hardware.h>



#define SimpleD_MAJOR 96


devfs_handle_t dev_handle; /* register handle to store device fs */
int SimpleD_temp_count=0;


ssize_t SimpleD_read (struct file * file ,char * buf, size_t count, loff_t * f_ops)
{

printk("s3c2410: device file-read operation!\n");

return count;
}

/*=========== SimpleD Write =======================*/
ssize_t SimpleD_write (struct file * file ,const char * buf, size_t count, loff_t * f_ops)
{

printk("s3c2410: device file-write operation!\n");

return count;
}



/*=========== SimpleD Ioctl =======================*/
ssize_t SimpleD_ioctl (struct inode * inode ,struct file * file,
unsigned int cmd, long data)
{
printk("s3c2410: device ioctl operation!\n");

}

/*============ SimpleD device open ==============*/
ssize_t SimpleD_open (struct inode * inode ,struct file * file)
{
return 0;
}

/*============ SimpleD device close =============*/
ssize_t SimpleD_release (struct inode * inode ,struct file * file)
{
devfs_unregister_chrdev( SimpleD_MAJOR, "SimpleD" );
devfs_unregister( dev_handle );

return 0;
}

struct file_operations SimpleD_ops ={

open: SimpleD_open,

read: SimpleD_read,

write: SimpleD_write,

ioctl: SimpleD_ioctl,

release: SimpleD_release,
};


static int __init HW_SimpleD_init(void)
{
int ret = -ENODEV;
int delay ;

ret = devfs_register_chrdev(SimpleD_MAJOR, "SimpleD", &amt;SimpleD_ops);

if( ret < 0 ){
printk (" s3c2410: init_module failed with >d\n", ret);
return ret;
}
else
{
printk(KERN_INFO" S3c2410 SimpleD register success!!!\n");
;
}

dev_handle = devfs_register( NULL, "SimpleD", DEVFS_FL_DEFAULT,
96, 0, S_IFCHR, &amt;SimpleD_ops, NULL);

//!!!!!!!!!!!!!!


return ret;
}


int __init s3c2410_SimpleD_init(void) {
int ret = -ENODEV;

ret = HW_SimpleD_init();
if (ret)
return ret;
return 0;
}
int init_module()
{
s3c2410_SimpleD_init();
}
void cleanup_module()
{

}