CAN核心初始化流程

文章目录初始化PF_CAN接口socket创建接口: can_create()协议注册: can_proto_register()初始化static __init int can_init(void){ printk(banner); // 创建接收者高速缓存 rcv_cache = kmem_cache_create("can_receiver", sizeof(struct receiver), 0, 0, NULL); if (!rcv_cache)
摘要由CSDN通过智能技术生成

初始化

static __init int can_init(void)
{
   
    printk(banner);

    // 创建接收者高速缓存
    rcv_cache = kmem_cache_create("can_receiver", sizeof(struct receiver), 0, 0, NULL);
    if (!rcv_cache)
        return -ENOMEM;

    /*
     * Insert can_rx_alldev_list for reception on all devices.
     * This struct is zero initialized which is correct for the
     * embedded hlist heads, the dev pointer, and the entries counter.
     */
    spin_lock(&can_rcvlists_lock);
    hlist_add_head_rcu(&can_rx_alldev_list.list, &can_rx_dev_list);
    spin_unlock(&can_rcvlists_lock);

    // 统计定时器
    if (stats_timer) {
   
        /* the statistics are updated every second (timer triggered) */
        setup_timer(&can_stattimer, can_stat_update, 0);
        mod_timer(&can_stattimer, round_jiffies(jiffies + HZ));
    } else
        can_stattimer.function = NULL;

    // 初始化proc文件节点
    can_init_proc();

    // 向系统注册PF_CAN协议族
    sock_register(&can_family_ops);
    // 监听CAN类型网络设备的注册&去注册
    register_netdevice_notifier(&can_netdev_notifier);
    // 向网络设备接口层注册接收ETH_P_CAN类型的数据包
    dev_add_pack
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值