设备通知链

直接上代码

static int brcm_device_event(struct notifier_block *unused, unsigned long event,
			     void *ptr)
{
	printk(KERN_INFO "brcm_device_event = %d\n", event);
	return NOTIFY_DONE;
}


static struct notifier_block brcm_notifier_block __read_mostly = {
	.notifier_call = brcm_device_event,
};

模块初始化部分

	ret = register_netdevice_notifier(&brcm_notifier_block);
	if (ret < 0) {
		printk(KERN_INFO "register_netdevice_notifier failed\n");
		return ret;
	}

模块退出需要unregister

unregister_netdevice_notifier(&brcm_notifier_block);

root@ZTE:/tmp# insmod bdcom-audit.ko 
[  414.723299] dpi_init start--
[  414.726366] brcm_device_event = 5
[  414.729743] brcm_device_event = 1
[  414.733102] brcm_device_event = 5
[  414.736428] brcm_device_event = 1
[  414.739779] brcm_device_event = 5
[  414.743155] brcm_device_event = 1
[  414.746527] brcm_device_event = 5
[  414.749887] brcm_device_event = 1
[  414.753249] brcm_device_event = 5
[  414.756603] brcm_device_event = 5
[  414.759928] brcm_device_event = 5
[  414.763280] brcm_device_event = 5
[  414.766657] brcm_device_event = 5
[  414.770033] brcm_device_event = 1
[  414.773460] brcm_device_event = 5
[  414.776823] brcm_device_event = 1
[  414.780144] brcm_device_event = 5
[  414.783500] brcm_device_event = 5

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值