首页 星云 工具 资源 星选 资讯 热门工具
:

PDF转图片 完全免费 小红书视频下载 无水印 抖音视频下载 无水印 数字星空

Linux异步通知机制-系统掉电保存文件

硬件开发 1.9KB 11 需要积分: 1
立即下载

资源介绍:

掉电保存驱动与应用
#include #include #include #include #include #include #include #include #include #define DEVICE_NAME "poweroffSave" static struct fasync_struct *async; /*poweroffSave struct save dts device node and irq num/line*/ struct poweroffSave { const struct device_node *devNode; int irq; }; struct poweroffSave poweroff; /*irq fun: * irq run , driver send async siganl to app * */ static irqreturn_t powerOff_irq(int irq, void *devid) { /*SIGIO:signal POLL_IN:only read*/ kill_fasync(&async,SIGIO,POLL_IN); return (IRQ_HANDLED); } static int poweroff_fasync (int fd, struct file *filp,int mode) { /*init fasync_struct*/ return fasync_helper(fd,filp,mode,&async); } /*sys call function:fasync*/ static struct file_operations poweroff_ops = { .owner = THIS_MODULE, .fasync = poweroff_fasync, }; static struct miscdevice poweroff_ops_dev = { .minor = MISC_DYNAMIC_MINOR, .name = DEVICE_NAME, .fops = &poweroff_ops, }; static int poweroffSave_probe(struct platform_device *device) { int ret; poweroff.devNode = of_find_node_by_path("/poweroffSave"); if(poweroff.devNode == NULL) { printk("poweroffSave node find fail\r\n"); return -1; } of_property_read_u32_array(poweroff.devNode,"irq",&poweroff.irq,1); /*request irq:ensure dts to irq line、irq mode*/ ret = request_irq(poweroff.irq,powerOff_irq,IRQ_TYPE_EDGE_FALLING,"poweroffIRQ",&poweroff); if(ret < 0) { printk("Failed to request irq %d\r\n",poweroff.irq); return ret; } /*register misc devcie*/ ret = misc_register(&poweroff_ops_dev); if(ret < 0) { printk("regitser misc_device error\r\n"); return -1; } return 0; } static int poweroffSave_remove(struct platform_device *device) { misc_deregister(&poweroff_ops_dev); free_irq(poweroff.irq,&poweroff); return 0; } static struct of_device_id poweroffSave_id[] = { {.compatible = "poweroffSave"}, {} }; static struct platform_driver powerOffSave_driver = { .probe = poweroffSave_probe, .remove = poweroffSave_remove, .driver ={ .owner = THIS_MODULE, .name = "poweroffSave", .of_match_table = poweroffSave_id, }, }; static int __init poweroffsave_init(void) { int err; err = platform_driver_register(&powerOffSave_driver); return 0; } static void __exit poweroffsave_exit(void) { platform_driver_unregister(&powerOffSave_driver); } module_init(poweroffsave_init); module_exit(poweroffsave_exit); MODULE_LICENSE("GPL");

资源文件列表:

poweroffSave.zip 大约有2个文件
  1. poweroffSave.c 1.12KB
  2. poweroffSave_drv.c 2.49KB
0评论
提交 加载更多评论
其他资源 嵌入式单片机开发 STM32HAL库 NRF24L01模块收发数据
嵌入式单片机开发 STM32HAL库 NRF24L01模块收发数据
根据表格内容来重命名表格文件名V1.0.0.zip
内含直接exe软件和py源代码,用户可以简单使用,也可以二次开发
Python实现给文件批量添加前缀.zip
内含源代码,适用零基础职场办公人员,支持二次开发
Qt QChart+Eigen库 绘制线性回归图表,源代码和库都在压缩包里
Qt QChart+Eigen库 绘制线性回归图表,源代码和库都在压缩包里
agv daochu1118.zip
agv daochu1118.zip
SM2258XT三星SSV4量产TOOL
SM2258XT三星SSV4量产TOOL
SM2258XT三星SSV4量产TOOL
02_源码资料.zip
02_源码资料.zip
inputCircle.zip
inputCircle.zip