svn commit: r299563 - head/sys/dev/gpio
Oleksandr Tymoshenko
gonzo at FreeBSD.org
Thu May 12 20:12:47 UTC 2016
Author: gonzo
Date: Thu May 12 20:12:45 2016
New Revision: 299563
URL: https://svnweb.freebsd.org/changeset/base/299563
Log:
Add gpiobus_release_pin function to release mapped pin
Add gpiobus_release_pin as a counterpart for gpiobus_map_pin. Without it
it's impossible to properly release pin so if kernel module is reloaded
it can't re-use pins again
Modified:
head/sys/dev/gpio/gpiobus.c
head/sys/dev/gpio/gpiobusvar.h
Modified: head/sys/dev/gpio/gpiobus.c
==============================================================================
--- head/sys/dev/gpio/gpiobus.c Thu May 12 20:04:09 2016 (r299562)
+++ head/sys/dev/gpio/gpiobus.c Thu May 12 20:12:45 2016 (r299563)
@@ -281,6 +281,30 @@ gpiobus_map_pin(device_t bus, uint32_t p
return (0);
}
+/* Release mapped pin */
+int
+gpiobus_release_pin(device_t bus, uint32_t pin)
+{
+ struct gpiobus_softc *sc;
+
+ sc = device_get_softc(bus);
+ /* Consistency check. */
+ if (pin >= sc->sc_npins) {
+ device_printf(bus,
+ "gpiobus_map_pin: invalid pin %d, max=%d\n",
+ pin, sc->sc_npins - 1);
+ return (-1);
+ }
+
+ if (!sc->sc_pins[pin].mapped) {
+ device_printf(bus, "gpiobus_map_pin: pin %d is not mapped\n", pin);
+ return (-1);
+ }
+ sc->sc_pins[pin].mapped = 0;
+
+ return (0);
+}
+
static int
gpiobus_parse_pins(struct gpiobus_softc *sc, device_t child, int mask)
{
Modified: head/sys/dev/gpio/gpiobusvar.h
==============================================================================
--- head/sys/dev/gpio/gpiobusvar.h Thu May 12 20:04:09 2016 (r299562)
+++ head/sys/dev/gpio/gpiobusvar.h Thu May 12 20:12:45 2016 (r299563)
@@ -138,6 +138,7 @@ int gpiobus_init_softc(device_t);
int gpiobus_alloc_ivars(struct gpiobus_ivar *);
void gpiobus_free_ivars(struct gpiobus_ivar *);
int gpiobus_map_pin(device_t, uint32_t);
+int gpiobus_release_pin(device_t, uint32_t);
extern driver_t gpiobus_driver;
More information about the svn-src-head
mailing list