Skip to content

Commit

Permalink
selftests: nci: Remove the polling code to read a NCI frame
Browse files Browse the repository at this point in the history
Because the virtual NCI device uses Wait Queue, the virtual device
application doesn't need to poll the NCI frame.

Signed-off-by: Bongsu Jeon <bongsu.jeon@samsung.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Bongsu Jeon authored and David S. Miller committed Aug 18, 2021
1 parent 8675569 commit 4ef956c
Showing 1 changed file with 11 additions and 22 deletions.
33 changes: 11 additions & 22 deletions tools/testing/selftests/nci/nci_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,7 @@ static void *virtual_dev_open(void *data)

dev_fd = *(int *)data;

while ((len = read(dev_fd, buf, 258)) == 0)
;
len = read(dev_fd, buf, 258);
if (len <= 0)
goto error;
if (len != sizeof(nci_reset_cmd))
Expand All @@ -280,8 +279,7 @@ static void *virtual_dev_open(void *data)
goto error;
write(dev_fd, nci_reset_rsp, sizeof(nci_reset_rsp));

while ((len = read(dev_fd, buf, 258)) == 0)
;
len = read(dev_fd, buf, 258);
if (len <= 0)
goto error;
if (len != sizeof(nci_init_cmd))
Expand All @@ -290,8 +288,7 @@ static void *virtual_dev_open(void *data)
goto error;
write(dev_fd, nci_init_rsp, sizeof(nci_init_rsp));

while ((len = read(dev_fd, buf, 258)) == 0)
;
len = read(dev_fd, buf, 258);
if (len <= 0)
goto error;
if (len != sizeof(nci_rf_disc_map_cmd))
Expand All @@ -313,8 +310,7 @@ static void *virtual_dev_open_v2(void *data)

dev_fd = *(int *)data;

while ((len = read(dev_fd, buf, 258)) == 0)
;
len = read(dev_fd, buf, 258);
if (len <= 0)
goto error;
if (len != sizeof(nci_reset_cmd))
Expand All @@ -324,8 +320,7 @@ static void *virtual_dev_open_v2(void *data)
write(dev_fd, nci_reset_rsp_v2, sizeof(nci_reset_rsp_v2));
write(dev_fd, nci_reset_ntf, sizeof(nci_reset_ntf));

while ((len = read(dev_fd, buf, 258)) == 0)
;
len = read(dev_fd, buf, 258);
if (len <= 0)
goto error;
if (len != sizeof(nci_init_cmd_v2))
Expand All @@ -334,8 +329,7 @@ static void *virtual_dev_open_v2(void *data)
goto error;
write(dev_fd, nci_init_rsp_v2, sizeof(nci_init_rsp_v2));

while ((len = read(dev_fd, buf, 258)) == 0)
;
len = read(dev_fd, buf, 258);
if (len <= 0)
goto error;
if (len != sizeof(nci_rf_disc_map_cmd))
Expand Down Expand Up @@ -402,8 +396,7 @@ static void *virtual_deinit(void *data)

dev_fd = *(int *)data;

while ((len = read(dev_fd, buf, 258)) == 0)
;
len = read(dev_fd, buf, 258);
if (len <= 0)
goto error;
if (len != sizeof(nci_reset_cmd))
Expand All @@ -425,8 +418,7 @@ static void *virtual_deinit_v2(void *data)

dev_fd = *(int *)data;

while ((len = read(dev_fd, buf, 258)) == 0)
;
len = read(dev_fd, buf, 258);
if (len <= 0)
goto error;
if (len != sizeof(nci_reset_cmd))
Expand Down Expand Up @@ -489,16 +481,14 @@ static void *virtual_poll_start(void *data)

dev_fd = *(int *)data;

while ((len = read(dev_fd, buf, 258)) == 0)
;
len = read(dev_fd, buf, 258);
if (len <= 0)
goto error;
if (len != sizeof(nci_rf_discovery_cmd))
goto error;
if (memcmp(nci_rf_discovery_cmd, buf, len))
goto error;
write(dev_fd, nci_rf_disc_rsp, sizeof(nci_rf_disc_rsp))
;
write(dev_fd, nci_rf_disc_rsp, sizeof(nci_rf_disc_rsp));

return (void *)0;
error:
Expand All @@ -513,8 +503,7 @@ static void *virtual_poll_stop(void *data)

dev_fd = *(int *)data;

while ((len = read(dev_fd, buf, 258)) == 0)
;
len = read(dev_fd, buf, 258);
if (len <= 0)
goto error;
if (len != sizeof(nci_rf_deact_cmd))
Expand Down

0 comments on commit 4ef956c

Please sign in to comment.