summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsbruno <sbruno@FreeBSD.org>2013-09-17 11:48:47 +0000
committersbruno <sbruno@FreeBSD.org>2013-09-17 11:48:47 +0000
commit1c5decc9ed968de7a8be874423cc23647c997e83 (patch)
treebefc5b6ebabea0ecde94a11b2cdcbf1102c639ab
parentebe265b408d7b30f95ca40e8a60a7c15cf20afc1 (diff)
downloadFreeBSD-src-1c5decc9ed968de7a8be874423cc23647c997e83.zip
FreeBSD-src-1c5decc9ed968de7a8be874423cc23647c997e83.tar.gz
Assume that the -f argument is /dev/gpioc0 if it is not passed.
hrs@ provided this verison of the patch and showed me where all the needed changes were to be made outside of gpioctl.c Approved by: re (hrs) MFC after: 2 weeks
-rw-r--r--include/paths.h1
-rw-r--r--usr.sbin/gpioctl/gpioctl.810
-rw-r--r--usr.sbin/gpioctl/gpioctl.c12
3 files changed, 14 insertions, 9 deletions
diff --git a/include/paths.h b/include/paths.h
index c0a99a5..89c9fc9 100644
--- a/include/paths.h
+++ b/include/paths.h
@@ -50,6 +50,7 @@
#define _PATH_CSHELL "/bin/csh"
#define _PATH_CSMAPPER "/usr/share/i18n/csmapper"
#define _PATH_DEFTAPE "/dev/sa0"
+#define _PATH_DEVGPIOC "/dev/gpioc"
#define _PATH_DEVNULL "/dev/null"
#define _PATH_DEVZERO "/dev/zero"
#define _PATH_DRUM "/dev/drum"
diff --git a/usr.sbin/gpioctl/gpioctl.8 b/usr.sbin/gpioctl/gpioctl.8
index ab936a4..c1abb5e 100644
--- a/usr.sbin/gpioctl/gpioctl.8
+++ b/usr.sbin/gpioctl/gpioctl.8
@@ -36,20 +36,20 @@
.Sh SYNOPSIS
.Nm
.Cm -l
-.Fl f Ar ctldev
+.Op Fl f Ar ctldev
.Op Fl v
.Nm
.Cm -t
-.Fl f Ar ctldev
+.Op Fl f Ar ctldev
.Ar pin
.Nm
.Cm -c
-.Fl f Ar ctldev
+.Op Fl f Ar ctldev
.Ar pin
.Ar flag
.Op flag ...
.Nm
-.Cm -f Ar ctldev
+.Op Cm -f Ar ctldev
.Ar pin
.Ar [0|1]
.Sh DESCRIPTION
@@ -83,6 +83,8 @@ Inverted output pin
.El
.It Fl f Ar ctldev
GPIO controller device to use
+If not specified, defaults to
+.Pa /dev/gpioc0
.It Fl l
list available pins
.It Fl t Ar pin
diff --git a/usr.sbin/gpioctl/gpioctl.c b/usr.sbin/gpioctl/gpioctl.c
index 9d76e1d..e4708a4 100644
--- a/usr.sbin/gpioctl/gpioctl.c
+++ b/usr.sbin/gpioctl/gpioctl.c
@@ -30,6 +30,7 @@ __FBSDID("$FreeBSD$");
#include <fcntl.h>
#include <getopt.h>
+#include <paths.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
@@ -63,10 +64,10 @@ static void
usage(void)
{
fprintf(stderr, "Usage:\n");
- fprintf(stderr, "\tgpioctl -f ctldev -l [-v]\n");
- fprintf(stderr, "\tgpioctl -f ctldev -t pin\n");
- fprintf(stderr, "\tgpioctl -f ctldev -c pin flag ...\n");
- fprintf(stderr, "\tgpioctl -f ctldev pin [0|1]\n");
+ fprintf(stderr, "\tgpioctl [-f ctldev] -l [-v]\n");
+ fprintf(stderr, "\tgpioctl [-f ctldev] -t pin\n");
+ fprintf(stderr, "\tgpioctl [-f ctldev] -c pin flag ...\n");
+ fprintf(stderr, "\tgpioctl [-f ctldev] pin [0|1]\n");
exit(1);
}
@@ -185,6 +186,7 @@ main(int argc, char **argv)
int i;
struct gpio_pin pin;
struct gpio_req req;
+ char defctlfile[] = _PATH_DEVGPIOC "0";
char *ctlfile = NULL;
int pinn, pinv, fd, ch;
int flags, flag, ok;
@@ -226,7 +228,7 @@ main(int argc, char **argv)
printf("%d/%s\n", i, argv[i]);
if (ctlfile == NULL)
- fail("No gpioctl device provided\n");
+ ctlfile = defctlfile;
fd = open(ctlfile, O_RDONLY);
if (fd < 0) {
OpenPOWER on IntegriCloud