From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com,
Chaoyong He <chaoyong.he@corigine.com>
Subject: [PATCH 04/13] net/nfp: drop usage of return error helpers
Date: Mon, 10 Apr 2023 19:00:06 +0800 [thread overview]
Message-ID: <20230410110015.2973660-5-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20230410110015.2973660-1-chaoyong.he@corigine.com>
Drop the usage of complex return error helpers. These helpers was used
to return either NULL or -1 from a function while communicating the
error using errno. However erron was seldom checked and the error path
was taken only depending on the functions return value.
Remove the macros and convert the few callers that did look at errno to
communicate different errors using the return value instead. Also update
all the related documentation.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
drivers/net/nfp/nfp_common.c | 1 -
.../net/nfp/nfpcore/nfp-common/nfp_platform.h | 6 --
drivers/net/nfp/nfpcore/nfp_cpp.h | 57 +++++++++----------
drivers/net/nfp/nfpcore/nfp_cppcore.c | 43 ++++++--------
drivers/net/nfp/nfpcore/nfp_mutex.c | 39 ++++++-------
drivers/net/nfp/nfpcore/nfp_nffw.c | 4 +-
drivers/net/nfp/nfpcore/nfp_resource.c | 2 +-
7 files changed, 65 insertions(+), 87 deletions(-)
diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c
index 2261d955c8..f300d6d892 100644
--- a/drivers/net/nfp/nfp_common.c
+++ b/drivers/net/nfp/nfp_common.c
@@ -50,7 +50,6 @@
#include <unistd.h>
#include <stdio.h>
#include <sys/ioctl.h>
-#include <errno.h>
static const uint32_t nfp_net_link_speed_nfp2rte[] = {
[NFP_NET_CFG_STS_LINK_RATE_UNSUPPORTED] = RTE_ETH_SPEED_NUM_NONE,
diff --git a/drivers/net/nfp/nfpcore/nfp-common/nfp_platform.h b/drivers/net/nfp/nfpcore/nfp-common/nfp_platform.h
index 7b64e2d32b..9fa52074f0 100644
--- a/drivers/net/nfp/nfpcore/nfp-common/nfp_platform.h
+++ b/drivers/net/nfp/nfpcore/nfp-common/nfp_platform.h
@@ -26,10 +26,4 @@
#define ARRAY_SIZE(x) RTE_DIM(x)
#endif
-#define NFP_ERRNO(err) (errno = (err), -1)
-#define NFP_ERRNO_RET(err, ret) (errno = (err), (ret))
-#define NFP_NOERR(errv) (errno)
-#define NFP_ERRPTR(err) (errno = (err), NULL)
-#define NFP_PTRERR(errv) (errno)
-
#endif /* __NFP_PLATFORM_H__ */
diff --git a/drivers/net/nfp/nfpcore/nfp_cpp.h b/drivers/net/nfp/nfpcore/nfp_cpp.h
index a04a68f546..437dcdf942 100644
--- a/drivers/net/nfp/nfpcore/nfp_cpp.h
+++ b/drivers/net/nfp/nfpcore/nfp_cpp.h
@@ -181,7 +181,7 @@ uint32_t __nfp_cpp_model_autodetect(struct nfp_cpp *cpp, uint32_t *model);
*
* @param[in] id 0-based ID for the CPP interface to use
*
- * @return NFP CPP handle, or NULL on failure (and set errno accordingly).
+ * @return NFP CPP handle, or NULL on failure.
*/
struct nfp_cpp *nfp_cpp_from_device_name(struct rte_pci_device *dev,
int driver_lock_needed);
@@ -299,7 +299,7 @@ int nfp_cpp_serial(struct nfp_cpp *cpp, const uint8_t **serial);
* @param[in] address Offset into the NFP CPP ID address space
* @param[in] size Size of the area to reserve
*
- * @return NFP CPP handle, or NULL on failure (and set errno accordingly).
+ * @return NFP CPP handle, or NULL on failure.
*/
struct nfp_cpp_area *nfp_cpp_area_alloc(struct nfp_cpp *cpp, uint32_t cpp_id,
unsigned long long address,
@@ -313,7 +313,7 @@ struct nfp_cpp_area *nfp_cpp_area_alloc(struct nfp_cpp *cpp, uint32_t cpp_id,
* @param[in] address Offset into the NFP CPP ID address space
* @param[in] size Size of the area to reserve
*
- * @return NFP CPP handle, or NULL on failure (and set errno accordingly).
+ * @return NFP CPP handle, or NULL on failure.
*/
struct nfp_cpp_area *nfp_cpp_area_alloc_with_name(struct nfp_cpp *cpp,
uint32_t cpp_id,
@@ -332,7 +332,7 @@ void nfp_cpp_area_free(struct nfp_cpp_area *area);
*
* @param[in] area NFP CPP area handle
*
- * @return 0 on success, -1 on failure (and set errno accordingly).
+ * @return 0 on success, -1 on failure.
*/
int nfp_cpp_area_acquire(struct nfp_cpp_area *area);
@@ -350,7 +350,7 @@ void nfp_cpp_area_release(struct nfp_cpp_area *area);
* @param[in] address Offset into the NFP CPP ID address space
* @param[in] size Size of the area to reserve
*
- * @return NFP CPP handle, or NULL on failure (and set errno accordingly).
+ * @return NFP CPP handle, or NULL on failure.
*/
struct nfp_cpp_area *nfp_cpp_area_alloc_acquire(struct nfp_cpp *cpp,
uint32_t cpp_id,
@@ -372,7 +372,7 @@ uint8_t *nfp_cpp_map_area(struct nfp_cpp *cpp, int domain, int target,
*
* @param[in] area NFP CPP area handle
*
- * @return Pointer to IO memory, or NULL on failure (and set errno accordingly).
+ * @return Pointer to IO memory, or NULL on failure.
*/
void *nfp_cpp_area_mapped(struct nfp_cpp_area *area);
@@ -385,7 +385,7 @@ void *nfp_cpp_area_mapped(struct nfp_cpp_area *area);
* @param[in] buffer Location of buffer to receive the data
* @param[in] length Length of the data to read
*
- * @return bytes read on success, -1 on failure (and set errno accordingly).
+ * @return bytes read on success, negative value on failure.
*
*/
int nfp_cpp_area_read(struct nfp_cpp_area *area, unsigned long offset,
@@ -400,7 +400,7 @@ int nfp_cpp_area_read(struct nfp_cpp_area *area, unsigned long offset,
* @param[in] buffer Location of buffer that holds the data
* @param[in] length Length of the data to read
*
- * @return bytes written on success, -1 on failure (and set errno accordingly).
+ * @return bytes written on success, negative value on failure.
*/
int nfp_cpp_area_write(struct nfp_cpp_area *area, unsigned long offset,
const void *buffer, size_t length);
@@ -424,7 +424,7 @@ void *nfp_cpp_area_iomem(struct nfp_cpp_area *area);
* @param[in] offset Offset into the area
* @param[in] size Size of region to validate
*
- * @return 0 on success, -1 on failure (and set errno accordingly).
+ * @return 0 on success, negative value on failure.
*/
int nfp_cpp_area_check_range(struct nfp_cpp_area *area,
unsigned long long offset, unsigned long size);
@@ -454,7 +454,7 @@ const char *nfp_cpp_area_name(struct nfp_cpp_area *cpp_area);
* @param[in] kernel_vaddr Buffer to copy read data to
* @param[in] length Size of the area to reserve
*
- * @return bytes read on success, -1 on failure (and set errno accordingly).
+ * @return bytes read on success, -1 on failure.
*/
int nfp_cpp_read(struct nfp_cpp *cpp, uint32_t cpp_id,
unsigned long long address, void *kernel_vaddr, size_t length);
@@ -468,7 +468,7 @@ int nfp_cpp_read(struct nfp_cpp *cpp, uint32_t cpp_id,
* @param[in] kernel_vaddr Buffer to copy write data from
* @param[in] length Size of the area to reserve
*
- * @return bytes written on success, -1 on failure (and set errno accordingly).
+ * @return bytes written on success, -1 on failure.
*/
int nfp_cpp_write(struct nfp_cpp *cpp, uint32_t cpp_id,
unsigned long long address, const void *kernel_vaddr,
@@ -484,7 +484,7 @@ int nfp_cpp_write(struct nfp_cpp *cpp, uint32_t cpp_id,
* @param[in] value 32-bit value to fill area with
* @param[in] length Size of the area to reserve
*
- * @return bytes written on success, -1 on failure (and set errno accordingly).
+ * @return bytes written on success, negative value on failure.
*/
int nfp_cpp_area_fill(struct nfp_cpp_area *area, unsigned long offset,
uint32_t value, size_t length);
@@ -501,7 +501,7 @@ int nfp_cpp_area_fill(struct nfp_cpp_area *area, unsigned long offset,
*
* NOTE: offset must be 32-bit aligned.
*
- * @return 0 on success, or -1 on error (and set errno accordingly).
+ * @return 0 on success, or -1 on error.
*/
int nfp_cpp_area_readl(struct nfp_cpp_area *area, unsigned long offset,
uint32_t *value);
@@ -518,7 +518,7 @@ int nfp_cpp_area_readl(struct nfp_cpp_area *area, unsigned long offset,
*
* NOTE: offset must be 32-bit aligned.
*
- * @return 0 on success, or -1 on error (and set errno accordingly).
+ * @return 0 on success, or -1 on error.
*/
int nfp_cpp_area_writel(struct nfp_cpp_area *area, unsigned long offset,
uint32_t value);
@@ -535,7 +535,7 @@ int nfp_cpp_area_writel(struct nfp_cpp_area *area, unsigned long offset,
*
* NOTE: offset must be 64-bit aligned.
*
- * @return 0 on success, or -1 on error (and set errno accordingly).
+ * @return 0 on success, or -1 on error.
*/
int nfp_cpp_area_readq(struct nfp_cpp_area *area, unsigned long offset,
uint64_t *value);
@@ -552,7 +552,7 @@ int nfp_cpp_area_readq(struct nfp_cpp_area *area, unsigned long offset,
*
* NOTE: offset must be 64-bit aligned.
*
- * @return 0 on success, or -1 on error (and set errno accordingly).
+ * @return 0 on success, or -1 on error.
*/
int nfp_cpp_area_writeq(struct nfp_cpp_area *area, unsigned long offset,
uint64_t value);
@@ -564,7 +564,7 @@ int nfp_cpp_area_writeq(struct nfp_cpp_area *area, unsigned long offset,
* @param xpb_tgt XPB target and address
* @param value value to write
*
- * @return 0 on success, or -1 on failure (and set errno accordingly).
+ * @return 0 on success, or -1 on failure.
*/
int nfp_xpb_writel(struct nfp_cpp *cpp, uint32_t xpb_tgt, uint32_t value);
@@ -575,7 +575,7 @@ int nfp_xpb_writel(struct nfp_cpp *cpp, uint32_t xpb_tgt, uint32_t value);
* @param xpb_tgt XPB target and address
* @param value output value
*
- * @return 0 on success, or -1 on failure (and set errno accordingly).
+ * @return 0 on success, or -1 on failure.
*/
int nfp_xpb_readl(struct nfp_cpp *cpp, uint32_t xpb_tgt, uint32_t *value);
@@ -587,7 +587,7 @@ int nfp_xpb_readl(struct nfp_cpp *cpp, uint32_t xpb_tgt, uint32_t *value);
* @param mask mask of bits to alter
* @param value value to modify
*
- * @return 0 on success, or -1 on failure (and set errno accordingly).
+ * @return 0 on success, or -1 on failure.
*/
int nfp_xpb_writelm(struct nfp_cpp *cpp, uint32_t xpb_tgt, uint32_t mask,
uint32_t value);
@@ -601,7 +601,7 @@ int nfp_xpb_writelm(struct nfp_cpp *cpp, uint32_t xpb_tgt, uint32_t mask,
* @param value value to monitor for
* @param timeout_us maximum number of us to wait (-1 for forever)
*
- * @return >= 0 on success, or -1 on failure (and set errno accordingly).
+ * @return >= 0 on success, negative value on failure.
*/
int nfp_xpb_waitlm(struct nfp_cpp *cpp, uint32_t xpb_tgt, uint32_t mask,
uint32_t value, int timeout_us);
@@ -614,7 +614,7 @@ int nfp_xpb_waitlm(struct nfp_cpp *cpp, uint32_t xpb_tgt, uint32_t mask,
* @param address offset into the NFP CPP ID address space
* @param value output value
*
- * @return 0 on success, or -1 on failure (and set errno accordingly).
+ * @return 0 on success, or -1 on failure.
*/
int nfp_cpp_readl(struct nfp_cpp *cpp, uint32_t cpp_id,
unsigned long long address, uint32_t *value);
@@ -627,7 +627,7 @@ int nfp_cpp_readl(struct nfp_cpp *cpp, uint32_t cpp_id,
* @param address offset into the NFP CPP ID address space
* @param value value to write
*
- * @return 0 on success, or -1 on failure (and set errno accordingly).
+ * @return 0 on success, or -1 on failure.
*
*/
int nfp_cpp_writel(struct nfp_cpp *cpp, uint32_t cpp_id,
@@ -641,7 +641,7 @@ int nfp_cpp_writel(struct nfp_cpp *cpp, uint32_t cpp_id,
* @param address offset into the NFP CPP ID address space
* @param value output value
*
- * @return 0 on success, or -1 on failure (and set errno accordingly).
+ * @return 0 on success, or -1 on failure.
*/
int nfp_cpp_readq(struct nfp_cpp *cpp, uint32_t cpp_id,
unsigned long long address, uint64_t *value);
@@ -654,7 +654,7 @@ int nfp_cpp_readq(struct nfp_cpp *cpp, uint32_t cpp_id,
* @param address offset into the NFP CPP ID address space
* @param value value to write
*
- * @return 0 on success, or -1 on failure (and set errno accordingly).
+ * @return 0 on success, or -1 on failure.
*/
int nfp_cpp_writeq(struct nfp_cpp *cpp, uint32_t cpp_id,
unsigned long long address, uint64_t value);
@@ -675,7 +675,7 @@ int nfp_cpp_writeq(struct nfp_cpp *cpp, uint32_t cpp_id,
* @param address Offset into the address space of the NFP CPP target ID
* @param key_id Unique 32-bit value for this mutex
*
- * @return 0 on success, or -1 on failure (and set errno accordingly).
+ * @return 0 on success, negative value on failure.
*/
int nfp_cpp_mutex_init(struct nfp_cpp *cpp, int target,
unsigned long long address, uint32_t key_id);
@@ -756,7 +756,7 @@ void nfp_cpp_mutex_free(struct nfp_cpp_mutex *mutex);
*
* @param mutex NFP CPP Mutex handle
*
- * @return 0 on success, or -1 on failure (and set errno accordingly).
+ * @return 0 on success, negative value on failure.
*/
int nfp_cpp_mutex_lock(struct nfp_cpp_mutex *mutex);
@@ -765,7 +765,7 @@ int nfp_cpp_mutex_lock(struct nfp_cpp_mutex *mutex);
*
* @param mutex NFP CPP Mutex handle
*
- * @return 0 on success, or -1 on failure (and set errno accordingly).
+ * @return 0 on success, negative value on failure.
*/
int nfp_cpp_mutex_unlock(struct nfp_cpp_mutex *mutex);
@@ -773,8 +773,7 @@ int nfp_cpp_mutex_unlock(struct nfp_cpp_mutex *mutex);
* Attempt to lock a mutex handle, using the NFP MU Atomic Engine
*
* @param mutex NFP CPP Mutex handle
- * @return 0 if the lock succeeded, -1 on failure (and errno set
- * appropriately).
+ * @return 0 if the lock succeeded, negative value on failure.
*/
int nfp_cpp_mutex_trylock(struct nfp_cpp_mutex *mutex);
diff --git a/drivers/net/nfp/nfpcore/nfp_cppcore.c b/drivers/net/nfp/nfpcore/nfp_cppcore.c
index 1d2468ad7a..97cf16c801 100644
--- a/drivers/net/nfp/nfpcore/nfp_cppcore.c
+++ b/drivers/net/nfp/nfpcore/nfp_cppcore.c
@@ -8,7 +8,6 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
-#include <errno.h>
#include <sys/types.h>
#include <rte_byteorder.h>
@@ -137,14 +136,14 @@ nfp_cpp_area_alloc_with_name(struct nfp_cpp *cpp, uint32_t dest,
{
struct nfp_cpp_area *area;
uint64_t tmp64 = (uint64_t)address;
- int tmp, err;
+ int err;
if (cpp == NULL)
return NULL;
/* CPP bus uses only a 40-bit address */
if ((address + size) > (1ULL << 40))
- return NFP_ERRPTR(EFAULT);
+ return NULL;
/* Remap from cpp_island to cpp_target */
err = nfp_target_cpp(dest, tmp64, &dest, &tmp64, cpp->imb_cat_table);
@@ -165,22 +164,12 @@ nfp_cpp_area_alloc_with_name(struct nfp_cpp *cpp, uint32_t dest,
area->name = ((char *)area) + sizeof(*area) + cpp->op->area_priv_size;
memcpy(area->name, name, strlen(name) + 1);
- /*
- * Preserve errno around the call to area_init, since most
- * implementations will blindly call nfp_target_action_width()for both
- * read or write modes, and that will set errno to EINVAL.
- */
- tmp = errno;
-
err = cpp->op->area_init(area, dest, address, size);
if (err < 0) {
free(area);
return NULL;
}
- /* Restore errno */
- errno = tmp;
-
area->offset = address;
area->size = size;
@@ -328,7 +317,7 @@ nfp_cpp_area_read(struct nfp_cpp_area *area, unsigned long offset,
void *kernel_vaddr, size_t length)
{
if ((offset + length) > area->size)
- return NFP_ERRNO(EFAULT);
+ return -EFAULT;
return area->cpp->op->area_read(area, kernel_vaddr, offset, length);
}
@@ -352,7 +341,7 @@ nfp_cpp_area_write(struct nfp_cpp_area *area, unsigned long offset,
const void *kernel_vaddr, size_t length)
{
if ((offset + length) > area->size)
- return NFP_ERRNO(EFAULT);
+ return -EFAULT;
return area->cpp->op->area_write(area, kernel_vaddr, offset, length);
}
@@ -373,14 +362,14 @@ nfp_cpp_area_mapped(struct nfp_cpp_area *area)
* @length: size of address range in bytes
*
* Check if address range fits within CPP area. Return 0 if area fits
- * or -1 on error.
+ * or negative value on error.
*/
int
nfp_cpp_area_check_range(struct nfp_cpp_area *area, unsigned long long offset,
unsigned long length)
{
if (((offset + length) > area->size))
- return NFP_ERRNO(EFAULT);
+ return -EFAULT;
return 0;
}
@@ -555,7 +544,7 @@ nfp_cpp_alloc(struct rte_pci_device *dev, int driver_lock_needed)
ops = nfp_cpp_transport_operations();
if (ops == NULL || ops->init == NULL)
- return NFP_ERRPTR(EINVAL);
+ return NULL;
cpp = calloc(1, sizeof(*cpp));
if (cpp == NULL)
@@ -621,7 +610,7 @@ nfp_cpp_from_device_name(struct rte_pci_device *dev, int driver_lock_needed)
* @param mask mask of bits to alter
* @param value value to modify
*
- * @return 0 on success, or -1 on failure (and set errno accordingly).
+ * @return 0 on success, or -1 on failure.
*/
int
nfp_xpb_writelm(struct nfp_cpp *cpp, uint32_t xpb_tgt, uint32_t mask,
@@ -648,7 +637,7 @@ nfp_xpb_writelm(struct nfp_cpp *cpp, uint32_t xpb_tgt, uint32_t mask,
* @param value value to monitor for
* @param timeout_us maximum number of us to wait (-1 for forever)
*
- * @return >= 0 on success, or -1 on failure (and set errno accordingly).
+ * @return >= 0 on success, or negative value on failure.
*/
int
nfp_xpb_waitlm(struct nfp_cpp *cpp, uint32_t xpb_tgt, uint32_t mask,
@@ -676,7 +665,7 @@ nfp_xpb_waitlm(struct nfp_cpp *cpp, uint32_t xpb_tgt, uint32_t mask,
} while (timeout_us >= 0);
if (timeout_us < 0)
- err = NFP_ERRNO(ETIMEDOUT);
+ err = -ETIMEDOUT;
else
err = timeout_us;
@@ -756,17 +745,17 @@ nfp_cpp_area_fill(struct nfp_cpp_area *area, unsigned long offset,
value64 = ((uint64_t)value << 32) | value;
if ((offset + length) > area->size)
- return NFP_ERRNO(EINVAL);
+ return -EINVAL;
if ((area->offset + offset) & 3)
- return NFP_ERRNO(EINVAL);
+ return -EINVAL;
if (((area->offset + offset) & 7) == 4 && length >= 4) {
err = nfp_cpp_area_write(area, offset, &value, sizeof(value));
if (err < 0)
return err;
if (err != sizeof(value))
- return NFP_ERRNO(ENOSPC);
+ return -ENOSPC;
offset += sizeof(value);
length -= sizeof(value);
}
@@ -778,7 +767,7 @@ nfp_cpp_area_fill(struct nfp_cpp_area *area, unsigned long offset,
if (err < 0)
return err;
if (err != sizeof(value64))
- return NFP_ERRNO(ENOSPC);
+ return -ENOSPC;
}
if ((i + sizeof(value)) <= length) {
@@ -787,7 +776,7 @@ nfp_cpp_area_fill(struct nfp_cpp_area *area, unsigned long offset,
if (err < 0)
return err;
if (err != sizeof(value))
- return NFP_ERRNO(ENOSPC);
+ return -ENOSPC;
i += sizeof(value);
}
@@ -828,7 +817,7 @@ __nfp_cpp_model_autodetect(struct nfp_cpp *cpp, uint32_t *model)
* Map an area of IOMEM access. To undo the effect of this function call
* @nfp_cpp_area_release_free(*area).
*
- * Return: Pointer to memory mapped area or ERR_PTR
+ * Return: Pointer to memory mapped area or NULL
*/
uint8_t *
nfp_cpp_map_area(struct nfp_cpp *cpp, int domain, int target, uint64_t addr,
diff --git a/drivers/net/nfp/nfpcore/nfp_mutex.c b/drivers/net/nfp/nfpcore/nfp_mutex.c
index 8a4e6a462a..f967a29351 100644
--- a/drivers/net/nfp/nfpcore/nfp_mutex.c
+++ b/drivers/net/nfp/nfpcore/nfp_mutex.c
@@ -3,8 +3,6 @@
* All rights reserved.
*/
-#include <errno.h>
-
#include <malloc.h>
#include <time.h>
#include <sched.h>
@@ -41,13 +39,13 @@ _nfp_cpp_mutex_validate(uint32_t model, int *target, unsigned long long address)
{
/* Address must be 64-bit aligned */
if (address & 7)
- return NFP_ERRNO(EINVAL);
+ return -EINVAL;
if (NFP_CPP_MODEL_IS_6000(model)) {
if (*target != NFP_CPP_TARGET_MU)
- return NFP_ERRNO(EINVAL);
+ return -EINVAL;
} else {
- return NFP_ERRNO(EINVAL);
+ return -EINVAL;
}
return 0;
@@ -71,7 +69,7 @@ _nfp_cpp_mutex_validate(uint32_t model, int *target, unsigned long long address)
* @param address Offset into the address space of the NFP CPP target ID
* @param key Unique 32-bit value for this mutex
*
- * @return 0 on success, or -1 on failure (and set errno accordingly).
+ * @return 0 on success, or negative value on failure.
*/
int
nfp_cpp_mutex_init(struct nfp_cpp *cpp, int target, unsigned long long address,
@@ -138,7 +136,7 @@ nfp_cpp_mutex_alloc(struct nfp_cpp *cpp, int target,
}
/* If the key doesn't match... */
- return NFP_ERRPTR(EEXIST);
+ return NULL;
}
err = _nfp_cpp_mutex_validate(model, &target, address);
@@ -150,11 +148,11 @@ nfp_cpp_mutex_alloc(struct nfp_cpp *cpp, int target,
return NULL;
if (tmp != key)
- return NFP_ERRPTR(EEXIST);
+ return NULL;
mutex = calloc(sizeof(*mutex), 1);
if (mutex == NULL)
- return NFP_ERRPTR(ENOMEM);
+ return NULL;
mutex->cpp = cpp;
mutex->target = target;
@@ -203,7 +201,7 @@ nfp_cpp_mutex_owner(struct nfp_cpp_mutex *mutex)
return err;
if (key != mutex->key)
- return NFP_ERRNO(EPERM);
+ return -EPERM;
if (MUTEX_IS_LOCKED(value) == 0)
return 0;
@@ -253,7 +251,7 @@ nfp_cpp_mutex_free(struct nfp_cpp_mutex *mutex)
*
* @param mutex NFP CPP Mutex handle
*
- * @return 0 on success, or -1 on failure (and set errno accordingly).
+ * @return 0 on success, or negative value on failure.
*/
int
nfp_cpp_mutex_lock(struct nfp_cpp_mutex *mutex)
@@ -262,8 +260,8 @@ nfp_cpp_mutex_lock(struct nfp_cpp_mutex *mutex)
time_t warn_at = time(NULL) + 15;
while ((err = nfp_cpp_mutex_trylock(mutex)) != 0) {
- /* If errno != EBUSY, then the lock was damaged */
- if (err < 0 && errno != EBUSY)
+ /* If err != -EBUSY, then the lock was damaged */
+ if (err < 0 && err != -EBUSY)
return err;
if (time(NULL) >= warn_at) {
PMD_DRV_LOG(ERR, "Warning: waiting for NFP mutex usage:%u depth:%hd] target:%d addr:%llx key:%08x]",
@@ -281,7 +279,7 @@ nfp_cpp_mutex_lock(struct nfp_cpp_mutex *mutex)
*
* @param mutex NFP CPP Mutex handle
*
- * @return 0 on success, or -1 on failure (and set errno accordingly).
+ * @return 0 on success, or negative value on failure.
*/
int
nfp_cpp_mutex_unlock(struct nfp_cpp_mutex *mutex)
@@ -307,12 +305,12 @@ nfp_cpp_mutex_unlock(struct nfp_cpp_mutex *mutex)
goto exit;
if (key != mutex->key) {
- err = NFP_ERRNO(EPERM);
+ err = -EPERM;
goto exit;
}
if (value != MUTEX_LOCKED(interface)) {
- err = NFP_ERRNO(EACCES);
+ err = -EACCES;
goto exit;
}
@@ -335,8 +333,7 @@ nfp_cpp_mutex_unlock(struct nfp_cpp_mutex *mutex)
* 0x....000f - Locked
*
* @param mutex NFP CPP Mutex handle
- * @return 0 if the lock succeeded, -1 on failure (and errno set
- * appropriately).
+ * @return 0 if the lock succeeded, negative value on failure.
*/
int
nfp_cpp_mutex_trylock(struct nfp_cpp_mutex *mutex)
@@ -350,7 +347,7 @@ nfp_cpp_mutex_trylock(struct nfp_cpp_mutex *mutex)
if (mutex->depth > 0) {
if (mutex->depth == MUTEX_DEPTH_MAX)
- return NFP_ERRNO(E2BIG);
+ return -E2BIG;
mutex->depth++;
return 0;
@@ -362,7 +359,7 @@ nfp_cpp_mutex_trylock(struct nfp_cpp_mutex *mutex)
goto exit;
if (key != mutex->key) {
- err = NFP_ERRNO(EPERM);
+ err = -EPERM;
goto exit;
}
@@ -415,7 +412,7 @@ nfp_cpp_mutex_trylock(struct nfp_cpp_mutex *mutex)
goto exit;
}
- err = NFP_ERRNO(MUTEX_IS_LOCKED(tmp) ? EBUSY : EINVAL);
+ err = MUTEX_IS_LOCKED(tmp) ? -EBUSY : -EINVAL;
exit:
return err;
diff --git a/drivers/net/nfp/nfpcore/nfp_nffw.c b/drivers/net/nfp/nfpcore/nfp_nffw.c
index ccc5227d4d..bead4f3341 100644
--- a/drivers/net/nfp/nfpcore/nfp_nffw.c
+++ b/drivers/net/nfp/nfpcore/nfp_nffw.c
@@ -112,7 +112,7 @@ nffw_res_fwinfos(struct nfp_nffw_info_data *fwinf, struct nffw_fwinfo **arr)
* nfp_nffw_info_open() - Acquire the lock on the NFFW table
* @cpp: NFP CPP handle
*
- * Return: 0, or -ERRNO
+ * Return: nffw info pointer, or NULL on failure
*/
struct nfp_nffw_info *
nfp_nffw_info_open(struct nfp_cpp *cpp)
@@ -164,7 +164,7 @@ nfp_nffw_info_open(struct nfp_cpp *cpp)
* nfp_nffw_info_close() - Release the lock on the NFFW table
* @state: NFP FW info state
*
- * Return: 0, or -ERRNO
+ * Return: void
*/
void
nfp_nffw_info_close(struct nfp_nffw_info *state)
diff --git a/drivers/net/nfp/nfpcore/nfp_resource.c b/drivers/net/nfp/nfpcore/nfp_resource.c
index 892ccf73c4..351bc623ed 100644
--- a/drivers/net/nfp/nfpcore/nfp_resource.c
+++ b/drivers/net/nfp/nfpcore/nfp_resource.c
@@ -145,7 +145,7 @@ nfp_resource_try_acquire(struct nfp_cpp *cpp, struct nfp_resource *res,
*
* NOTE: This function locks the acquired resource
*
- * Return: NFP Resource handle, or ERR_PTR()
+ * Return: NFP Resource handle, or NULL
*/
struct nfp_resource *
nfp_resource_acquire(struct nfp_cpp *cpp, const char *name)
--
2.39.1
next prev parent reply other threads:[~2023-04-10 11:01 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-10 11:00 [PATCH 00/13] Sync the kernel driver logic Chaoyong He
2023-04-10 11:00 ` [PATCH 01/13] net/nfp: define correct size for configuration BAR Chaoyong He
2023-04-10 11:00 ` [PATCH 02/13] net/nfp: move shared target logic to own source file Chaoyong He
2023-04-10 11:00 ` [PATCH 03/13] net/nfp: remove the redundant macro about CPP target Chaoyong He
2023-04-10 11:00 ` Chaoyong He [this message]
2023-04-10 11:00 ` [PATCH 05/13] net/nfp: use generic macros for array size and to set bits Chaoyong He
2023-04-10 11:00 ` [PATCH 06/13] net/nfp: remove dead code related to CPP Chaoyong He
2023-04-10 11:00 ` [PATCH 07/13] net/nfp: remove duplicated nffw defines Chaoyong He
2023-04-10 11:00 ` [PATCH 08/13] net/nfp: move NFD3 logic to own source file Chaoyong He
2023-04-10 11:00 ` [PATCH 09/13] net/nfp: adjust the coding style for NFD3 Chaoyong He
2023-04-10 11:00 ` [PATCH 10/13] net/nfp: rename macro name of NFD3 Tx descriptor Chaoyong He
2023-04-10 11:00 ` [PATCH 11/13] net/nfp: move NFDk logic to own source file Chaoyong He
2023-04-10 11:00 ` [PATCH 12/13] net/nfp: adjust the coding style for NFDk Chaoyong He
2023-04-10 11:00 ` [PATCH 13/13] net/nfp: modify the logic of some NFDk function Chaoyong He
2023-05-11 14:47 ` [PATCH 00/13] Sync the kernel driver logic Niklas Söderlund
2023-05-12 14:37 ` Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230410110015.2973660-5-chaoyong.he@corigine.com \
--to=chaoyong.he@corigine.com \
--cc=dev@dpdk.org \
--cc=niklas.soderlund@corigine.com \
--cc=oss-drivers@corigine.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).