Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Remove the GPIODETACH gpio(4) ioctl (it is still available i...
details: https://anonhg.NetBSD.org/src/rev/f426655e653f
branches: trunk
changeset: 770091:f426655e653f
user: mbalmer <mbalmer%NetBSD.org@localhost>
date: Mon Oct 03 11:16:47 2011 +0000
description:
Remove the GPIODETACH gpio(4) ioctl (it is still available in COMPAT_50) and
the 'detach' command line option from gpioctl(8). Drivers that are
attached to gpio pins can be detached using the drvctl(8) command.
diffstat:
share/man/man4/gpio.4 | 19 +++------
sys/dev/gpio/gpio.c | 89 ++++++++++++++++++++++-----------------------
sys/sys/gpio.h | 6 +-
usr.sbin/gpioctl/gpioctl.8 | 15 +++----
usr.sbin/gpioctl/gpioctl.c | 19 +---------
5 files changed, 61 insertions(+), 87 deletions(-)
diffs (truncated from 310 to 300 lines):
diff -r 4e9e770d0c2f -r f426655e653f share/man/man4/gpio.4
--- a/share/man/man4/gpio.4 Mon Oct 03 10:30:13 2011 +0000
+++ b/share/man/man4/gpio.4 Mon Oct 03 11:16:47 2011 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: gpio.4,v 1.20 2011/10/02 09:33:18 mbalmer Exp $
+.\" $NetBSD: gpio.4,v 1.21 2011/10/03 11:16:47 mbalmer Exp $
.\" $OpenBSD: gpio.4,v 1.5 2004/11/23 09:39:29 reyk Exp $
.\"
.\" Copyright (c) 2004 Alexander Yurchenko <grange%openbsd.org@localhost>
@@ -15,7 +15,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd October 2, 2011
+.Dd October 3, 2011
.Dt GPIO 4
.Os
.Sh NAME
@@ -220,18 +220,10 @@
uint32_t ga_flags; /* driver dependent */
};
.Ed
-.It Dv GPIODETACH (struct gpio_attach)
-Detach a device from this gpio device that was previously attached using the
-.Dv GPIOATTACH
-.Xr ioctl 2 .
+.Pp
The
-.Fa ga_offset ,
-.Fa ga_mask ,
-and
-.Fa ga_flags
-fields of the
-.Fa gpio_attach
-structure are ignored.
+.Xr drvctl 8
+command can be used to detach a device from a gpio pin.
.El
.Sh FILES
.Bl -tag -width "/dev/gpiou" -compact
@@ -241,6 +233,7 @@
file.
.El
.Sh SEE ALSO
+.Xr drvctl 8 ,
.Xr ioctl 2 ,
.Xr gpioctl 8
.Sh HISTORY
diff -r 4e9e770d0c2f -r f426655e653f sys/dev/gpio/gpio.c
--- a/sys/dev/gpio/gpio.c Mon Oct 03 10:30:13 2011 +0000
+++ b/sys/dev/gpio/gpio.c Mon Oct 03 11:16:47 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gpio.c,v 1.43 2011/10/03 08:23:58 mbalmer Exp $ */
+/* $NetBSD: gpio.c,v 1.44 2011/10/03 11:16:47 mbalmer Exp $ */
/* $OpenBSD: gpio.c,v 1.6 2006/01/14 12:33:49 grange Exp $ */
/*
@@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gpio.c,v 1.43 2011/10/03 08:23:58 mbalmer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gpio.c,v 1.44 2011/10/03 11:16:47 mbalmer Exp $");
/*
* General Purpose Input/Output framework.
@@ -737,49 +737,6 @@
cv_signal(&sc->sc_attach);
mutex_exit(&sc->sc_mtx);
return error;
-#ifdef COMPAT_50
- case GPIODETACH50:
- /* FALLTHOUGH */
-#endif
- case GPIODETACH:
- if (kauth_authorize_device(cred, KAUTH_DEVICE_GPIO_PINSET,
- NULL, NULL, NULL, NULL))
- return EPERM;
-
- error = 0;
- mutex_enter(&sc->sc_mtx);
- while (sc->sc_attach_busy) {
- error = cv_wait_sig(&sc->sc_attach, &sc->sc_mtx);
- if (error)
- break;
- }
- if (!error)
- sc->sc_attach_busy = 1;
- mutex_exit(&sc->sc_mtx);
- if (error)
- return EBUSY;
-
- attach = data;
- LIST_FOREACH(gdev, &sc->sc_devs, sc_next) {
- if (strcmp(device_xname(gdev->sc_dev),
- attach->ga_dvname) == 0) {
- mutex_enter(&sc->sc_mtx);
- sc->sc_attach_busy = 0;
- cv_signal(&sc->sc_attach);
- mutex_exit(&sc->sc_mtx);
-
- if (config_detach(gdev->sc_dev, 0) == 0)
- return 0;
- break;
- }
- }
- if (gdev == NULL) {
- mutex_enter(&sc->sc_mtx);
- sc->sc_attach_busy = 0;
- cv_signal(&sc->sc_attach);
- mutex_exit(&sc->sc_mtx);
- }
- return EINVAL;
case GPIOSET:
if (kauth_authorize_device(cred, KAUTH_DEVICE_GPIO_PINSET,
NULL, NULL, NULL, NULL))
@@ -987,6 +944,48 @@
sc->sc_pins[pin].pin_flags = flags;
}
break;
+ case GPIODETACH50:
+ /* FALLTHOUGH */
+ case GPIODETACH:
+ if (kauth_authorize_device(cred, KAUTH_DEVICE_GPIO_PINSET,
+ NULL, NULL, NULL, NULL))
+ return EPERM;
+
+ error = 0;
+ mutex_enter(&sc->sc_mtx);
+ while (sc->sc_attach_busy) {
+ error = cv_wait_sig(&sc->sc_attach, &sc->sc_mtx);
+ if (error)
+ break;
+ }
+ if (!error)
+ sc->sc_attach_busy = 1;
+ mutex_exit(&sc->sc_mtx);
+ if (error)
+ return EBUSY;
+
+ attach = data;
+ LIST_FOREACH(gdev, &sc->sc_devs, sc_next) {
+ if (strcmp(device_xname(gdev->sc_dev),
+ attach->ga_dvname) == 0) {
+ mutex_enter(&sc->sc_mtx);
+ sc->sc_attach_busy = 0;
+ cv_signal(&sc->sc_attach);
+ mutex_exit(&sc->sc_mtx);
+
+ if (config_detach(gdev->sc_dev, 0) == 0)
+ return 0;
+ break;
+ }
+ }
+ if (gdev == NULL) {
+ mutex_enter(&sc->sc_mtx);
+ sc->sc_attach_busy = 0;
+ cv_signal(&sc->sc_attach);
+ mutex_exit(&sc->sc_mtx);
+ }
+ return EINVAL;
+
default:
return ENOTTY;
}
diff -r 4e9e770d0c2f -r f426655e653f sys/sys/gpio.h
--- a/sys/sys/gpio.h Mon Oct 03 10:30:13 2011 +0000
+++ b/sys/sys/gpio.h Mon Oct 03 11:16:47 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gpio.h,v 1.10 2011/10/02 09:33:19 mbalmer Exp $ */
+/* $NetBSD: gpio.h,v 1.11 2011/10/03 11:16:47 mbalmer Exp $ */
/* $OpenBSD: gpio.h,v 1.7 2008/11/26 14:51:20 mbalmer Exp $ */
/*
* Copyright (c) 2009, 2011 Marc Balmer <marc%msys.ch@localhost>
@@ -76,7 +76,7 @@
char gp_name2[GPIOMAXNAME]; /* new name */
};
-/* Attach/detach device drivers that use GPIO pins */
+/* Attach device drivers that use GPIO pins */
struct gpio_attach {
char ga_dvname[16]; /* device name */
int ga_offset; /* pin number */
@@ -92,7 +92,6 @@
#define GPIOWRITE _IOWR('G', 8, struct gpio_req)
#define GPIOTOGGLE _IOWR('G', 9, struct gpio_req)
#define GPIOATTACH _IOWR('G', 10, struct gpio_attach)
-#define GPIODETACH _IOWR('G', 11, struct gpio_attach)
#define GPIOPULSE _IOWR('G', 12, struct gpio_pulse)
#ifdef COMPAT_50
@@ -123,6 +122,7 @@
#define GPIOPINCTL _IOWR('G', 4, struct gpio_pin_ctl)
#define GPIOATTACH50 _IOWR('G', 10, struct gpio_attach50)
#define GPIODETACH50 _IOWR('G', 11, struct gpio_attach50)
+#define GPIODETACH _IOWR('G', 11, struct gpio_attach)
#endif /* COMPAT_50 */
#endif /* !_SYS_GPIO_H_ */
diff -r 4e9e770d0c2f -r f426655e653f usr.sbin/gpioctl/gpioctl.8
--- a/usr.sbin/gpioctl/gpioctl.8 Mon Oct 03 10:30:13 2011 +0000
+++ b/usr.sbin/gpioctl/gpioctl.8 Mon Oct 03 11:16:47 2011 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: gpioctl.8,v 1.12 2011/10/02 12:43:53 mbalmer Exp $
+.\" $NetBSD: gpioctl.8,v 1.13 2011/10/03 11:16:48 mbalmer Exp $
.\"
.\" Copyright (c) 2009, 2010, 2011 Marc Balmer <marc%msys.ch@localhost>
.\" Copyright (c) 2004 Alexander Yurchenko <grange%openbsd.org@localhost>
@@ -15,7 +15,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd October 2, 2011
+.Dd October 3, 2011
.Dt GPIOCTL 8
.Os
.Sh NAME
@@ -33,11 +33,6 @@
.Nm gpioctl
.Op Fl q
.Ar device
-.Cm detach
-.Ar device
-.Nm gpioctl
-.Op Fl q
-.Ar device
.Ar pin
.Op Ar 0 | 1 | 2
.Nm gpioctl
@@ -131,6 +126,9 @@
device using the
.Nm
command.
+Such drivers can be detached at runtime using the
+.Xr drvctl 8
+command.
.Pp
The following configuration
.Ar flags
@@ -204,7 +202,7 @@
.Pp
Detach the gpioow0 device:
.Pp
-.Dl # gpioctl gpio0 detach gpioow0
+.Dl # drvctl -d gpioow0
.Pp
Configure pin 5 as output and name it error_led:
.Pp
@@ -214,6 +212,7 @@
.Pp
.Dl # gpioctl gpio0 error_led 2
.Sh SEE ALSO
+.Xr drvctl 8 ,
.Xr gpio 4
.Sh HISTORY
The
diff -r 4e9e770d0c2f -r f426655e653f usr.sbin/gpioctl/gpioctl.c
--- a/usr.sbin/gpioctl/gpioctl.c Mon Oct 03 10:30:13 2011 +0000
+++ b/usr.sbin/gpioctl/gpioctl.c Mon Oct 03 11:16:47 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gpioctl.c,v 1.15 2011/10/02 12:43:53 mbalmer Exp $ */
+/* $NetBSD: gpioctl.c,v 1.16 2011/10/03 11:16:48 mbalmer Exp $ */
/*
* Copyright (c) 2008, 2010, 2011 Marc Balmer <mbalmer%NetBSD.org@localhost>
@@ -47,7 +47,6 @@
static void gpioset(int pin, char *name, int flags, char *alias);
static void gpiounset(int pin, char *name);
static void devattach(char *, int, uint32_t, uint32_t);
-static void devdetach(char *);
__dead static void usage(void);
extern long long strtonum(const char *numstr, long long minval,
@@ -153,10 +152,6 @@
}
devattach(driver, ga_offset, ga_mask, ga_flags);
return EXIT_SUCCESS;
- } else if (!strcmp(argv[1], "detach")) {
- if (argc != 3)
- usage();
- devdetach(argv[2]);
} else {
char *nm = NULL;
@@ -414,17 +409,6 @@
}
static void
-devdetach(char *dvname)
-{
- struct gpio_attach attach;
-
- memset(&attach, 0, sizeof(attach));
- strlcpy(attach.ga_dvname, dvname, sizeof(attach.ga_dvname));
- if (ioctl(devfd, GPIODETACH, &attach) == -1)
- err(EXIT_FAILURE, "GPIODETACH");
-}
-
-static void
usage(void)
Home |
Main Index |
Thread Index |
Old Index