drivers: ieee802154: drop get_dev_data/get_dev_config usage
Replace all get_dev_data()/get_dev_config() accessor utilities with dev->data and dev->config. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
c5b596a0bf
commit
9b92dfeca8
2 changed files with 23 additions and 45 deletions
|
@ -59,12 +59,6 @@ static void ieee802154_cc13xx_cc26xx_rx_done(
|
|||
struct ieee802154_cc13xx_cc26xx_data *drv_data);
|
||||
static int ieee802154_cc13xx_cc26xx_stop(const struct device *dev);
|
||||
|
||||
static inline struct ieee802154_cc13xx_cc26xx_data *
|
||||
get_dev_data(const struct device *dev)
|
||||
{
|
||||
return dev->data;
|
||||
}
|
||||
|
||||
/* TODO remove when rf driver bugfix is pulled in */
|
||||
static void update_saved_cmdhandle(RF_CmdHandle ch, RF_CmdHandle *saved)
|
||||
{
|
||||
|
@ -77,7 +71,7 @@ static void cmd_ieee_csma_callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
|
|||
ARG_UNUSED(h);
|
||||
|
||||
const struct device *dev = &DEVICE_NAME_GET(ieee802154_cc13xx_cc26xx);
|
||||
struct ieee802154_cc13xx_cc26xx_data *drv_data = get_dev_data(dev);
|
||||
struct ieee802154_cc13xx_cc26xx_data *drv_data = dev->data;
|
||||
|
||||
update_saved_cmdhandle(ch, (RF_CmdHandle *) &drv_data->saved_cmdhandle);
|
||||
|
||||
|
@ -93,7 +87,7 @@ static void cmd_ieee_rx_callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
|
|||
ARG_UNUSED(h);
|
||||
|
||||
const struct device *dev = &DEVICE_NAME_GET(ieee802154_cc13xx_cc26xx);
|
||||
struct ieee802154_cc13xx_cc26xx_data *drv_data = get_dev_data(dev);
|
||||
struct ieee802154_cc13xx_cc26xx_data *drv_data = dev->data;
|
||||
|
||||
update_saved_cmdhandle(ch, (RF_CmdHandle *) &drv_data->saved_cmdhandle);
|
||||
|
||||
|
@ -135,7 +129,7 @@ ieee802154_cc13xx_cc26xx_get_capabilities(const struct device *dev)
|
|||
|
||||
static int ieee802154_cc13xx_cc26xx_cca(const struct device *dev)
|
||||
{
|
||||
struct ieee802154_cc13xx_cc26xx_data *drv_data = get_dev_data(dev);
|
||||
struct ieee802154_cc13xx_cc26xx_data *drv_data = dev->data;
|
||||
RF_Stat status;
|
||||
|
||||
status = RF_runImmediateCmd(drv_data->rf_handle,
|
||||
|
@ -161,7 +155,7 @@ static int ieee802154_cc13xx_cc26xx_set_channel(const struct device *dev,
|
|||
int r;
|
||||
RF_Stat status;
|
||||
RF_CmdHandle cmd_handle;
|
||||
struct ieee802154_cc13xx_cc26xx_data *drv_data = get_dev_data(dev);
|
||||
struct ieee802154_cc13xx_cc26xx_data *drv_data = dev->data;
|
||||
|
||||
/* TODO Support sub-GHz for CC13xx */
|
||||
if (channel < 11 || channel > 26) {
|
||||
|
@ -210,7 +204,7 @@ static int ieee802154_cc13xx_cc26xx_reset_channel(
|
|||
const struct device *dev)
|
||||
{
|
||||
uint8_t channel;
|
||||
struct ieee802154_cc13xx_cc26xx_data *drv_data = get_dev_data(dev);
|
||||
struct ieee802154_cc13xx_cc26xx_data *drv_data = dev->data;
|
||||
|
||||
/* extract the channel from cmd_ieee_rx */
|
||||
channel = drv_data->cmd_ieee_rx.channel;
|
||||
|
@ -227,7 +221,7 @@ ieee802154_cc13xx_cc26xx_filter(const struct device *dev, bool set,
|
|||
enum ieee802154_filter_type type,
|
||||
const struct ieee802154_filter *filter)
|
||||
{
|
||||
struct ieee802154_cc13xx_cc26xx_data *drv_data = get_dev_data(dev);
|
||||
struct ieee802154_cc13xx_cc26xx_data *drv_data = dev->data;
|
||||
|
||||
if (!set) {
|
||||
return -ENOTSUP;
|
||||
|
@ -253,7 +247,7 @@ static int ieee802154_cc13xx_cc26xx_set_txpower(const struct device *dev,
|
|||
{
|
||||
RF_Stat status;
|
||||
const RF_TxPowerTable_Entry *table;
|
||||
struct ieee802154_cc13xx_cc26xx_data *drv_data = get_dev_data(dev);
|
||||
struct ieee802154_cc13xx_cc26xx_data *drv_data = dev->data;
|
||||
|
||||
/* TODO Support sub-GHz for CC13xx */
|
||||
table = txPowerTable_2_4;
|
||||
|
@ -285,7 +279,7 @@ static int ieee802154_cc13xx_cc26xx_tx(const struct device *dev,
|
|||
RF_ScheduleCmdParams sched_params = {
|
||||
.allowDelay = true,
|
||||
};
|
||||
struct ieee802154_cc13xx_cc26xx_data *drv_data = get_dev_data(dev);
|
||||
struct ieee802154_cc13xx_cc26xx_data *drv_data = dev->data;
|
||||
bool ack = ieee802154_is_ar_flag_set(frag);
|
||||
int retry = CONFIG_IEEE802154_CC13XX_CC26XX_RADIO_TX_RETRIES;
|
||||
|
||||
|
@ -453,7 +447,7 @@ static int ieee802154_cc13xx_cc26xx_start(const struct device *dev)
|
|||
|
||||
static int ieee802154_cc13xx_cc26xx_stop(const struct device *dev)
|
||||
{
|
||||
struct ieee802154_cc13xx_cc26xx_data *drv_data = get_dev_data(dev);
|
||||
struct ieee802154_cc13xx_cc26xx_data *drv_data = dev->data;
|
||||
|
||||
RF_Stat status;
|
||||
|
||||
|
@ -480,7 +474,7 @@ ieee802154_cc13xx_cc26xx_configure(const struct device *dev,
|
|||
|
||||
static void ieee802154_cc13xx_cc26xx_data_init(const struct device *dev)
|
||||
{
|
||||
struct ieee802154_cc13xx_cc26xx_data *drv_data = get_dev_data(dev);
|
||||
struct ieee802154_cc13xx_cc26xx_data *drv_data = dev->data;
|
||||
uint8_t *mac;
|
||||
|
||||
if (sys_read32(CCFG_BASE + CCFG_O_IEEE_MAC_0) != 0xFFFFFFFF &&
|
||||
|
@ -517,7 +511,7 @@ static void ieee802154_cc13xx_cc26xx_data_init(const struct device *dev)
|
|||
static void ieee802154_cc13xx_cc26xx_iface_init(struct net_if *iface)
|
||||
{
|
||||
const struct device *dev = net_if_get_device(iface);
|
||||
struct ieee802154_cc13xx_cc26xx_data *drv_data = get_dev_data(dev);
|
||||
struct ieee802154_cc13xx_cc26xx_data *drv_data = dev->data;
|
||||
|
||||
net_if_set_link_addr(iface, drv_data->mac, sizeof(drv_data->mac),
|
||||
NET_LINK_IEEE802154);
|
||||
|
@ -549,7 +543,7 @@ static int ieee802154_cc13xx_cc26xx_init(const struct device *dev)
|
|||
.rfMode = RF_MODE_MULTIPLE,
|
||||
.cpePatchFxn = &rf_patch_cpe_multi_protocol,
|
||||
};
|
||||
struct ieee802154_cc13xx_cc26xx_data *drv_data = get_dev_data(dev);
|
||||
struct ieee802154_cc13xx_cc26xx_data *drv_data = dev->data;
|
||||
|
||||
/* Initialize driver data */
|
||||
ieee802154_cc13xx_cc26xx_data_init(dev);
|
||||
|
|
|
@ -132,19 +132,12 @@ static inline bool is_subghz(uint16_t channel)
|
|||
return (channel <= IEEE802154_SUB_GHZ_CHANNEL_MAX);
|
||||
}
|
||||
|
||||
static inline struct ieee802154_cc13xx_cc26xx_subg_data *
|
||||
get_dev_data(const struct device *dev)
|
||||
{
|
||||
return dev->data;
|
||||
}
|
||||
|
||||
static void cmd_prop_tx_adv_callback(RF_Handle h, RF_CmdHandle ch,
|
||||
RF_EventMask e)
|
||||
{
|
||||
const struct device *dev =
|
||||
&DEVICE_NAME_GET(ieee802154_cc13xx_cc26xx_subg);
|
||||
struct ieee802154_cc13xx_cc26xx_subg_data *drv_data =
|
||||
get_dev_data(dev);
|
||||
struct ieee802154_cc13xx_cc26xx_subg_data *drv_data = dev->data;
|
||||
RF_Op *op = RF_getCmdOp(h, ch);
|
||||
|
||||
LOG_DBG("ch: %u cmd: %04x cs st: %04x tx st: %04x e: 0x%" PRIx64, ch,
|
||||
|
@ -156,8 +149,7 @@ static void cmd_prop_rx_adv_callback(RF_Handle h, RF_CmdHandle ch,
|
|||
{
|
||||
const struct device *dev =
|
||||
&DEVICE_NAME_GET(ieee802154_cc13xx_cc26xx_subg);
|
||||
struct ieee802154_cc13xx_cc26xx_subg_data *drv_data =
|
||||
get_dev_data(dev);
|
||||
struct ieee802154_cc13xx_cc26xx_subg_data *drv_data = dev->data;
|
||||
RF_Op *op = RF_getCmdOp(h, ch);
|
||||
|
||||
LOG_DBG("ch: %u cmd: %04x st: %04x e: 0x%" PRIx64, ch,
|
||||
|
@ -201,8 +193,7 @@ ieee802154_cc13xx_cc26xx_subg_get_capabilities(const struct device *dev)
|
|||
|
||||
static int ieee802154_cc13xx_cc26xx_subg_cca(const struct device *dev)
|
||||
{
|
||||
struct ieee802154_cc13xx_cc26xx_subg_data *drv_data =
|
||||
get_dev_data(dev);
|
||||
struct ieee802154_cc13xx_cc26xx_subg_data *drv_data = dev->data;
|
||||
RF_Stat status;
|
||||
|
||||
drv_data->cmd_prop_cs.status = IDLE;
|
||||
|
@ -228,8 +219,7 @@ static int ieee802154_cc13xx_cc26xx_subg_cca(const struct device *dev)
|
|||
|
||||
static int ieee802154_cc13xx_cc26xx_subg_rx(const struct device *dev)
|
||||
{
|
||||
struct ieee802154_cc13xx_cc26xx_subg_data *drv_data =
|
||||
get_dev_data(dev);
|
||||
struct ieee802154_cc13xx_cc26xx_subg_data *drv_data = dev->data;
|
||||
RF_CmdHandle cmd_handle;
|
||||
|
||||
/* Set all RX entries to empty */
|
||||
|
@ -250,8 +240,7 @@ static int ieee802154_cc13xx_cc26xx_subg_rx(const struct device *dev)
|
|||
static int ieee802154_cc13xx_cc26xx_subg_set_channel(
|
||||
const struct device *dev, uint16_t channel)
|
||||
{
|
||||
struct ieee802154_cc13xx_cc26xx_subg_data *drv_data =
|
||||
get_dev_data(dev);
|
||||
struct ieee802154_cc13xx_cc26xx_subg_data *drv_data = dev->data;
|
||||
RF_EventMask reason;
|
||||
uint16_t freq, fract;
|
||||
int r;
|
||||
|
@ -309,7 +298,7 @@ ieee802154_cc13xx_cc26xx_subg_filter(const struct device *dev, bool set,
|
|||
static int ieee802154_cc13xx_cc26xx_subg_set_txpower(
|
||||
const struct device *dev, int16_t dbm)
|
||||
{
|
||||
struct ieee802154_cc13xx_cc26xx_subg_data *drv_data = get_dev_data(dev);
|
||||
struct ieee802154_cc13xx_cc26xx_subg_data *drv_data = dev->data;
|
||||
RF_Stat status;
|
||||
|
||||
RF_TxPowerTable_Value power_table_value = RF_TxPowerTable_findValue(
|
||||
|
@ -335,8 +324,7 @@ static int ieee802154_cc13xx_cc26xx_subg_tx(const struct device *dev,
|
|||
struct net_pkt *pkt,
|
||||
struct net_buf *frag)
|
||||
{
|
||||
struct ieee802154_cc13xx_cc26xx_subg_data *drv_data =
|
||||
get_dev_data(dev);
|
||||
struct ieee802154_cc13xx_cc26xx_subg_data *drv_data = dev->data;
|
||||
int retry = CONFIG_IEEE802154_CC13XX_CC26XX_SUB_GHZ_RADIO_TX_RETRIES;
|
||||
RF_EventMask reason;
|
||||
int r;
|
||||
|
@ -511,8 +499,7 @@ static int ieee802154_cc13xx_cc26xx_subg_start(const struct device *dev)
|
|||
*/
|
||||
static int ieee802154_cc13xx_cc26xx_subg_stop(const struct device *dev)
|
||||
{
|
||||
struct ieee802154_cc13xx_cc26xx_subg_data *drv_data =
|
||||
get_dev_data(dev);
|
||||
struct ieee802154_cc13xx_cc26xx_subg_data *drv_data = dev->data;
|
||||
RF_Stat status;
|
||||
|
||||
status = RF_flushCmd(drv_data->rf_handle, RF_CMDHANDLE_FLUSH_ALL, 0);
|
||||
|
@ -533,8 +520,7 @@ static int ieee802154_cc13xx_cc26xx_subg_stop(const struct device *dev)
|
|||
*/
|
||||
static int ieee802154_cc13xx_cc26xx_subg_stop_if(const struct device *dev)
|
||||
{
|
||||
struct ieee802154_cc13xx_cc26xx_subg_data *drv_data =
|
||||
get_dev_data(dev);
|
||||
struct ieee802154_cc13xx_cc26xx_subg_data *drv_data = dev->data;
|
||||
int ret;
|
||||
|
||||
ret = ieee802154_cc13xx_cc26xx_subg_stop(dev);
|
||||
|
@ -612,8 +598,7 @@ static void ieee802154_cc13xx_cc26xx_subg_data_init(
|
|||
static void ieee802154_cc13xx_cc26xx_subg_iface_init(struct net_if *iface)
|
||||
{
|
||||
const struct device *dev = net_if_get_device(iface);
|
||||
struct ieee802154_cc13xx_cc26xx_subg_data *drv_data =
|
||||
get_dev_data(dev);
|
||||
struct ieee802154_cc13xx_cc26xx_subg_data *drv_data = dev->data;
|
||||
|
||||
net_if_set_link_addr(iface, drv_data->mac, sizeof(drv_data->mac),
|
||||
NET_LINK_IEEE802154);
|
||||
|
@ -644,8 +629,7 @@ static int ieee802154_cc13xx_cc26xx_subg_init(const struct device *dev)
|
|||
{
|
||||
RF_Params rf_params;
|
||||
RF_EventMask reason;
|
||||
struct ieee802154_cc13xx_cc26xx_subg_data *drv_data =
|
||||
get_dev_data(dev);
|
||||
struct ieee802154_cc13xx_cc26xx_subg_data *drv_data = dev->data;
|
||||
|
||||
/* Initialize driver data */
|
||||
ieee802154_cc13xx_cc26xx_subg_data_init(drv_data);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue