Sync the logic from kernel driver and remove the unneeded header
file include statements.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
drivers/net/nfp/nfpcore/nfp_resource.c | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
@@ -3,15 +3,11 @@
* All rights reserved.
*/
-#include <stdio.h>
-#include <time.h>
-#include <endian.h>
+#include "nfp_resource.h"
-#include "nfp_cpp.h"
+#include "nfp_crc.h"
#include "nfp_logs.h"
#include "nfp6000/nfp6000.h"
-#include "nfp_resource.h"
-#include "nfp_crc.h"
#define NFP_RESOURCE_TBL_TARGET NFP_CPP_TARGET_MU
#define NFP_RESOURCE_TBL_BASE 0x8100000000ULL
@@ -43,7 +39,7 @@ struct nfp_resource_entry {
};
#define NFP_RESOURCE_TBL_SIZE 4096
-#define NFP_RESOURCE_TBL_ENTRIES (int)(NFP_RESOURCE_TBL_SIZE / \
+#define NFP_RESOURCE_TBL_ENTRIES (NFP_RESOURCE_TBL_SIZE / \
sizeof(struct nfp_resource_entry))
struct nfp_resource {
@@ -173,8 +169,7 @@ nfp_resource_acquire(struct nfp_cpp *cpp,
NFP_RESOURCE_TBL_BASE, NFP_RESOURCE_TBL_KEY);
if (dev_mutex == NULL) {
PMD_DRV_LOG(ERR, "RESOURCE - CPP mutex alloc failed");
- rte_free(res);
- return NULL;
+ goto err_free;
}
wait.tv_sec = 0;
@@ -186,13 +181,12 @@ nfp_resource_acquire(struct nfp_cpp *cpp,
break;
if (err != -EBUSY) {
PMD_DRV_LOG(ERR, "RESOURCE - try acquire failed");
- goto err_free;
+ goto mutex_free;
}
if (count++ > 1000) { /* 1ms * 1000 = 1s */
PMD_DRV_LOG(ERR, "Error: resource %s timed out", name);
- err = -EBUSY;
- goto err_free;
+ goto mutex_free;
}
nanosleep(&wait, NULL);
@@ -202,8 +196,9 @@ nfp_resource_acquire(struct nfp_cpp *cpp,
return res;
-err_free:
+mutex_free:
nfp_cpp_mutex_free(dev_mutex);
+err_free:
rte_free(res);
return NULL;
}