Skip to content

Commit 2de30ff

Browse files
committed
[toup] zephyr: driver: Moved the driver ops in device data
Moved the driver ops from device->config to device->api as that makes more sense to have it there. Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
1 parent 1a58102 commit 2de30ff

File tree

1 file changed

+26
-20
lines changed

1 file changed

+26
-20
lines changed

src/drivers/driver_zephyr.c

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@
1616

1717
#define SCAN_TIMEOUT 30
1818

19+
const struct zep_wpa_supp_dev_ops *get_dev_ops(const struct device *dev)
20+
{
21+
struct net_wifi_mgmt_offload *api;
22+
23+
api = (struct net_wifi_mgmt_offload *)dev->api;
24+
25+
return api->wifi_drv_ops;
26+
}
27+
1928
void wpa_supplicant_event_wrapper(void *ctx,
2029
enum wpa_event_type event,
2130
union wpa_event_data *data)
@@ -60,8 +69,7 @@ static int wpa_drv_zep_abort_scan(void *priv,
6069

6170
if_ctx = priv;
6271

63-
dev_ops = if_ctx->dev_ctx->config;
64-
72+
dev_ops = get_dev_ops(if_ctx->dev_ctx);
6573
if (!dev_ops->scan_abort) {
6674
wpa_printf(MSG_ERROR,
6775
"%s: No op registered for scan_abort\n",
@@ -478,8 +486,7 @@ static int wpa_drv_register_frame(struct zep_drv_if_ctx *if_ctx,
478486
{
479487
const struct zep_wpa_supp_dev_ops *dev_ops = NULL;
480488

481-
dev_ops = if_ctx->dev_ctx->config;
482-
489+
dev_ops = get_dev_ops(if_ctx->dev_ctx);
483490
if (!dev_ops->register_frame)
484491
return -1;
485492

@@ -641,7 +648,7 @@ struct hostapd_hw_modes *wpa_drv_get_hw_feature_data(void *priv,
641648

642649
if_ctx = priv;
643650

644-
dev_ops = if_ctx->dev_ctx->config;
651+
dev_ops = get_dev_ops(if_ctx->dev_ctx);
645652

646653
struct phy_info_arg result = {
647654
.num_modes = num_modes,
@@ -718,7 +725,7 @@ static void *wpa_drv_zep_init(void *ctx,
718725
void *global_priv)
719726
{
720727
struct zep_drv_if_ctx *if_ctx = NULL;
721-
const struct zep_wpa_supp_dev_ops *dev_ops = NULL;
728+
const struct zep_wpa_supp_dev_ops *dev_ops;
722729
struct zep_wpa_supp_dev_callbk_fns callbk_fns;
723730
const struct device *device;
724731
struct net_if *iface;
@@ -741,7 +748,7 @@ static void *wpa_drv_zep_init(void *ctx,
741748
if_ctx->dev_ctx = device;
742749
if_ctx->drv_ctx = global_priv;
743750

744-
dev_ops = if_ctx->dev_ctx->config;
751+
dev_ops = get_dev_ops(if_ctx->dev_ctx);
745752
if (!dev_ops->init) {
746753
wpa_printf(MSG_ERROR,
747754
"%s: No op registered for init\n",
@@ -792,7 +799,7 @@ static void wpa_drv_zep_deinit(void *priv)
792799

793800
if_ctx = priv;
794801

795-
dev_ops = if_ctx->dev_ctx->config;
802+
dev_ops = get_dev_ops(if_ctx->dev_ctx);
796803
if (!dev_ops->deinit) {
797804
wpa_printf(MSG_ERROR, "%s: No op registered for deinit\n", __func__);
798805
return;
@@ -822,7 +829,7 @@ static int wpa_drv_zep_scan2(void *priv, struct wpa_driver_scan_params *params)
822829
goto out;
823830
}
824831

825-
dev_ops = if_ctx->dev_ctx->config;
832+
dev_ops = get_dev_ops(if_ctx->dev_ctx);
826833
if (!dev_ops->scan2) {
827834
wpa_printf(MSG_ERROR, "%s: No op registered for scan2\n", __func__);
828835
goto out;
@@ -881,7 +888,7 @@ struct wpa_scan_results *wpa_drv_zep_get_scan_results2(void *priv)
881888

882889
if_ctx = priv;
883890

884-
dev_ops = if_ctx->dev_ctx->config;
891+
dev_ops = get_dev_ops(if_ctx->dev_ctx);
885892
if (!dev_ops->get_scan_results2) {
886893
wpa_printf(MSG_ERROR,
887894
"%s: No op registered for scan2\n",
@@ -943,8 +950,7 @@ static int wpa_drv_zep_deauthenticate(void *priv, const u8 *addr,
943950

944951
if_ctx = priv;
945952

946-
dev_ops = if_ctx->dev_ctx->config;
947-
953+
dev_ops = get_dev_ops(if_ctx->dev_ctx);
948954
ret = dev_ops->deauthenticate(if_ctx->dev_priv, addr, reason_code);
949955
if (ret) {
950956
wpa_printf(MSG_ERROR, "%s: deauthenticate op failed\n", __func__);
@@ -972,7 +978,7 @@ static int wpa_drv_zep_authenticate(void *priv,
972978

973979
if_ctx = priv;
974980

975-
dev_ops = if_ctx->dev_ctx->config;
981+
dev_ops = get_dev_ops(if_ctx->dev_ctx);
976982

977983
os_memcpy(if_ctx->ssid, params->ssid, params->ssid_len);
978984

@@ -1011,7 +1017,7 @@ static int wpa_drv_zep_associate(void *priv,
10111017

10121018
if_ctx = priv;
10131019

1014-
dev_ops = if_ctx->dev_ctx->config;
1020+
dev_ops = get_dev_ops(if_ctx->dev_ctx);
10151021

10161022
ret = dev_ops->associate(if_ctx->dev_priv, params);
10171023
if (ret) {
@@ -1052,7 +1058,7 @@ static int _wpa_drv_zep_set_key(void *priv,
10521058
}
10531059

10541060
if_ctx = priv;
1055-
dev_ops = if_ctx->dev_ctx->config;
1061+
dev_ops = get_dev_ops(if_ctx->dev_ctx);
10561062

10571063
wpa_printf(MSG_DEBUG, "%s: priv:%p alg %d addr %p key_idx %d set_tx %d seq %p "
10581064
"seq_len %d key %p key_len %d\n",
@@ -1114,7 +1120,7 @@ static int wpa_drv_zep_get_capa(void *priv, struct wpa_driver_capa *capa)
11141120
}
11151121

11161122
if_ctx = priv;
1117-
dev_ops = if_ctx->dev_ctx->config;
1123+
dev_ops = get_dev_ops(if_ctx->dev_ctx);
11181124

11191125
if (!dev_ops->get_capa) {
11201126
wpa_printf(MSG_ERROR, "%s: get_capa op not supported\n", __func__);
@@ -1174,7 +1180,7 @@ static int wpa_drv_zep_set_supp_port(void *priv,
11741180

11751181
if_ctx = priv;
11761182

1177-
dev_ops = if_ctx->dev_ctx->config;
1183+
dev_ops = get_dev_ops(if_ctx->dev_ctx);
11781184

11791185
iface = net_if_lookup_by_dev(if_ctx->dev_ctx);
11801186

@@ -1209,7 +1215,7 @@ static int wpa_drv_zep_signal_poll(void *priv, struct wpa_signal_info *si)
12091215
}
12101216

12111217
if_ctx = priv;
1212-
dev_ops = if_ctx->dev_ctx->config;
1218+
dev_ops = get_dev_ops(if_ctx->dev_ctx);
12131219

12141220
os_memset(si, 0, sizeof(*si));
12151221

@@ -1242,7 +1248,7 @@ static int wpa_drv_zep_send_action(void *priv, unsigned int freq,
12421248
struct ieee80211_hdr *hdr;
12431249

12441250
if_ctx = priv;
1245-
dev_ops = if_ctx->dev_ctx->config;
1251+
dev_ops = get_dev_ops(if_ctx->dev_ctx);
12461252

12471253
wpa_printf(MSG_DEBUG, "wpa_supp: Send Action frame ("
12481254
"freq=%u MHz wait=%d ms no_cck=%d)",
@@ -1299,7 +1305,7 @@ static int wpa_drv_zep_get_conn_info(void *priv, struct wpa_conn_info *ci)
12991305
}
13001306

13011307
if_ctx = priv;
1302-
dev_ops = if_ctx->dev_ctx->config;
1308+
dev_ops = get_dev_ops(if_ctx->dev_ctx);
13031309

13041310
if (!dev_ops) {
13051311
wpa_printf(MSG_ERROR, "%s:Failed to get config handle\n", __func__);

0 commit comments

Comments
 (0)