Now that the cpufreq framework validates the lcore ID using
rte_lcore_is_eal_managed() before dispatching to any driver,
each individual cpufreq driver no longer needs its own range
check against RTE_MAX_LCORE.

Remove the duplicated lcore ID checks from the kvm_vm cpufreq
driver and its guest_channel helper.

Signed-off-by: Huisong Li <[email protected]>
---
 drivers/power/kvm_vm/guest_channel.c | 22 ----------------------
 drivers/power/kvm_vm/kvm_vm.c        | 10 ----------
 2 files changed, 32 deletions(-)

diff --git a/drivers/power/kvm_vm/guest_channel.c 
b/drivers/power/kvm_vm/guest_channel.c
index 42bfcedb56..dc8fe05fef 100644
--- a/drivers/power/kvm_vm/guest_channel.c
+++ b/drivers/power/kvm_vm/guest_channel.c
@@ -61,11 +61,6 @@ guest_channel_host_connect(const char *path, unsigned int 
lcore_id)
        char fd_path[PATH_MAX];
        int fd = -1;
 
-       if (lcore_id >= RTE_MAX_LCORE) {
-               GUEST_CHANNEL_LOG(ERR, "Channel(%u) is out of range 0...%d",
-                               lcore_id, RTE_MAX_LCORE-1);
-               return -1;
-       }
        /* check if path is already open */
        if (global_fds[lcore_id] != -1) {
                GUEST_CHANNEL_LOG(ERR, "Channel(%u) is already open with fd %d",
@@ -127,12 +122,6 @@ guest_channel_send_msg(struct rte_power_channel_packet 
*pkt,
        int ret, buffer_len = sizeof(*pkt);
        void *buffer = pkt;
 
-       if (lcore_id >= RTE_MAX_LCORE) {
-               GUEST_CHANNEL_LOG(ERR, "Channel(%u) is out of range 0...%d",
-                               lcore_id, RTE_MAX_LCORE-1);
-               return -1;
-       }
-
        if (global_fds[lcore_id] < 0) {
                GUEST_CHANNEL_LOG(ERR, "Channel is not connected");
                return -1;
@@ -169,12 +158,6 @@ int power_guest_channel_read_msg(void *pkt,
        if (pkt_len == 0 || pkt == NULL)
                return -1;
 
-       if (lcore_id >= RTE_MAX_LCORE) {
-               GUEST_CHANNEL_LOG(ERR, "Channel(%u) is out of range 0...%d",
-                               lcore_id, RTE_MAX_LCORE-1);
-               return -1;
-       }
-
        if (global_fds[lcore_id] < 0) {
                GUEST_CHANNEL_LOG(ERR, "Channel is not connected");
                return -1;
@@ -225,11 +208,6 @@ int rte_power_guest_channel_receive_msg(void *pkt,
 void
 guest_channel_host_disconnect(unsigned int lcore_id)
 {
-       if (lcore_id >= RTE_MAX_LCORE) {
-               GUEST_CHANNEL_LOG(ERR, "Channel(%u) is out of range 0...%d",
-                               lcore_id, RTE_MAX_LCORE-1);
-               return;
-       }
        if (global_fds[lcore_id] < 0)
                return;
        close(global_fds[lcore_id]);
diff --git a/drivers/power/kvm_vm/kvm_vm.c b/drivers/power/kvm_vm/kvm_vm.c
index 5754a441cd..e8b454bb55 100644
--- a/drivers/power/kvm_vm/kvm_vm.c
+++ b/drivers/power/kvm_vm/kvm_vm.c
@@ -24,11 +24,6 @@ power_kvm_vm_check_supported(void)
 int
 power_kvm_vm_init(unsigned int lcore_id)
 {
-       if (lcore_id >= RTE_MAX_LCORE) {
-               POWER_LOG(ERR, "Core(%u) is out of range 0...%d",
-                               lcore_id, RTE_MAX_LCORE-1);
-               return -1;
-       }
        pkt[lcore_id].command = RTE_POWER_CPU_POWER;
        pkt[lcore_id].resource_id = lcore_id;
        return guest_channel_host_connect(FD_PATH, lcore_id);
@@ -73,11 +68,6 @@ send_msg(unsigned int lcore_id, uint32_t scale_direction)
 {
        int ret;
 
-       if (lcore_id >= RTE_MAX_LCORE) {
-               POWER_LOG(ERR, "Core(%u) is out of range 0...%d",
-                               lcore_id, RTE_MAX_LCORE-1);
-               return -1;
-       }
        pkt[lcore_id].unit = scale_direction;
        ret = guest_channel_send_msg(&pkt[lcore_id], lcore_id);
        if (ret == 0)
-- 
2.33.0

Reply via email to