Skip to content

Commit 7dcacc1

Browse files
authored
Merge pull request #2235 from armink/fix_ops
[DeviceDriver][wlan] Add device ops to wlan.
2 parents d973007 + 59a4e4b commit 7dcacc1

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

components/drivers/wlan/wlan_dev.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,18 @@ static rt_err_t _rt_wlan_dev_control(rt_device_t dev, int cmd, void *args)
754754
return err;
755755
}
756756

757+
#ifdef RT_USING_DEVICE_OPS
758+
const static struct rt_device_ops wlan_ops =
759+
{
760+
_rt_wlan_dev_init,
761+
RT_NULL,
762+
RT_NULL,
763+
RT_NULL,
764+
RT_NULL,
765+
_rt_wlan_dev_control
766+
};
767+
#endif
768+
757769
rt_err_t rt_wlan_dev_register(struct rt_wlan_device *wlan, const char *name, const struct rt_wlan_dev_ops *ops, rt_uint32_t flag, void *user_data)
758770
{
759771
rt_err_t err = RT_EOK;
@@ -765,13 +777,18 @@ rt_err_t rt_wlan_dev_register(struct rt_wlan_device *wlan, const char *name, con
765777
}
766778

767779
rt_memset(wlan, 0, sizeof(struct rt_wlan_device));
768-
780+
781+
#ifdef RT_USING_DEVICE_OPS
782+
wlan->device.ops = &wlan_ops;
783+
#else
769784
wlan->device.init = _rt_wlan_dev_init;
770785
wlan->device.open = RT_NULL;
771786
wlan->device.close = RT_NULL;
772787
wlan->device.read = RT_NULL;
773788
wlan->device.write = RT_NULL;
774789
wlan->device.control = _rt_wlan_dev_control;
790+
#endif
791+
775792
wlan->device.user_data = RT_NULL;
776793

777794
wlan->device.type = RT_Device_Class_NetIf;

components/drivers/wlan/wlan_lwip.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,18 @@ static rt_err_t rt_wlan_lwip_protocol_send(rt_device_t device, struct pbuf *p)
372372
#endif
373373
}
374374

375+
#ifdef RT_USING_DEVICE_OPS
376+
const static struct rt_device_ops wlan_lwip_ops =
377+
{
378+
RT_NULL,
379+
RT_NULL,
380+
RT_NULL,
381+
RT_NULL,
382+
RT_NULL,
383+
rt_wlan_lwip_protocol_control
384+
};
385+
#endif
386+
375387
static struct rt_wlan_prot *rt_wlan_lwip_protocol_register(struct rt_wlan_prot *prot, struct rt_wlan_device *wlan)
376388
{
377389
struct eth_device *eth = RT_NULL;
@@ -417,12 +429,18 @@ static struct rt_wlan_prot *rt_wlan_lwip_protocol_register(struct rt_wlan_prot *
417429
rt_memset(lwip_prot, 0, sizeof(struct lwip_prot_des));
418430

419431
eth = &lwip_prot->eth;
432+
433+
#ifdef RT_USING_DEVICE_OPS
434+
eth->parent.ops = &wlan_lwip_ops;
435+
#else
420436
eth->parent.init = RT_NULL;
421437
eth->parent.open = RT_NULL;
422438
eth->parent.close = RT_NULL;
423439
eth->parent.read = RT_NULL;
424440
eth->parent.write = RT_NULL;
425441
eth->parent.control = rt_wlan_lwip_protocol_control;
442+
#endif
443+
426444
eth->parent.user_data = wlan;
427445
eth->eth_rx = RT_NULL;
428446
eth->eth_tx = rt_wlan_lwip_protocol_send;

0 commit comments

Comments
 (0)