wifi 中phy 设备的注册步骤

个人总结,不一定对。

1.  申请内存:

struct ieee80211_hw *hw;
        const struct wl12xx_platform_data *wlan_data;
        struct wl1271 *wl;
        int ret;
        /* We are only able to handle the wlan function */
        if (func->num != 0x02)
            return -ENODEV;
        hw = wl1271_alloc_hw();  
        if (IS_ERR(hw))
            return PTR_ERR(hw);
2. 初始化内容

  wl = hw->priv;
        wl->if_priv = func;
        wl->if_ops = &sdio_ops;
        /* Grab access to FN0 for ELP reg. */
        func->card->quirks |= MMC_QUIRK_LENIENT_FN0;
        wlan_data = wl12xx_get_platform_data();
        if (IS_ERR(wlan_data)) {
            ret = PTR_ERR(wlan_data);
            wl1271_error("missing wlan platform data: %d", ret);
            goto out_free;
        }
        wl->irq = wlan_data->irq;
        wl->ref_clock = wlan_data->board_ref_clock;
        ret = request_irq(wl->irq, wl1271_irq, 0, DRIVER_NAME, wl);
        if (ret < 0) {
            wl1271_error("request_irq() failed: %d", ret);
            goto out_free;
        }
        set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
        disable_irq(wl->irq);
        ret = wl1271_init_ieee80211(wl);   //初始化
        if (ret)
            goto out_irq;
3. 注册
ret = wl1271_register_hw(wl);
        if (ret)
            goto out_irq;
4. 赋值指针:
sdio_set_drvdata(func, wl);  

具体讨论:

1. wl1271_alloc_hw():
struct ieee80211_hw *wl1271_alloc_hw(void)
    {
        struct ieee80211_hw *hw;
        struct platform_device *plat_dev = NULL;
        struct wl1271 *wl;
        int i, ret;
        unsigned int order;
        hw = ieee80211_alloc_hw(sizeof(*wl), &wl1271_ops);  //申请ieee 802.11 phy hw 内存
        if (!hw) {
            wl1271_error("could not alloc ieee80211_hw");
            ret = -ENOMEM;
            goto err_hw_alloc;
        }
        plat_dev = kmemdup(&wl1271_device, sizeof(wl1271_device), GFP_KERNEL); //复制内存
        if (!plat_dev) {
            wl1271_error("could not allocate platform_device");
            ret = -ENOMEM;
            goto err_plat_alloc;
        }
        wl = hw->priv;
        memset(wl, 0, sizeof(*wl));    //wl初始化为0
        INIT_LIST_HEAD(&wl->list);    //初始化list
        wl->hw = hw;
        wl->plat_dev = plat_dev;
        skb_queue_head_init(&wl->tx_queue);
        INIT_DELAYED_WORK(&wl->elp_work, wl1271_elp_work);
        INIT_DELAYED_WORK(&wl->pspoll_work, wl1271_pspoll_work);
        INIT_WORK(&wl->irq_work, wl1271_irq_work);
        INIT_WORK(&wl->tx_work, wl1271_tx_work);
        INIT_WORK(&wl->recovery_work, wl1271_recovery_work);
        INIT_DELAYED_WORK(&wl->scan_complete_work, wl1271_scan_complete_work);

        wl->channel = WL1271_DEFAULT_CHANNEL;
        wl->beacon_int = WL1271_DEFAULT_BEACON_INT;
        wl->default_key = 0;
        wl->rx_counter = 0;
        wl->rx_config = WL1271_DEFAULT_RX_CONFIG;
        wl->rx_filter = WL1271_DEFAULT_RX_FILTER;
        wl->psm_entry_retry = 0;
        
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值