金牌会员
- 积分
- 1045
- 金钱
- 1045
- 注册时间
- 2020-8-4
- 在线时间
- 247 小时
|
楼主 |
发表于 2020-12-4 09:28:14
|
显示全部楼层
static ssize_t led_read(struct file *filp, char __user *buf, size_t cnt, loff_t *offt)
{
int retvalue;
unsigned char databuf[1];
unsigned char ledstat;
struct gpioled_dev *dev = filp->private_data;
retvalue = gpio_get_value(dev->led_gpio);
if(retvalue < 0) {
printk("gpio read failed!\r\n");
return -EFAULT;
} else if(ledstat == 0) {
databuf[0] = 1;
} else {
databuf[0] = 0;
}
retvalue = copy_to_user(buf, databuf, cnt);
if(retvalue < 0) {
printk("kernel read failed!\r\n");
return -EFAULT;
}
return 0;
}
这是加入的代码 |
|