Deleted Added
full compact
smbconf.c (59760) smbconf.c (93023)
1/*-
1/*-
2 * Copyright (c) 1998 Nicolas Souchu
2 * Copyright (c) 1998, 2001 Nicolas Souchu
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
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright

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

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
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 *
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
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright

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

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
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 * $FreeBSD: head/sys/dev/smbus/smbconf.c 59760 2000-04-29 15:36:14Z phk $
26 * $FreeBSD: head/sys/dev/smbus/smbconf.c 93023 2002-03-23 15:49:15Z nsouch $
27 *
28 */
29#include <sys/param.h>
30#include <sys/systm.h>
31#include <sys/module.h>
32#include <sys/bus.h>
33
34#include <dev/smbus/smbconf.h>

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

73 error = EBUSY;
74 } else {
75 error = EINVAL;
76 }
77
78 return (error);
79}
80
27 *
28 */
29#include <sys/param.h>
30#include <sys/systm.h>
31#include <sys/module.h>
32#include <sys/bus.h>
33
34#include <dev/smbus/smbconf.h>

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

73 error = EBUSY;
74 } else {
75 error = EINVAL;
76 }
77
78 return (error);
79}
80
81/*
82 * smbus_alloc_bus()
83 *
84 * Allocate a new bus connected to the given parent device
85 */
86device_t
87smbus_alloc_bus(device_t parent)
88{
89 device_t child;
90
91 /* add the bus to the parent */
92 child = device_add_child(parent, "smbus", -1);
93
94 return (child);
95}
96
97static int
98smbus_poll(struct smbus_softc *sc, int how)
99{
100 int error;
101
102 switch (how) {
103 case (SMB_WAIT | SMB_INTR):
104 error = tsleep(sc, SMBPRI|PCATCH, "smbreq", 0);

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

185 sc->owner = 0;
186 splx(s);
187
188 /* wakeup waiting processes */
189 wakeup(sc);
190
191 return (0);
192}
81static int
82smbus_poll(struct smbus_softc *sc, int how)
83{
84 int error;
85
86 switch (how) {
87 case (SMB_WAIT | SMB_INTR):
88 error = tsleep(sc, SMBPRI|PCATCH, "smbreq", 0);

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

169 sc->owner = 0;
170 splx(s);
171
172 /* wakeup waiting processes */
173 wakeup(sc);
174
175 return (0);
176}
193
194/*
195 * smbus_get_addr()
196 *
197 * Get the I2C 7 bits address of the device
198 */
199u_char
200smbus_get_addr(device_t dev)
201{
202 uintptr_t addr;
203 device_t parent = device_get_parent(dev);
204
205 BUS_READ_IVAR(parent, dev, SMBUS_IVAR_ADDR, &addr);
206
207 return ((u_char)addr);
208}