"pci_endpoint_test" driver now returns 0 for success and negative error
code for failure. So adapt to the change by reporting FAILURE if the
return value is < 0, and SUCCESS otherwise.
Signed-off-by: Manivannan Sadhasivam <[email protected]>
---
tools/pci/pcitest.c | 41 +++++++++++++++++++++--------------------
1 file changed, 21 insertions(+), 20 deletions(-)
diff --git a/tools/pci/pcitest.c b/tools/pci/pcitest.c
index 441b54234635..a4e5b17cc3b5 100644
--- a/tools/pci/pcitest.c
+++ b/tools/pci/pcitest.c
@@ -18,7 +18,6 @@
#define BILLION 1E9
-static char *result[] = { "NOT OKAY", "OKAY" };
static char *irq[] = { "LEGACY", "MSI", "MSI-X" };
struct pci_test {
@@ -54,9 +53,9 @@ static int run_test(struct pci_test *test)
ret = ioctl(fd, PCITEST_BAR, test->barnum);
fprintf(stdout, "BAR%d:\t\t", test->barnum);
if (ret < 0)
- fprintf(stdout, "TEST FAILED\n");
+ fprintf(stdout, "FAILED\n");
else
- fprintf(stdout, "%s\n", result[ret]);
+ fprintf(stdout, "SUCCESS\n");
}
if (test->set_irqtype) {
@@ -65,16 +64,18 @@ static int run_test(struct pci_test *test)
if (ret < 0)
fprintf(stdout, "FAILED\n");
else
- fprintf(stdout, "%s\n", result[ret]);
+ fprintf(stdout, "SUCCESS\n");
}
if (test->get_irqtype) {
ret = ioctl(fd, PCITEST_GET_IRQTYPE);
fprintf(stdout, "GET IRQ TYPE:\t\t");
- if (ret < 0)
+ if (ret < 0) {
fprintf(stdout, "FAILED\n");
- else
+ } else {
fprintf(stdout, "%s\n", irq[ret]);
+ ret = 0;
+ }
}
if (test->clear_irq) {
@@ -83,34 +84,34 @@ static int run_test(struct pci_test *test)
if (ret < 0)
fprintf(stdout, "FAILED\n");
else
- fprintf(stdout, "%s\n", result[ret]);
+ fprintf(stdout, "SUCCESS\n");
}
if (test->legacyirq) {
ret = ioctl(fd, PCITEST_LEGACY_IRQ, 0);
fprintf(stdout, "LEGACY IRQ:\t");
if (ret < 0)
- fprintf(stdout, "TEST FAILED\n");
+ fprintf(stdout, "FAILED\n");
else
- fprintf(stdout, "%s\n", result[ret]);
+ fprintf(stdout, "SUCCESS\n");
}
if (test->msinum > 0 && test->msinum <= 32) {
ret = ioctl(fd, PCITEST_MSI, test->msinum);
fprintf(stdout, "MSI%d:\t\t", test->msinum);
if (ret < 0)
- fprintf(stdout, "TEST FAILED\n");
+ fprintf(stdout, "FAILED\n");
else
- fprintf(stdout, "%s\n", result[ret]);
+ fprintf(stdout, "SUCCESS\n");
}
if (test->msixnum > 0 && test->msixnum <= 2048) {
ret = ioctl(fd, PCITEST_MSIX, test->msixnum);
fprintf(stdout, "MSI-X%d:\t\t", test->msixnum);
if (ret < 0)
- fprintf(stdout, "TEST FAILED\n");
+ fprintf(stdout, "FAILED\n");
else
- fprintf(stdout, "%s\n", result[ret]);
+ fprintf(stdout, "SUCCESS\n");
}
if (test->write) {
@@ -120,9 +121,9 @@ static int run_test(struct pci_test *test)
ret = ioctl(fd, PCITEST_WRITE, ¶m);
fprintf(stdout, "WRITE (%7ld bytes):\t\t", test->size);
if (ret < 0)
- fprintf(stdout, "TEST FAILED\n");
+ fprintf(stdout, "FAILED\n");
else
- fprintf(stdout, "%s\n", result[ret]);
+ fprintf(stdout, "SUCCESS\n");
}
if (test->read) {
@@ -132,9 +133,9 @@ static int run_test(struct pci_test *test)
ret = ioctl(fd, PCITEST_READ, ¶m);
fprintf(stdout, "READ (%7ld bytes):\t\t", test->size);
if (ret < 0)
- fprintf(stdout, "TEST FAILED\n");
+ fprintf(stdout, "FAILED\n");
else
- fprintf(stdout, "%s\n", result[ret]);
+ fprintf(stdout, "SUCCESS\n");
}
if (test->copy) {
@@ -144,14 +145,14 @@ static int run_test(struct pci_test *test)
ret = ioctl(fd, PCITEST_COPY, ¶m);
fprintf(stdout, "COPY (%7ld bytes):\t\t", test->size);
if (ret < 0)
- fprintf(stdout, "TEST FAILED\n");
+ fprintf(stdout, "FAILED\n");
else
- fprintf(stdout, "%s\n", result[ret]);
+ fprintf(stdout, "SUCCESS\n");
}
fflush(stdout);
close(fd);
- return (ret < 0) ? ret : 1 - ret; /* return 0 if test succeeded */
+ return ret;
}
int main(int argc, char **argv)
--
2.25.1
On Fri, Aug 19, 2022 at 08:20:16PM +0530, Manivannan Sadhasivam wrote:
> "pci_endpoint_test" driver now returns 0 for success and negative error
> code for failure. So adapt to the change by reporting FAILURE if the
> return value is < 0, and SUCCESS otherwise.
>
> Signed-off-by: Manivannan Sadhasivam <[email protected]>
Fixes: tag and cc: stable?
thanks,
greg k-h
On Fri, Aug 19, 2022 at 05:27:24PM +0200, Greg KH wrote:
> On Fri, Aug 19, 2022 at 08:20:16PM +0530, Manivannan Sadhasivam wrote:
> > "pci_endpoint_test" driver now returns 0 for success and negative error
> > code for failure. So adapt to the change by reporting FAILURE if the
> > return value is < 0, and SUCCESS otherwise.
> >
> > Signed-off-by: Manivannan Sadhasivam <[email protected]>
>
> Fixes: tag and cc: stable?
>
Okay, then the same needs to be done for pci_endpoint_test and Documentation.
Thanks,
Mani
> thanks,
>
> greg k-h
--
மணிவண்ணன் சதாசிவம்
2022年8月19日(金) 23:50 Manivannan Sadhasivam <[email protected]>:
>
> "pci_endpoint_test" driver now returns 0 for success and negative error
> code for failure. So adapt to the change by reporting FAILURE if the
> return value is < 0, and SUCCESS otherwise.
>
> Signed-off-by: Manivannan Sadhasivam <[email protected]>
> ---
> tools/pci/pcitest.c | 41 +++++++++++++++++++++--------------------
> 1 file changed, 21 insertions(+), 20 deletions(-)
>
> diff --git a/tools/pci/pcitest.c b/tools/pci/pcitest.c
> index 441b54234635..a4e5b17cc3b5 100644
> --- a/tools/pci/pcitest.c
> +++ b/tools/pci/pcitest.c
> @@ -18,7 +18,6 @@
>
> #define BILLION 1E9
>
> -static char *result[] = { "NOT OKAY", "OKAY" };
> static char *irq[] = { "LEGACY", "MSI", "MSI-X" };
>
> struct pci_test {
> @@ -54,9 +53,9 @@ static int run_test(struct pci_test *test)
> ret = ioctl(fd, PCITEST_BAR, test->barnum);
> fprintf(stdout, "BAR%d:\t\t", test->barnum);
> if (ret < 0)
> - fprintf(stdout, "TEST FAILED\n");
> + fprintf(stdout, "FAILED\n");
> else
> - fprintf(stdout, "%s\n", result[ret]);
> + fprintf(stdout, "SUCCESS\n");
> }
>
> if (test->set_irqtype) {
> @@ -65,16 +64,18 @@ static int run_test(struct pci_test *test)
> if (ret < 0)
> fprintf(stdout, "FAILED\n");
> else
> - fprintf(stdout, "%s\n", result[ret]);
> + fprintf(stdout, "SUCCESS\n");
> }
>
> if (test->get_irqtype) {
> ret = ioctl(fd, PCITEST_GET_IRQTYPE);
> fprintf(stdout, "GET IRQ TYPE:\t\t");
> - if (ret < 0)
> + if (ret < 0) {
> fprintf(stdout, "FAILED\n");
> - else
> + } else {
> fprintf(stdout, "%s\n", irq[ret]);
> + ret = 0;
> + }
> }
>
> if (test->clear_irq) {
> @@ -83,34 +84,34 @@ static int run_test(struct pci_test *test)
> if (ret < 0)
> fprintf(stdout, "FAILED\n");
> else
> - fprintf(stdout, "%s\n", result[ret]);
> + fprintf(stdout, "SUCCESS\n");
> }
>
> if (test->legacyirq) {
> ret = ioctl(fd, PCITEST_LEGACY_IRQ, 0);
> fprintf(stdout, "LEGACY IRQ:\t");
> if (ret < 0)
> - fprintf(stdout, "TEST FAILED\n");
> + fprintf(stdout, "FAILED\n");
> else
> - fprintf(stdout, "%s\n", result[ret]);
> + fprintf(stdout, "SUCCESS\n");
> }
>
> if (test->msinum > 0 && test->msinum <= 32) {
> ret = ioctl(fd, PCITEST_MSI, test->msinum);
> fprintf(stdout, "MSI%d:\t\t", test->msinum);
> if (ret < 0)
> - fprintf(stdout, "TEST FAILED\n");
> + fprintf(stdout, "FAILED\n");
> else
> - fprintf(stdout, "%s\n", result[ret]);
> + fprintf(stdout, "SUCCESS\n");
> }
>
> if (test->msixnum > 0 && test->msixnum <= 2048) {
> ret = ioctl(fd, PCITEST_MSIX, test->msixnum);
> fprintf(stdout, "MSI-X%d:\t\t", test->msixnum);
> if (ret < 0)
> - fprintf(stdout, "TEST FAILED\n");
> + fprintf(stdout, "FAILED\n");
> else
> - fprintf(stdout, "%s\n", result[ret]);
> + fprintf(stdout, "SUCCESS\n");
> }
>
> if (test->write) {
> @@ -120,9 +121,9 @@ static int run_test(struct pci_test *test)
> ret = ioctl(fd, PCITEST_WRITE, ¶m);
> fprintf(stdout, "WRITE (%7ld bytes):\t\t", test->size);
> if (ret < 0)
> - fprintf(stdout, "TEST FAILED\n");
> + fprintf(stdout, "FAILED\n");
> else
> - fprintf(stdout, "%s\n", result[ret]);
> + fprintf(stdout, "SUCCESS\n");
> }
>
> if (test->read) {
> @@ -132,9 +133,9 @@ static int run_test(struct pci_test *test)
> ret = ioctl(fd, PCITEST_READ, ¶m);
> fprintf(stdout, "READ (%7ld bytes):\t\t", test->size);
> if (ret < 0)
> - fprintf(stdout, "TEST FAILED\n");
> + fprintf(stdout, "FAILED\n");
> else
> - fprintf(stdout, "%s\n", result[ret]);
> + fprintf(stdout, "SUCCESS\n");
> }
>
> if (test->copy) {
> @@ -144,14 +145,14 @@ static int run_test(struct pci_test *test)
> ret = ioctl(fd, PCITEST_COPY, ¶m);
> fprintf(stdout, "COPY (%7ld bytes):\t\t", test->size);
> if (ret < 0)
> - fprintf(stdout, "TEST FAILED\n");
> + fprintf(stdout, "FAILED\n");
> else
> - fprintf(stdout, "%s\n", result[ret]);
> + fprintf(stdout, "SUCCESS\n");
> }
>
> fflush(stdout);
> close(fd);
> - return (ret < 0) ? ret : 1 - ret; /* return 0 if test succeeded */
> + return ret;
> }
>
> int main(int argc, char **argv)
> --
> 2.25.1
>
Don't you use the errno of ioctl?
Thanks,
Shunsuke