1
0
mirror of git://projects.qi-hardware.com/nn-usb-fpga.git synced 2025-04-21 12:27:27 +03:00

Adding write funtions to blink driver sample

This commit is contained in:
Carlos Camargo
2010-05-04 11:17:38 -05:00
parent 07888ac4c4
commit de9acb468b
6 changed files with 79 additions and 142 deletions

View File

@@ -61,12 +61,30 @@ static int device_open(struct inode *inode, struct file *file)
return SUCCESS;
}
static ssize_t
device_write(struct file *filp, const char *buff, size_t count, loff_t * off)
{
const char cmd = buff[0];
if(cmd=='Q')
{
printk(KERN_INFO "Q...\n");
gpio_set_value(LED_PIN, 1);
}
else
if(cmd=='S'){
printk(KERN_INFO "S...\n");
gpio_set_value(LED_PIN, 0);
}
return 1;
}
static int device_release(struct inode *inode, struct file *file)
{
is_device_open = 0;
gpio_set_value(LED_PIN, 0);
module_put(THIS_MODULE);
printk( KERN_INFO "Close BLINKER\n" );
@@ -76,6 +94,7 @@ static int device_release(struct inode *inode, struct file *file)
struct file_operations fops = {
.open = device_open,
.write = device_write,
.release = device_release,
};