From dc1613f1f15bef319641dfc903da06dccbf34e41 Mon Sep 17 00:00:00 2001 From: Alexander Yurchenko Date: Tue, 23 Nov 2004 21:18:38 +0000 Subject: Let gpio_detach() do something useful. Tested by reyk@ on gpio@ath. --- sys/dev/gpio/gpio.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'sys/dev/gpio/gpio.c') diff --git a/sys/dev/gpio/gpio.c b/sys/dev/gpio/gpio.c index 880beba48d2..fc4f6844696 100644 --- a/sys/dev/gpio/gpio.c +++ b/sys/dev/gpio/gpio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gpio.c,v 1.3 2004/11/22 15:37:42 reyk Exp $ */ +/* $OpenBSD: gpio.c,v 1.4 2004/11/23 21:18:37 grange Exp $ */ /* * Copyright (c) 2004 Alexander Yurchenko * @@ -25,6 +25,7 @@ #include #include #include +#include #include @@ -87,8 +88,19 @@ gpio_attach(struct device *parent, struct device *self, void *aux) } int -gpio_detach(struct device *parent, int flags) +gpio_detach(struct device *self, int flags) { + int maj, mn; + + /* Locate the major number */ + for (maj = 0; maj < nchrdev; maj++) + if (cdevsw[maj].d_open == gpioopen) + break; + + /* Nuke the vnodes for any open instances (calls close) */ + mn = self->dv_unit; + vdevgone(maj, mn, mn, VCHR); + return (0); } -- cgit v1.2.3