用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - android代码库

ubuntu a

2019-12-04 作者: 朱文波30举报

[android]代码库

#include <linux/init.h> 
#include <linux/module.h> 
#include <linux/types.h> 
#include <linux/fs.h> 
#include <linux/proc_fs.h> 
#include <linux/device.h> 
#include <asm/uaccess.h> 
   
#include "hello.h" 
   
/*主设备和从设备号变量*/ 
static int hello_major = 0
static int hello_minor = 0
   
/*设备类别和设备变量*/ 
static struct class* hello_class = NULL; 
static struct hello_android_dev* hello_dev = NULL; 
   
/*传统的设备文件操作方法*/ 
static int hello_open(struct inode* inode, struct file* filp); 
static int hello_release(struct inode* inode, struct file* filp); 
static ssize_t hello_read(struct file* filp, char __user *buf, size_t count, loff_t* f_pos); 
static ssize_t hello_write(struct file* filp, const char __user *buf, size_t count, loff_t* f_pos); 
   
/*设备文件操作方法表*/ 
static struct file_operations hello_fops = { 
    .owner = THIS_MODULE, 
    .open = hello_open, 
    .release = hello_release, 
    .read = hello_read, 
    .write = hello_write,  
}; 
   
/*访问设置属性方法*/ 
static ssize_t hello_val_show(struct device* dev, struct device_attribute* attr,  char* buf); 
static ssize_t hello_val_store(struct device* dev, struct device_attribute* attr, const char* buf, size_t count); 
   
/*定义设备属性*/ 
static DEVICE_ATTR(val, S_IRUGO | S_IWUSR, hello_val_show, hello_val_store);


网友评论    (发表评论)


发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...