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 <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
Tomasz Bursztyka 2016-06-15 10:41:36 +02:00 committed by Jukka Rissanen
commit ed6ad65427

View file

@ -34,13 +34,9 @@
#include <net/l2_buf.h>
#include <packetbuf.h>
#define CONFIG_NETWORKING_LEGACY_RADIO_DRIVER
#ifdef CONFIG_NETWORKING_LEGACY_RADIO_DRIVER
#include <dev/radio.h>
#include <net_driver_15_4.h>
static struct device *cc2520_sglt;
#endif /* CONFIG_NETWORKING_LEGACY_RADIO_DRIVER */
#include "ieee802154_cc2520.h"
@ -680,7 +676,7 @@ flush:
/********************
* Radio device API *
*******************/
static int cc2520_set_channel(struct device *dev, uint16_t channel)
static inline int cc2520_set_channel(struct device *dev, uint16_t channel)
{
struct cc2520_context *cc2520 = dev->driver_data;
@ -701,7 +697,7 @@ static int cc2520_set_channel(struct device *dev, uint16_t channel)
return 0;
}
static int cc2520_set_pan_id(struct device *dev, uint16_t pan_id)
static inline int cc2520_set_pan_id(struct device *dev, uint16_t pan_id)
{
struct cc2520_context *cc2520 = dev->driver_data;
@ -717,7 +713,7 @@ static int cc2520_set_pan_id(struct device *dev, uint16_t pan_id)
return 0;
}
static int cc2520_set_short_addr(struct device *dev, uint16_t short_addr)
static inline int cc2520_set_short_addr(struct device *dev, uint16_t short_addr)
{
struct cc2520_context *cc2520 = dev->driver_data;
@ -733,7 +729,8 @@ static int cc2520_set_short_addr(struct device *dev, uint16_t short_addr)
return 0;
}
static int cc2520_set_ieee_addr(struct device *dev, const uint8_t *ieee_addr)
static inline int cc2520_set_ieee_addr(struct device *dev,
const uint8_t *ieee_addr)
{
struct cc2520_context *cc2520 = dev->driver_data;
uint8_t ext_addr[8];
@ -755,7 +752,7 @@ static int cc2520_set_ieee_addr(struct device *dev, const uint8_t *ieee_addr)
return 0;
}
static int cc2520_tx(struct device *dev, struct net_buf *buf)
static inline int cc2520_tx(struct device *dev, struct net_buf *buf)
{
struct cc2520_context *cc2520 = dev->driver_data;
uint8_t retry = 2;
@ -808,9 +805,9 @@ error:
return -EIO;
}
static const uint8_t *cc2520_get_mac(struct device *dev)
static inline uint8_t *cc2520_get_mac(struct device *dev)
{
struct cc2520_context *cc2520 = cc2520_sglt->driver_data;
struct cc2520_context *cc2520 = dev->driver_data;
if (cc2520->mac_addr[1] == 0x00) {
/* TI OUI */
@ -828,9 +825,9 @@ static const uint8_t *cc2520_get_mac(struct device *dev)
return cc2520->mac_addr;
}
static int cc2520_start(struct device *dev)
static inline int cc2520_start(struct device *dev)
{
struct cc2520_context *cc2520 = cc2520_sglt->driver_data;
struct cc2520_context *cc2520 = dev->driver_data;
SYS_LOG_DBG("\n");
@ -848,9 +845,9 @@ static int cc2520_start(struct device *dev)
return 0;
}
static int cc2520_stop(struct device *dev)
static inline int cc2520_stop(struct device *dev)
{
struct cc2520_context *cc2520 = cc2520_sglt->driver_data;
struct cc2520_context *cc2520 = dev->driver_data;
SYS_LOG_DBG("\n");
@ -871,7 +868,6 @@ static int cc2520_stop(struct device *dev)
/***************************
* Legacy Radio device API *
**************************/
#ifdef CONFIG_NETWORKING_LEGACY_RADIO_DRIVER
/**
* NOTE: This legacy API DOES NOT FIT within Zephyr device driver model
* and, as such, will be made obsolete soon (well, hopefully...)
@ -1021,8 +1017,6 @@ struct radio_driver cc2520_15_4_radio_driver = {
.get_object = cc2520_get_object,
.set_object = cc2520_set_object,
};
#endif /* CONFIG_NETWORKING_LEGACY_RADIO_DRIVER */
/******************
* Initialization *
@ -1157,9 +1151,7 @@ static int cc2520_init(struct device *dev)
cc2520_rx, POINTER_TO_INT(dev),
0, 0, 0);
#ifdef CONFIG_NETWORKING_LEGACY_RADIO_DRIVER
cc2520_sglt = dev;
#endif
return 0;
}