1、rtc_class_ops填充 驱动主要工作是填充 rtc_class_ops结构体,结构体描述了RTC芯片能够提供的所有操作方式: struct rtc_class_ops { int (*open)(struct device *); void (*release)(struct device *); int (*ioctl)(struct device *, unsigned int, unsigned long); int (*read_time)(struct device ...
1、rtc_class_ops 填充 驱动主要工作是填充 rtc_class_ops结构体,结构体描述了RTC芯片能够提供的所有操作方式: 从log可得 5-0051: 5表示I2C通道5,0051表示从设备地址 rtc0 :注册的rtc设备为rtc0 2、class.c和RTC驱动注册 class.c文件在RTC驱动注册之前开始得到运行: 函数功能: 1、创建名为rtc的class 2、提...
编写RTC内核驱动的主要步骤就是填写rtc_class_ops。 这个结构体中使用的struct device参数就是rtc_device_register()使用的那个dev,它代表总线上的物理设备。这个 struct device的driver_data数据一般保存struct device的状态,包括指向rtc_device的指针。 驱动开发者至少应该提供read_time/set_time这两个接口,其他函数都...
2.2.2 rtc_class_ops structrtc_class_ops{int(*open)(structdevice *);void(*release)(structdevice *);int(*ioctl)(structdevice *,unsignedint,unsignedlong);int(*read_time)(structdevice *,structrtc_time *);int(*set_time)(structdevice *,structrtc_time *);int(*read_alarm)(structdevice *,s...
structrtc_device*rtc_device_register(constchar*name,structdevice*dev,conststructrtc_class_ops*ops,structmodule*owner) 函数参数和返回值含义 如下: - name:设备名字。 - dev:设备。 - ops:RTC底层驱动函数集。 - owner:驱动模块拥有者。 - 返回值: 注册成功的话就返回rtc_device,错误的话会返回一个负值...
首先rtc设备肯定是struct device的子类;系统中有多个RTC设备的时候,每个设备要有自己的ID和name;接下来的rtc_class_ops是一个非常关键的变量,它包含了设置时间、读取时间、设置闹钟,读取闹钟等回调函数,设备驱动中就是通过这些接口屏蔽硬件差异的,这会是实现设备驱动的关键部分;其它还有跟timer相关的变量、同步与互斥...
登录后复制//RTC设备structrtc_device{structdevicedev;structmodule*owner;intid;conststructrtc_class_ops*ops;//rtc操作函数structmutexops_lock;structcdevchar_dev;unsignedlongflags;unsignedlongirq_data;spinlock_tirq_lock;wait_queue_head_tirq_queue;structfasync_struct*async_queue;intirq_freq;intmax_user...
RTC设备在内核中是以字符设备形式存在的,内核中使用rtc_device结构体来抽象一个rtc设备。rtc_device结构体屏蔽了不同RTC硬件之间的差异,通过rtc_class_ops结构体为上层提供了访问硬件设备的统一接口,该结构体中包含了对硬件操作的相关函数。 rtc_class_ops结构体 ...
而在这个结构中rtc_class_ops函数需要驱动程序实现。 2. struct rtc_class_ops数据结构 代码语言:javascript 代码运行次数:0 运行 AI代码解释 struct rtc_class_ops { int (*open)(struct device *); void (*release)(struct device *); int (*ioctl)(struct device *, unsigned int, unsigned long); ...
static int rtc_proc_show(struct seq_file *seq, void *offset) { int err; struct rtc_device *rtc = seq->private; const struct rtc_class_ops *ops = rtc->ops; struct rtc_wkalrm alrm; struct rtc_time tm; err = rtc_read_time(rtc, &tm); //读取当前的时间 if (err == 0) { seq...