设为首页 加入收藏

TOP

Linux 中断学习之小试牛刀篇(九)
2014-11-24 07:26:15 来源: 作者: 【 】 浏览:9
Tags:Linux 中断 习之 小试牛刀
ED) && !dev_id)
1064 return -EINVAL;
1065
1066 desc = irq_to_desc(irq);
1067 if (!desc)
1068 return -EINVAL;
1069
1070 if (desc->status & IRQ_NOREQUEST)
1071 return -EINVAL;
1072
1073 if (!handler) {
1074 if (!thread_fn)
1075 return -EINVAL;
1076 handler = irq_default_primary_handler;
1077 }
1078
1079 action = kzalloc(sizeof(struct irqaction), GFP_KERNEL);
1080 if (!action)
1081 return -ENOMEM;
1082
1083 action->handler = handler;
1084 action->thread_fn = thread_fn;
1085 action->flags = irqflags;
1086 action->name = devname;
1087 action->dev_id = dev_id;
1088
1089 chip_bus_lock(irq, desc);
1090 retval = __setup_irq(irq, desc, action);
1091 chip_bus_sync_unlock(irq, desc);
1092
1093 if (retval)
1094 kfree(action);
1095
1096#ifdef CONFIG_DEBUG_SHIRQ
1097 if (!retval && (irqflags & IRQF_SHARED)) {
1098 /*
1099 * It's a shared IRQ -- the driver ought to be prepared for it
1100 * to happen immediately, so let's make sure....
1101 * We disable the irq to make sure that a 'real' IRQ doesn't
1102 * run in parallel with our fake.
1103 */
1104 unsigned long flags;
1105
1106 disable_irq(irq);
1107 local_irq_save(flags);
1108
1109 handler(irq, dev_id);
1110
1111 local_irq_restore(flags);
1112 enable_irq(irq);
1113 }
1114#endif
1115 return retval;
1116}
1049int request_threaded_irq(unsigned int irq, irq_handler_t handler,
1050 irq_handler_t thread_fn, unsigned long irqflags,
1051 const char *devname, void *dev_id)
1052{
1053 struct irqaction *action;
1054 struct irq_desc *desc;
1055 int retval;
1056
1057 /*
1058 * Sanity-check: shared interrupts must pass in a real dev-ID,
1059 * otherwise we'll have trouble later trying to figure out
1060 * which interrupt is which (messes up the interrupt freeing
1061 * logic etc).
1062 */
1063 if ((irqflags & IRQF_SHARED) && !dev_id)
1064 return -EINVAL;
1065
1066 desc = irq_to_desc(irq);
1067 if (!desc)
1068 return -EINVAL;
1069
1070 if (desc->status & IRQ_NOREQUEST)
1071 return -EINVAL;
1072
1073 if (!handler) {
1074 if (!thread_fn)
1075 return -EINVAL;
1076 handler = irq_default_primary_handler;
1077 }
1078
1079 action = kzalloc(sizeof(struct irqaction), GFP_KERNEL);
1080 if (!action)
1081 return -ENOMEM;
1082
1083 action->handler = handler;
1084 action->thread_fn = thread_fn;
1085 action->flags = irqflags;
1086 action->name = devname;
1087 action->dev_id = dev_id;
1088
1089 chip_bus_lock(irq, desc);
1090 retval = __setup_irq(irq, desc, action);
1091 chip_bus_sync_unlock(irq, desc);
1092
109
首页 上一页 6 7 8 9 10 下一页 尾页 9/10/10
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Linux 中断学习之前言篇 中断之原.. 下一篇Linux之Git工具的使用

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·Java 学习线路图是怎 (2025-12-25 15:19:15)
·关于 Java 学习,有 (2025-12-25 15:19:12)
·有没有Java swing教 (2025-12-25 15:19:09)
·Start, Stop, and Di (2025-12-25 14:50:57)
·C语言入门教程:零基 (2025-12-25 14:50:54)