summaryrefslogtreecommitdiff
path: root/sys
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
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')
-rw-r--r--sys/dev/gpio/gpio.c89
-rw-r--r--sys/sys/gpio.h6
2 files changed, 47 insertions, 48 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;
}
diff --git a/sys/sys/gpio.h b/sys/sys/gpio.h
index 9bee1c2e60d..50e5a54dead 100644
--- a/sys/sys/gpio.h
+++ b/sys/sys/gpio.h
@@ -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>
@@ -76,7 +76,7 @@ struct gpio_set {
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 @@ struct gpio_attach {
#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 @@ struct gpio_pin_op {
#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_ */