Skip to content

Commit ed6ad65

Browse files
Tomasz Bursztykajukkar
Tomasz Bursztyka
authored andcommitted
drivers: cc2520: Make current driver for legacy stack only
Another driver will be made for native IP stack. This is meant to avoid cluttering the code with #ifdef all over the place. Instead driver will be transparently selected at built time. Change-Id: I283f1194fece9357425b87794b5cb51938ca80d3 Signed-off-by: Tomasz Bursztyka <[email protected]>
1 parent 4e7efd4 commit ed6ad65

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

drivers/ieee802154/ieee802154_cc2520.c

+12-20
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,9 @@
3434
#include <net/l2_buf.h>
3535
#include <packetbuf.h>
3636

37-
#define CONFIG_NETWORKING_LEGACY_RADIO_DRIVER
38-
39-
#ifdef CONFIG_NETWORKING_LEGACY_RADIO_DRIVER
4037
#include <dev/radio.h>
4138
#include <net_driver_15_4.h>
4239
static struct device *cc2520_sglt;
43-
#endif /* CONFIG_NETWORKING_LEGACY_RADIO_DRIVER */
4440

4541
#include "ieee802154_cc2520.h"
4642

@@ -680,7 +676,7 @@ static void cc2520_rx(int arg, int unused2)
680676
/********************
681677
* Radio device API *
682678
*******************/
683-
static int cc2520_set_channel(struct device *dev, uint16_t channel)
679+
static inline int cc2520_set_channel(struct device *dev, uint16_t channel)
684680
{
685681
struct cc2520_context *cc2520 = dev->driver_data;
686682

@@ -701,7 +697,7 @@ static int cc2520_set_channel(struct device *dev, uint16_t channel)
701697
return 0;
702698
}
703699

704-
static int cc2520_set_pan_id(struct device *dev, uint16_t pan_id)
700+
static inline int cc2520_set_pan_id(struct device *dev, uint16_t pan_id)
705701
{
706702
struct cc2520_context *cc2520 = dev->driver_data;
707703

@@ -717,7 +713,7 @@ static int cc2520_set_pan_id(struct device *dev, uint16_t pan_id)
717713
return 0;
718714
}
719715

720-
static int cc2520_set_short_addr(struct device *dev, uint16_t short_addr)
716+
static inline int cc2520_set_short_addr(struct device *dev, uint16_t short_addr)
721717
{
722718
struct cc2520_context *cc2520 = dev->driver_data;
723719

@@ -733,7 +729,8 @@ static int cc2520_set_short_addr(struct device *dev, uint16_t short_addr)
733729
return 0;
734730
}
735731

736-
static int cc2520_set_ieee_addr(struct device *dev, const uint8_t *ieee_addr)
732+
static inline int cc2520_set_ieee_addr(struct device *dev,
733+
const uint8_t *ieee_addr)
737734
{
738735
struct cc2520_context *cc2520 = dev->driver_data;
739736
uint8_t ext_addr[8];
@@ -755,7 +752,7 @@ static int cc2520_set_ieee_addr(struct device *dev, const uint8_t *ieee_addr)
755752
return 0;
756753
}
757754

758-
static int cc2520_tx(struct device *dev, struct net_buf *buf)
755+
static inline int cc2520_tx(struct device *dev, struct net_buf *buf)
759756
{
760757
struct cc2520_context *cc2520 = dev->driver_data;
761758
uint8_t retry = 2;
@@ -808,9 +805,9 @@ static int cc2520_tx(struct device *dev, struct net_buf *buf)
808805
return -EIO;
809806
}
810807

811-
static const uint8_t *cc2520_get_mac(struct device *dev)
808+
static inline uint8_t *cc2520_get_mac(struct device *dev)
812809
{
813-
struct cc2520_context *cc2520 = cc2520_sglt->driver_data;
810+
struct cc2520_context *cc2520 = dev->driver_data;
814811

815812
if (cc2520->mac_addr[1] == 0x00) {
816813
/* TI OUI */
@@ -828,9 +825,9 @@ static const uint8_t *cc2520_get_mac(struct device *dev)
828825
return cc2520->mac_addr;
829826
}
830827

831-
static int cc2520_start(struct device *dev)
828+
static inline int cc2520_start(struct device *dev)
832829
{
833-
struct cc2520_context *cc2520 = cc2520_sglt->driver_data;
830+
struct cc2520_context *cc2520 = dev->driver_data;
834831

835832
SYS_LOG_DBG("\n");
836833

@@ -848,9 +845,9 @@ static int cc2520_start(struct device *dev)
848845
return 0;
849846
}
850847

851-
static int cc2520_stop(struct device *dev)
848+
static inline int cc2520_stop(struct device *dev)
852849
{
853-
struct cc2520_context *cc2520 = cc2520_sglt->driver_data;
850+
struct cc2520_context *cc2520 = dev->driver_data;
854851

855852
SYS_LOG_DBG("\n");
856853

@@ -871,7 +868,6 @@ static int cc2520_stop(struct device *dev)
871868
/***************************
872869
* Legacy Radio device API *
873870
**************************/
874-
#ifdef CONFIG_NETWORKING_LEGACY_RADIO_DRIVER
875871
/**
876872
* NOTE: This legacy API DOES NOT FIT within Zephyr device driver model
877873
* and, as such, will be made obsolete soon (well, hopefully...)
@@ -1021,8 +1017,6 @@ struct radio_driver cc2520_15_4_radio_driver = {
10211017
.get_object = cc2520_get_object,
10221018
.set_object = cc2520_set_object,
10231019
};
1024-
#endif /* CONFIG_NETWORKING_LEGACY_RADIO_DRIVER */
1025-
10261020

10271021
/******************
10281022
* Initialization *
@@ -1157,9 +1151,7 @@ static int cc2520_init(struct device *dev)
11571151
cc2520_rx, POINTER_TO_INT(dev),
11581152
0, 0, 0);
11591153

1160-
#ifdef CONFIG_NETWORKING_LEGACY_RADIO_DRIVER
11611154
cc2520_sglt = dev;
1162-
#endif
11631155

11641156
return 0;
11651157
}

0 commit comments

Comments
 (0)