From owner-p4-projects@FreeBSD.ORG Thu Dec 4 23:26:13 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 013A41065675; Thu, 4 Dec 2008 23:26:13 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B89B3106564A for ; Thu, 4 Dec 2008 23:26:12 +0000 (UTC) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id A92118FC0C for ; Thu, 4 Dec 2008 23:26:12 +0000 (UTC) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id mB4NQCWc050097 for ; Thu, 4 Dec 2008 23:26:12 GMT (envelope-from sam@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id mB4NQCcR050095 for perforce@freebsd.org; Thu, 4 Dec 2008 23:26:12 GMT (envelope-from sam@freebsd.org) Date: Thu, 4 Dec 2008 23:26:12 GMT Message-Id: <200812042326.mB4NQCcR050095@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sam@freebsd.org using -f From: Sam Leffler To: Perforce Change Reviews Cc: Subject: PERFORCE change 154083 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Dec 2008 23:26:13 -0000 http://perforce.freebsd.org/chv.cgi?CH=154083 Change 154083 by sam@sam_ebb on 2008/12/04 23:26:09 give this a little TLC Affected files ... .. //depot/projects/vap/sys/arm/xscale/ixp425/avila_led.c#3 edit Differences ... ==== //depot/projects/vap/sys/arm/xscale/ixp425/avila_led.c#3 (text+ko) ==== @@ -37,22 +37,19 @@ #include #define GPIO_LED_STATUS 3 -#define GPIO_LED_STATUS_BIT (1U << GPIO_LED_STATUS) +#define GPIO_LED_STATUS_BIT (1U << GPIO_LED_STATUS) -static struct cdev *gpioled; - struct led_avila_softc { device_t sc_dev; bus_space_tag_t sc_iot; bus_space_handle_t sc_gpio_ioh; + struct cdev *sc_led; }; -static struct led_avila_softc *led_avila_sc = NULL; - static void -led_func(void *unused, int onoff) +led_func(void *arg, int onoff) { - struct led_avila_softc *sc = led_avila_sc; + struct led_avila_softc *sc = arg; uint32_t reg; reg = GPIO_CONF_READ_4(sc, IXP425_GPIO_GPOUTR); @@ -66,7 +63,7 @@ static int led_avila_probe(device_t dev) { - device_set_desc(dev, "Gateworks Avila GPIO connected LED"); + device_set_desc(dev, "Gateworks Avila Front Panel LED"); return (0); } @@ -75,31 +72,35 @@ { struct led_avila_softc *sc = device_get_softc(dev); struct ixp425_softc *sa = device_get_softc(device_get_parent(dev)); - void *led = NULL; - uint32_t reg; - led_avila_sc = sc; - sc->sc_dev = dev; sc->sc_iot = sa->sc_iot; sc->sc_gpio_ioh = sa->sc_gpio_ioh; /* Configure LED GPIO pin as output */ - reg = GPIO_CONF_READ_4(sc, IXP425_GPIO_GPOER); - reg &= ~GPIO_LED_STATUS_BIT; - GPIO_CONF_WRITE_4(sc, IXP425_GPIO_GPOER, reg); + GPIO_CONF_WRITE_4(sc, IXP425_GPIO_GPOER, + GPIO_CONF_READ_4(sc, IXP425_GPIO_GPOER) &~ GPIO_LED_STATUS_BIT); - gpioled = led_create(led_func, led, "gpioled"); + sc->sc_led = led_create(led_func, sc, "gpioled"); - /* Turn on LED */ - led_func(led, 1); + led_func(sc, 1); /* Turn on LED */ return (0); } +static void +led_avila_detach(device_t dev) +{ + struct led_avila_softc *sc = device_get_softc(dev); + + if (sc->sc_led != NULL) + led_destroy(sc->sc_led); +} + static device_method_t led_avila_methods[] = { DEVMETHOD(device_probe, led_avila_probe), DEVMETHOD(device_attach, led_avila_attach), + DEVMETHOD(device_detach, led_avila_detach), {0, 0}, };