diff options
author | mullerf <mullerf@google.com> | 2021-06-08 12:23:01 -0700 |
---|---|---|
committer | Haiping Yang <haiping@google.com> | 2021-12-05 01:47:02 +0000 |
commit | 473e957da703cead5547347e882f65944c78f8d5 (patch) | |
tree | c30fc8f0c613cf8f928e174426745439723a4d65 | |
parent | ca563cc8a72a3430b35f0f2e579ea041e92d32be (diff) | |
download | wlan-473e957da703cead5547347e882f65944c78f8d5.tar.gz |
Map error to correct error code
This patch has been provided by the vendor.
Test: VtsHalWifiV1_3TargetTest passes all tests now
Bug: 186692129
Signed-off-by: mullerf <mullerf@google.com>
Change-Id: I9a4e9398f6fb1e95a9c314fca30c3e066acfd459
(cherry picked from commit 8b051c25bb8dcf644ebe90121473cd49d4c13fde)
-rwxr-xr-x | bcmdhd/wifi_hal/cpp_bindings.cpp | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/bcmdhd/wifi_hal/cpp_bindings.cpp b/bcmdhd/wifi_hal/cpp_bindings.cpp index 698789d..5311e6e 100755 --- a/bcmdhd/wifi_hal/cpp_bindings.cpp +++ b/bcmdhd/wifi_hal/cpp_bindings.cpp @@ -579,27 +579,56 @@ int WifiRequest::create(int family, uint8_t cmd, int flags, int hdrlen) { } } +static int mapErrorCodes(int err) +{ + int ret; + if (!err) { + return WIFI_SUCCESS; + } + switch (err) { + case -EOPNOTSUPP: + ret = WIFI_ERROR_NOT_SUPPORTED; + break; + case -ETIMEDOUT: + ret = WIFI_ERROR_TIMED_OUT; + break; + case -EINVAL: + ret = WIFI_ERROR_INVALID_ARGS; + break; + case -ENOMEM: + ret = WIFI_ERROR_OUT_OF_MEMORY; + break; + case -EBUSY: + ret = WIFI_ERROR_BUSY; + break; + default: + ret = WIFI_ERROR_UNKNOWN; + } + ALOGD("error code %d mapped to %d", err, ret); + return ret; +} + int WifiRequest::create(uint32_t id, int subcmd) { int res = create(NL80211_CMD_VENDOR); if (res < 0) { - return res; + return mapErrorCodes(res); } res = put_u32(NL80211_ATTR_VENDOR_ID, id); if (res < 0) { - return res; + return mapErrorCodes(res); } res = put_u32(NL80211_ATTR_VENDOR_SUBCMD, subcmd); if (res < 0) { - return res; + return mapErrorCodes(res); } if (mIface != -1) { res = set_iface_id(mIface); } - return res; + return mapErrorCodes(res); } @@ -646,7 +675,7 @@ int WifiCommand::requestResponse(WifiRequest& request) { out: nl_cb_put(cb); pthread_mutex_unlock(&ResponseMutex); - return err; + return mapErrorCodes(err); } int WifiCommand::requestEvent(int cmd) { @@ -675,7 +704,7 @@ int WifiCommand::requestEvent(int cmd) { out: wifi_unregister_handler(wifiHandle(), cmd); - return res; + return mapErrorCodes(res); } int WifiCommand::requestVendorEvent(uint32_t id, int subcmd) { @@ -699,7 +728,7 @@ int WifiCommand::requestVendorEvent(uint32_t id, int subcmd) { out: wifi_unregister_vendor_handler(wifiHandle(), id, subcmd); - return res; + return mapErrorCodes(res); } /* Event handlers */ |