Deleted Added
full compact
gpioc.c (233767) gpioc.c (274670)
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: head/sys/dev/gpio/gpioc.c 233767 2012-04-02 00:11:26Z gonzo $");
28__FBSDID("$FreeBSD: head/sys/dev/gpio/gpioc.c 274670 2014-11-18 17:22:08Z loos $");
29
30#include <sys/param.h>
31#include <sys/systm.h>
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/types.h>
33
34#include <sys/bus.h>
35#include <sys/conf.h>
32#include <sys/bus.h>
33#include <sys/conf.h>
34#include <sys/gpio.h>
36#include <sys/ioccom.h>
37#include <sys/kernel.h>
38#include <sys/malloc.h>
39#include <sys/module.h>
35#include <sys/ioccom.h>
36#include <sys/kernel.h>
37#include <sys/malloc.h>
38#include <sys/module.h>
40#include <sys/queue.h>
41#include <machine/bus.h>
42#include <machine/resource.h>
43
39
44#include <sys/gpio.h>
40#include <dev/gpio/gpiobusvar.h>
41
45#include "gpio_if.h"
46
47#undef GPIOC_DEBUG
48#ifdef GPIOC_DEBUG
49#define dprintf printf
50#else
51#define dprintf(x, arg...)
52#endif

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

114static int
115gpioc_ioctl(struct cdev *cdev, u_long cmd, caddr_t arg, int fflag,
116 struct thread *td)
117{
118 int max_pin, res;
119 struct gpioc_softc *sc = cdev->si_drv1;
120 struct gpio_pin pin;
121 struct gpio_req req;
42#include "gpio_if.h"
43
44#undef GPIOC_DEBUG
45#ifdef GPIOC_DEBUG
46#define dprintf printf
47#else
48#define dprintf(x, arg...)
49#endif

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

111static int
112gpioc_ioctl(struct cdev *cdev, u_long cmd, caddr_t arg, int fflag,
113 struct thread *td)
114{
115 int max_pin, res;
116 struct gpioc_softc *sc = cdev->si_drv1;
117 struct gpio_pin pin;
118 struct gpio_req req;
119 uint32_t caps;
122
123 switch (cmd) {
124 case GPIOMAXPIN:
125 max_pin = -1;
126 res = GPIO_PIN_MAX(sc->sc_pdev, &max_pin);
127 bcopy(&max_pin, arg, sizeof(max_pin));
128 break;
129 case GPIOGETCONFIG:

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

136 break;
137 GPIO_PIN_GETCAPS(sc->sc_pdev, pin.gp_pin, &pin.gp_caps);
138 GPIO_PIN_GETNAME(sc->sc_pdev, pin.gp_pin, pin.gp_name);
139 bcopy(&pin, arg, sizeof(pin));
140 break;
141 case GPIOSETCONFIG:
142 bcopy(arg, &pin, sizeof(pin));
143 dprintf("set config pin %d\n", pin.gp_pin);
120
121 switch (cmd) {
122 case GPIOMAXPIN:
123 max_pin = -1;
124 res = GPIO_PIN_MAX(sc->sc_pdev, &max_pin);
125 bcopy(&max_pin, arg, sizeof(max_pin));
126 break;
127 case GPIOGETCONFIG:

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

134 break;
135 GPIO_PIN_GETCAPS(sc->sc_pdev, pin.gp_pin, &pin.gp_caps);
136 GPIO_PIN_GETNAME(sc->sc_pdev, pin.gp_pin, pin.gp_name);
137 bcopy(&pin, arg, sizeof(pin));
138 break;
139 case GPIOSETCONFIG:
140 bcopy(arg, &pin, sizeof(pin));
141 dprintf("set config pin %d\n", pin.gp_pin);
144 res = GPIO_PIN_SETFLAGS(sc->sc_pdev, pin.gp_pin,
145 pin.gp_flags);
142 res = GPIO_PIN_GETCAPS(sc->sc_pdev, pin.gp_pin, &caps);
143 if (res == 0)
144 res = gpio_check_flags(caps, pin.gp_flags);
145 if (res == 0)
146 res = GPIO_PIN_SETFLAGS(sc->sc_pdev, pin.gp_pin,
147 pin.gp_flags);
146 break;
147 case GPIOGET:
148 bcopy(arg, &req, sizeof(req));
149 res = GPIO_PIN_GET(sc->sc_pdev, req.gp_pin,
150 &req.gp_value);
151 dprintf("read pin %d -> %d\n",
152 req.gp_pin, req.gp_value);
153 bcopy(&req, arg, sizeof(req));

--- 44 unchanged lines hidden ---
148 break;
149 case GPIOGET:
150 bcopy(arg, &req, sizeof(req));
151 res = GPIO_PIN_GET(sc->sc_pdev, req.gp_pin,
152 &req.gp_value);
153 dprintf("read pin %d -> %d\n",
154 req.gp_pin, req.gp_value);
155 bcopy(&req, arg, sizeof(req));

--- 44 unchanged lines hidden ---