1 // Copyright 2024 The Pigweed Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 // use this file except in compliance with the License. You may obtain a copy of 5 // the License at 6 // 7 // https://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 // License for the specific language governing permissions and limitations under 13 // the License. 14 15 #include "pw_bluetooth_sapphire/fuchsia/host/controllers/helpers.h" 16 17 namespace bt::controllers { 18 ZxStatusToPwStatus(zx_status_t status)19pw::Status ZxStatusToPwStatus(zx_status_t status) { 20 switch (status) { 21 case ZX_OK: 22 return PW_STATUS_OK; 23 case ZX_ERR_INTERNAL: 24 return pw::Status::Internal(); 25 case ZX_ERR_NOT_SUPPORTED: 26 return pw::Status::Unimplemented(); 27 case ZX_ERR_NO_RESOURCES: 28 return pw::Status::ResourceExhausted(); 29 case ZX_ERR_INVALID_ARGS: 30 return pw::Status::InvalidArgument(); 31 case ZX_ERR_OUT_OF_RANGE: 32 return pw::Status::OutOfRange(); 33 case ZX_ERR_CANCELED: 34 return pw::Status::Cancelled(); 35 case ZX_ERR_PEER_CLOSED: 36 return pw::Status::Unavailable(); 37 case ZX_ERR_NOT_FOUND: 38 return pw::Status::NotFound(); 39 case ZX_ERR_ALREADY_EXISTS: 40 return pw::Status::AlreadyExists(); 41 case ZX_ERR_UNAVAILABLE: 42 return pw::Status::Unavailable(); 43 case ZX_ERR_ACCESS_DENIED: 44 return pw::Status::PermissionDenied(); 45 case ZX_ERR_IO_DATA_LOSS: 46 return pw::Status::DataLoss(); 47 default: 48 return pw::Status::Unknown(); 49 } 50 } 51 52 } // namespace bt::controllers 53