summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authormbalmer <mbalmer@NetBSD.org>2011-10-03 11:16:47 +0000
committermbalmer <mbalmer@NetBSD.org>2011-10-03 11:16:47 +0000
commitdc2d28b27812e26d245cd6090f087f6d22b5ce40 (patch)
treecf1723cbc5200079abef0ecaec69637863edb60b /sys/dev
parentb121b72df6e5d1d34ab00babebc7790c8df0e9c8 (diff)
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 (limited to 'sys/dev')
-rw-r--r--sys/dev/gpio/gpio.c89
1 files changed, 44 insertions, 45 deletions
diff --git a/sys/dev/gpio/gpio.c b/sys/dev/gpio/gpio.c
index 5a4e6f0bfbe..5811373dd20 100644
--- a/sys/dev/gpio/gpio.c
+++ b/sys/dev/gpio/gpio.c
@@ -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 @@ gpio_ioctl(struct gpio_softc *sc, u_long cmd, void *data, int flag,
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 @@ gpio_ioctl_oapi(struct gpio_softc *sc, u_long cmd, void *data, int flag,
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;
}