aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amdfalconx86/recipes-applications/gpio-test/files/gpio-test.c
diff options
context:
space:
mode:
Diffstat (limited to 'meta-amdfalconx86/recipes-applications/gpio-test/files/gpio-test.c')
-rw-r--r--meta-amdfalconx86/recipes-applications/gpio-test/files/gpio-test.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/meta-amdfalconx86/recipes-applications/gpio-test/files/gpio-test.c b/meta-amdfalconx86/recipes-applications/gpio-test/files/gpio-test.c
index 6cd073bd..41a16765 100644
--- a/meta-amdfalconx86/recipes-applications/gpio-test/files/gpio-test.c
+++ b/meta-amdfalconx86/recipes-applications/gpio-test/files/gpio-test.c
@@ -109,7 +109,34 @@ void parse_cmd(const char *cmdline)
{
int fd;
- if (strncmp(cmdline, "help", 4) == 0)
+ if ((cmdline == NULL) || (strncmp(cmdline, "exit", 4) == 0)) {
+ int i;
+ int ret;
+ char gpio[3 + 1];
+
+ printf("\nExiting...\n");
+
+ /* We need to unexport all the GPIO pins exported earlier */
+ for (i = 0; i < AMD_GPIO_NUM_PINS; i++) {
+ if (gpio_in_use[i]) {
+ int fd;
+
+ fd = open("/sys/class/gpio/unexport", O_WRONLY);
+ if (fd < 0) {
+ printf("\nPlease make sure AMD GPIO driver is loaded\n");
+ exit(EXIT_FAILURE);
+ }
+ memset(gpio, '\0', (3 + 1));
+ snprintf(gpio, 4, "%d", i);
+
+ ret = write(fd, gpio, strlen(gpio));
+ if (ret < 0)
+ perror("Error writing to /sys/class/gpio/unexport");
+ }
+ }
+
+ exit(EXIT_SUCCESS);
+ } else if (strncmp(cmdline, "help", 4) == 0)
print_usage();
else if (strncmp(cmdline, "getnumgpio", 10) == 0) {
int fd;
@@ -470,33 +497,6 @@ void parse_cmd(const char *cmdline)
perror("Error executing \'dmesg | grep GPIO\'");
} else if (strncmp(cmdline, "license", 7) == 0) {
show_license();
- } else if (strncmp(cmdline, "exit", 4) == 0) {
- int i;
- int ret;
- char gpio[3 + 1];
-
- printf("\nExiting...\n");
-
- /* We need to unexport all the GPIO pins exported earlier */
- for (i = 0; i < AMD_GPIO_NUM_PINS; i++) {
- if (gpio_in_use[i]) {
- int fd;
-
- fd = open("/sys/class/gpio/unexport", O_WRONLY);
- if (fd < 0) {
- printf("\nPlease make sure AMD GPIO driver is loaded\n");
- exit(EXIT_FAILURE);
- }
- memset(gpio, '\0', (3 + 1));
- snprintf(gpio, 4, "%d", i);
-
- ret = write(fd, gpio, strlen(gpio));
- if (ret < 0)
- perror("Error writing to /sys/class/gpio/unexport");
- }
- }
-
- exit(EXIT_SUCCESS);
} else {
printf("\nUnknown command\n");
print_usage();