Deleted Added
full compact
gpioled.c (266105) gpioled.c (278783)
1/*-
2 * Copyright (c) 2009 Oleksandr Tymoshenko <gonzo@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2009 Oleksandr Tymoshenko <gonzo@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: stable/10/sys/dev/gpio/gpioled.c 266105 2014-05-15 01:27:53Z loos $");
28__FBSDID("$FreeBSD: stable/10/sys/dev/gpio/gpioled.c 278783 2015-02-14 20:50:38Z loos $");
29
30#include "opt_platform.h"
31
32#include <sys/param.h>
33#include <sys/systm.h>
29
30#include "opt_platform.h"
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/bio.h>
35#include <sys/bus.h>
34#include <sys/bus.h>
36#include <sys/conf.h>
35#include <sys/gpio.h>
37#include <sys/kernel.h>
36#include <sys/kernel.h>
38#include <sys/kthread.h>
39#include <sys/lock.h>
40#include <sys/malloc.h>
41#include <sys/module.h>
42#include <sys/mutex.h>
43
44#ifdef FDT
45#include <dev/fdt/fdt_common.h>
37#include <sys/lock.h>
38#include <sys/malloc.h>
39#include <sys/module.h>
40#include <sys/mutex.h>
41
42#ifdef FDT
43#include <dev/fdt/fdt_common.h>
46#include <dev/gpio/gpiobusvar.h>
47#include <dev/ofw/ofw_bus.h>
48#endif
49
44#include <dev/ofw/ofw_bus.h>
45#endif
46
47#include <dev/gpio/gpiobusvar.h>
50#include <dev/led/led.h>
48#include <dev/led/led.h>
51#include <sys/gpio.h>
49
52#include "gpiobus_if.h"
53
54/*
55 * Only one pin for led
56 */
57#define GPIOLED_PIN 0
58
59#define GPIOLED_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx)

--- 14 unchanged lines hidden (view full) ---

74static void gpioled_control(void *, int);
75static int gpioled_probe(device_t);
76static int gpioled_attach(device_t);
77static int gpioled_detach(device_t);
78
79static void
80gpioled_control(void *priv, int onoff)
81{
50#include "gpiobus_if.h"
51
52/*
53 * Only one pin for led
54 */
55#define GPIOLED_PIN 0
56
57#define GPIOLED_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx)

--- 14 unchanged lines hidden (view full) ---

72static void gpioled_control(void *, int);
73static int gpioled_probe(device_t);
74static int gpioled_attach(device_t);
75static int gpioled_detach(device_t);
76
77static void
78gpioled_control(void *priv, int onoff)
79{
82 struct gpioled_softc *sc = priv;
80 int error;
81 struct gpioled_softc *sc;
82
83 sc = (struct gpioled_softc *)priv;
83 GPIOLED_LOCK(sc);
84 GPIOLED_LOCK(sc);
84 GPIOBUS_LOCK_BUS(sc->sc_busdev);
85 GPIOBUS_ACQUIRE_BUS(sc->sc_busdev, sc->sc_dev);
86 GPIOBUS_PIN_SETFLAGS(sc->sc_busdev, sc->sc_dev, GPIOLED_PIN,
87 GPIO_PIN_OUTPUT);
88 GPIOBUS_PIN_SET(sc->sc_busdev, sc->sc_dev, GPIOLED_PIN,
89 onoff ? GPIO_PIN_HIGH : GPIO_PIN_LOW);
85 error = GPIOBUS_ACQUIRE_BUS(sc->sc_busdev, sc->sc_dev,
86 GPIOBUS_DONTWAIT);
87 if (error != 0) {
88 GPIOLED_UNLOCK(sc);
89 return;
90 }
91 error = GPIOBUS_PIN_SETFLAGS(sc->sc_busdev, sc->sc_dev,
92 GPIOLED_PIN, GPIO_PIN_OUTPUT);
93 if (error == 0)
94 GPIOBUS_PIN_SET(sc->sc_busdev, sc->sc_dev, GPIOLED_PIN,
95 onoff ? GPIO_PIN_HIGH : GPIO_PIN_LOW);
90 GPIOBUS_RELEASE_BUS(sc->sc_busdev, sc->sc_dev);
96 GPIOBUS_RELEASE_BUS(sc->sc_busdev, sc->sc_dev);
91 GPIOBUS_UNLOCK_BUS(sc->sc_busdev);
92 GPIOLED_UNLOCK(sc);
93}
94
95#ifdef FDT
96static void
97gpioled_identify(driver_t *driver, device_t bus)
98{
99 phandle_t child, leds, root;

--- 129 unchanged lines hidden ---
97 GPIOLED_UNLOCK(sc);
98}
99
100#ifdef FDT
101static void
102gpioled_identify(driver_t *driver, device_t bus)
103{
104 phandle_t child, leds, root;

--- 129 unchanged lines hidden ---