From 1475aad76869af30a338734c21b7992f71098557 Mon Sep 17 00:00:00 2001 From: Dustin Brown Date: Tue, 5 Feb 2019 12:47:43 -0800 Subject: [PATCH] qcacmn: Move qdf_status_to/from_os_return() QDF_STATUS is defined in qdf_status, but related APIs qdf_status_to_os_return() and qdf_status_from_os_return() are defined in qdf_util. Create a new file, qdf_status.c, and move these functions there instead. Change-Id: Iaa2efa5f662be014a61a8490c3fab411ec0f2054 CRs-Fixed: 2395178 --- qdf/Kbuild | 1 + qdf/inc/qdf_status.h | 23 ++++++- qdf/inc/qdf_types.h | 1 + qdf/inc/qdf_util.h | 24 +------ qdf/linux/src/i_qdf_types.h | 2 - qdf/linux/src/i_qdf_util.h | 127 ++--------------------------------- qdf/linux/src/qdf_status.c | 130 ++++++++++++++++++++++++++++++++++++ 7 files changed, 157 insertions(+), 151 deletions(-) create mode 100644 qdf/linux/src/qdf_status.c diff --git a/qdf/Kbuild b/qdf/Kbuild index fd3d1dd55e..b1468c5272 100644 --- a/qdf/Kbuild +++ b/qdf/Kbuild @@ -48,6 +48,7 @@ linux/src/qdf_module.o \ linux/src/qdf_net_if.o \ linux/src/qdf_nbuf.o \ linux/src/qdf_perf.o \ +linux/src/qdf_status.o \ linux/src/qdf_threads.o \ linux/src/qdf_trace.o \ linux/src/qdf_vfs.o \ diff --git a/qdf/inc/qdf_status.h b/qdf/inc/qdf_status.h index 00fe806028..76274084f6 100644 --- a/qdf/inc/qdf_status.h +++ b/qdf/inc/qdf_status.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2014-2019 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -22,7 +22,7 @@ * Basic status codes/definitions used by QDF */ -#if !defined(__QDF_STATUS_H) +#ifndef __QDF_STATUS_H #define __QDF_STATUS_H /** @@ -139,4 +139,21 @@ typedef enum { #define QDF_IS_STATUS_SUCCESS(status) (QDF_STATUS_SUCCESS == (status)) #define QDF_IS_STATUS_ERROR(status) (QDF_STATUS_SUCCESS != (status)) -#endif /* if !defined __QDF_STATUS_H */ +/** + * qdf_status_to_os_return() - map a QDF_STATUS into an OS specific return code + * @status: QDF_STATUS to map + * + * Return: an OS specific error code + */ +int qdf_status_to_os_return(QDF_STATUS status); + +/** + * qdf_status_from_os_return() - map an OS specific return code to a QDF_STATUS + * @rc: the input return code to map + * + * Return: QDF_STATUS + */ +QDF_STATUS qdf_status_from_os_return(int rc); + +#endif /* __QDF_STATUS_H */ + diff --git a/qdf/inc/qdf_types.h b/qdf/inc/qdf_types.h index 6e6031d086..74ec0fb527 100644 --- a/qdf/inc/qdf_types.h +++ b/qdf/inc/qdf_types.h @@ -38,6 +38,7 @@ #ifdef TSOSEG_DEBUG #include #endif +#include "qdf_status.h" /* Preprocessor definitions and constants */ #define QDF_MAX_SGLIST 4 diff --git a/qdf/inc/qdf_util.h b/qdf/inc/qdf_util.h index 7b49357a44..d1ebb6fb7d 100644 --- a/qdf/inc/qdf_util.h +++ b/qdf/inc/qdf_util.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2014-2019 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -122,28 +122,6 @@ typedef __qdf_wait_queue_head_t qdf_wait_queue_head_t; #define qdf_ewma_tx_lag_read(tx_lag) \ __qdf_ewma_tx_lag_read(tx_lag) -/** - * qdf_status_to_os_return - returns the status to OS. - * @status: enum QDF_STATUS - * - * returns: int status success/failure - */ -static inline int qdf_status_to_os_return(QDF_STATUS status) -{ - return __qdf_status_to_os_return(status); -} - -/** - * qdf_status_from_os_return() - map OS specific return code to a QDF_STATUS - * @rc: the input return code to map - * - * Return: QDF_STATUS - */ -static inline QDF_STATUS qdf_status_from_os_return(int rc) -{ - return __qdf_status_from_os_return(rc); -} - /** * qdf_set_bit() - set bit in address * @nr: bit number to be set diff --git a/qdf/linux/src/i_qdf_types.h b/qdf/linux/src/i_qdf_types.h index c8fa221fd8..d23a1b90d7 100644 --- a/qdf/linux/src/i_qdf_types.h +++ b/qdf/linux/src/i_qdf_types.h @@ -24,8 +24,6 @@ #if !defined(__I_QDF_TYPES_H) #define __I_QDF_TYPES_H -#include - #ifndef __KERNEL__ #define __iomem #endif diff --git a/qdf/linux/src/i_qdf_util.h b/qdf/linux/src/i_qdf_util.h index 1f66d2cd32..d29a939125 100644 --- a/qdf/linux/src/i_qdf_util.h +++ b/qdf/linux/src/i_qdf_util.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2014-2019 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -35,7 +35,6 @@ #include #include -#include #include #if LINUX_VERSION_CODE <= KERNEL_VERSION(3, 3, 8) @@ -61,12 +60,10 @@ typedef wait_queue_head_t __qdf_wait_queue_head_t; /* Generic compiler-dependent macros if defined by the OS */ #define __qdf_wait_queue_interruptible(wait_queue, condition) \ - wait_event_interruptible(wait_queue, condition) + wait_event_interruptible(wait_queue, condition) -#define __qdf_wait_queue_timeout( \ - wait_queue, condition, timeout) \ - wait_event_timeout(wait_queue, condition,\ - timeout) +#define __qdf_wait_queue_timeout(wait_queue, condition, timeout) \ + wait_event_timeout(wait_queue, condition, timeout) #define __qdf_init_waitqueue_head(_q) init_waitqueue_head(_q) @@ -75,127 +72,11 @@ typedef wait_queue_head_t __qdf_wait_queue_head_t; #define __qdf_wake_up(_q) wake_up(_q) - #define __qdf_wake_up_completion(_q) wake_up_completion(_q) #define __qdf_unlikely(_expr) unlikely(_expr) #define __qdf_likely(_expr) likely(_expr) -/** - * __qdf_status_to_os_return() - translates qdf_status types to linux return types - * @status: status to translate - * - * Translates error types that linux may want to handle specially. - * - * return: 0 or the linux error code that most closely matches the QDF_STATUS. - * defaults to -1 (EPERM) - */ -static inline int __qdf_status_to_os_return(QDF_STATUS status) -{ - switch (status) { - case QDF_STATUS_SUCCESS: - return 0; - case QDF_STATUS_E_RESOURCES: - return -EBUSY; - case QDF_STATUS_E_NOMEM: - return -ENOMEM; - case QDF_STATUS_E_AGAIN: - return -EAGAIN; - case QDF_STATUS_E_INVAL: - return -EINVAL; - case QDF_STATUS_E_FAULT: - return -EFAULT; - case QDF_STATUS_E_ALREADY: - return -EALREADY; - case QDF_STATUS_E_BADMSG: - return -EBADMSG; - case QDF_STATUS_E_BUSY: - return -EBUSY; - case QDF_STATUS_E_CANCELED: - return -ECANCELED; - case QDF_STATUS_E_ABORTED: - return -ECONNABORTED; - case QDF_STATUS_E_PERM: - return -EPERM; - case QDF_STATUS_E_EXISTS: - return -EEXIST; - case QDF_STATUS_E_NOENT: - return -ENOENT; - case QDF_STATUS_E_E2BIG: - return -E2BIG; - case QDF_STATUS_E_NOSPC: - return -ENOSPC; - case QDF_STATUS_E_ADDRNOTAVAIL: - return -EADDRNOTAVAIL; - case QDF_STATUS_E_ENXIO: - return -ENXIO; - case QDF_STATUS_E_NETDOWN: - return -ENETDOWN; - case QDF_STATUS_E_IO: - return -EIO; - case QDF_STATUS_E_NETRESET: - return -ENETRESET; - case QDF_STATUS_E_PENDING: - return -EINPROGRESS; - case QDF_STATUS_E_TIMEOUT: - return -ETIMEDOUT; - default: - return -EPERM; - } -} - -static inline QDF_STATUS __qdf_status_from_os_return(int rc) -{ - switch (rc) { - case 0: - return QDF_STATUS_SUCCESS; - case -ENOMEM: - return QDF_STATUS_E_NOMEM; - case -EAGAIN: - return QDF_STATUS_E_AGAIN; - case -EINVAL: - return QDF_STATUS_E_INVAL; - case -EFAULT: - return QDF_STATUS_E_FAULT; - case -EALREADY: - return QDF_STATUS_E_ALREADY; - case -EBADMSG: - return QDF_STATUS_E_BADMSG; - case -EBUSY: - return QDF_STATUS_E_BUSY; - case -ECANCELED: - return QDF_STATUS_E_CANCELED; - case -ECONNABORTED: - return QDF_STATUS_E_ABORTED; - case -EPERM: - return QDF_STATUS_E_PERM; - case -EEXIST: - return QDF_STATUS_E_EXISTS; - case -ENOENT: - return QDF_STATUS_E_NOENT; - case -E2BIG: - return QDF_STATUS_E_E2BIG; - case -ENOSPC: - return QDF_STATUS_E_NOSPC; - case -EADDRNOTAVAIL: - return QDF_STATUS_E_ADDRNOTAVAIL; - case -ENXIO: - return QDF_STATUS_E_ENXIO; - case -ENETDOWN: - return QDF_STATUS_E_NETDOWN; - case -EIO: - return QDF_STATUS_E_IO; - case -ENETRESET: - return QDF_STATUS_E_NETRESET; - case -EINPROGRESS: - return QDF_STATUS_E_PENDING; - case -ETIMEDOUT: - return QDF_STATUS_E_TIMEOUT; - default: - return QDF_STATUS_E_PERM; - } -} - /** * __qdf_set_bit() - set bit in address * @nr: bit number to be set diff --git a/qdf/linux/src/qdf_status.c b/qdf/linux/src/qdf_status.c new file mode 100644 index 0000000000..f96e27392e --- /dev/null +++ b/qdf/linux/src/qdf_status.c @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2014-2019 The Linux Foundation. All rights reserved. + * + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all + * copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL + * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#include "linux/errno.h" +#include "qdf_module.h" +#include "qdf_status.h" + +int qdf_status_to_os_return(QDF_STATUS status) +{ + switch (status) { + case QDF_STATUS_SUCCESS: + return 0; + case QDF_STATUS_E_RESOURCES: + return -EBUSY; + case QDF_STATUS_E_NOMEM: + return -ENOMEM; + case QDF_STATUS_E_AGAIN: + return -EAGAIN; + case QDF_STATUS_E_INVAL: + return -EINVAL; + case QDF_STATUS_E_FAULT: + return -EFAULT; + case QDF_STATUS_E_ALREADY: + return -EALREADY; + case QDF_STATUS_E_BADMSG: + return -EBADMSG; + case QDF_STATUS_E_BUSY: + return -EBUSY; + case QDF_STATUS_E_CANCELED: + return -ECANCELED; + case QDF_STATUS_E_ABORTED: + return -ECONNABORTED; + case QDF_STATUS_E_PERM: + return -EPERM; + case QDF_STATUS_E_EXISTS: + return -EEXIST; + case QDF_STATUS_E_NOENT: + return -ENOENT; + case QDF_STATUS_E_E2BIG: + return -E2BIG; + case QDF_STATUS_E_NOSPC: + return -ENOSPC; + case QDF_STATUS_E_ADDRNOTAVAIL: + return -EADDRNOTAVAIL; + case QDF_STATUS_E_ENXIO: + return -ENXIO; + case QDF_STATUS_E_NETDOWN: + return -ENETDOWN; + case QDF_STATUS_E_IO: + return -EIO; + case QDF_STATUS_E_NETRESET: + return -ENETRESET; + case QDF_STATUS_E_PENDING: + return -EINPROGRESS; + case QDF_STATUS_E_TIMEOUT: + return -ETIMEDOUT; + default: + return -EPERM; + } +} +qdf_export_symbol(qdf_status_to_os_return); + +QDF_STATUS qdf_status_from_os_return(int rc) +{ + switch (rc) { + case 0: + return QDF_STATUS_SUCCESS; + case -ENOMEM: + return QDF_STATUS_E_NOMEM; + case -EAGAIN: + return QDF_STATUS_E_AGAIN; + case -EINVAL: + return QDF_STATUS_E_INVAL; + case -EFAULT: + return QDF_STATUS_E_FAULT; + case -EALREADY: + return QDF_STATUS_E_ALREADY; + case -EBADMSG: + return QDF_STATUS_E_BADMSG; + case -EBUSY: + return QDF_STATUS_E_BUSY; + case -ECANCELED: + return QDF_STATUS_E_CANCELED; + case -ECONNABORTED: + return QDF_STATUS_E_ABORTED; + case -EPERM: + return QDF_STATUS_E_PERM; + case -EEXIST: + return QDF_STATUS_E_EXISTS; + case -ENOENT: + return QDF_STATUS_E_NOENT; + case -E2BIG: + return QDF_STATUS_E_E2BIG; + case -ENOSPC: + return QDF_STATUS_E_NOSPC; + case -EADDRNOTAVAIL: + return QDF_STATUS_E_ADDRNOTAVAIL; + case -ENXIO: + return QDF_STATUS_E_ENXIO; + case -ENETDOWN: + return QDF_STATUS_E_NETDOWN; + case -EIO: + return QDF_STATUS_E_IO; + case -ENETRESET: + return QDF_STATUS_E_NETRESET; + case -EINPROGRESS: + return QDF_STATUS_E_PENDING; + case -ETIMEDOUT: + return QDF_STATUS_E_TIMEOUT; + default: + return QDF_STATUS_E_PERM; + } +} +qdf_export_symbol(qdf_status_from_os_return); +