1/*-
2 * Copyright (c) 1998 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 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 * $Id: smb.c,v 1.4 1998/12/07 21:58:17 archie Exp $
27 *
28 */
29#include <sys/param.h>
30#include <sys/kernel.h>
31#include <sys/systm.h>
32#include <sys/module.h>
33#include <sys/bus.h>
34#include <sys/conf.h>
--- 117 unchanged lines hidden (view full) ---
152 sc->sc_count--;
153
154 return (0);
155}
156
157static int
158smbwrite(dev_t dev, struct uio * uio, int ioflag)
159{
160 /* not supported */
161
162 return (EINVAL);
163}
164
165static int
166smbread(dev_t dev, struct uio * uio, int ioflag)
167{
168 /* not supported */
169
170 return (EINVAL);
--- 4 unchanged lines hidden (view full) ---
175{
176 device_t smbdev = IIC_DEVICE(minor(dev));
177 struct smb_softc *sc = IIC_SOFTC(minor(dev));
178 device_t parent = device_get_parent(smbdev);
179
180 int error = 0;
181 struct smbcmd *s = (struct smbcmd *)data;
182
183 if (!sc || !s)
184 return (EINVAL);
185
186 switch (cmd) {
187 case SMB_QUICK_WRITE:
188 smbus_quick(parent, s->slave, SMB_QWRITE);
189 goto end;
190
191 case SMB_QUICK_READ:
192 smbus_quick(parent, s->slave, SMB_QREAD);
193 goto end;
194 };
195
196 switch (cmd) {
197 case SMB_SENDB:
198 smbus_sendb(parent, s->slave, s->cmd);
199 break;
200
201 case SMB_RECVB:
202 smbus_recvb(parent, s->slave, &s->cmd);
203 break;
204
205 case SMB_WRITEB:
206 smbus_writeb(parent, s->slave, s->cmd, s->data.byte);
207 break;
208
209 case SMB_WRITEW:
210 smbus_writew(parent, s->slave, s->cmd, s->data.word);
211 break;
212
213 case SMB_READB:
214 if (s->data.byte_ptr)
215 smbus_readb(parent, s->slave, s->cmd,
216 s->data.byte_ptr);
217 break;
218
219 case SMB_READW:
220 if (s->data.word_ptr)
221 smbus_readw(parent, s->slave, s->cmd, s->data.word_ptr);
222 break;
223
224 case SMB_PCALL:
225 if (s->data.process.rdata)
226 smbus_pcall(parent, s->slave, s->cmd,
227 s->data.process.sdata, s->data.process.rdata);
228 break;
229
230 case SMB_BWRITE:
231 if (s->count && s->data.byte_ptr)
232 smbus_bwrite(parent, s->slave, s->cmd, s->count,
233 s->data.byte_ptr);
234 break;
235
236 case SMB_BREAD:
237 if (s->count && s->data.byte_ptr)
238 smbus_bread(parent, s->slave, s->cmd, s->count,
239 s->data.byte_ptr);
240 break;
241
242 default:
243 error = ENODEV;
244 }
245
246end:
--- 21 unchanged lines hidden ---
2 * Copyright (c) 1998 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 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 * $Id: smb.c,v 1.4 1998/12/07 21:58:17 archie Exp $
27 *
28 */
29#include <sys/param.h>
30#include <sys/kernel.h>
31#include <sys/systm.h>
32#include <sys/module.h>
33#include <sys/bus.h>
34#include <sys/conf.h>
--- 117 unchanged lines hidden (view full) ---
152 sc->sc_count--;
153
154 return (0);
155}
156
157static int
158smbwrite(dev_t dev, struct uio * uio, int ioflag)
159{
160 /* not supported */
161
162 return (EINVAL);
163}
164
165static int
166smbread(dev_t dev, struct uio * uio, int ioflag)
167{
168 /* not supported */
169
170 return (EINVAL);
--- 4 unchanged lines hidden (view full) ---
175{
176 device_t smbdev = IIC_DEVICE(minor(dev));
177 struct smb_softc *sc = IIC_SOFTC(minor(dev));
178 device_t parent = device_get_parent(smbdev);
179
180 int error = 0;
181 struct smbcmd *s = (struct smbcmd *)data;
182
183 if (!sc || !s)
184 return (EINVAL);
185
186 switch (cmd) {
187 case SMB_QUICK_WRITE:
188 smbus_quick(parent, s->slave, SMB_QWRITE);
189 goto end;
190
191 case SMB_QUICK_READ:
192 smbus_quick(parent, s->slave, SMB_QREAD);
193 goto end;
194 };
195
196 switch (cmd) {
197 case SMB_SENDB:
198 smbus_sendb(parent, s->slave, s->cmd);
199 break;
200
201 case SMB_RECVB:
202 smbus_recvb(parent, s->slave, &s->cmd);
203 break;
204
205 case SMB_WRITEB:
206 smbus_writeb(parent, s->slave, s->cmd, s->data.byte);
207 break;
208
209 case SMB_WRITEW:
210 smbus_writew(parent, s->slave, s->cmd, s->data.word);
211 break;
212
213 case SMB_READB:
214 if (s->data.byte_ptr)
215 smbus_readb(parent, s->slave, s->cmd,
216 s->data.byte_ptr);
217 break;
218
219 case SMB_READW:
220 if (s->data.word_ptr)
221 smbus_readw(parent, s->slave, s->cmd, s->data.word_ptr);
222 break;
223
224 case SMB_PCALL:
225 if (s->data.process.rdata)
226 smbus_pcall(parent, s->slave, s->cmd,
227 s->data.process.sdata, s->data.process.rdata);
228 break;
229
230 case SMB_BWRITE:
231 if (s->count && s->data.byte_ptr)
232 smbus_bwrite(parent, s->slave, s->cmd, s->count,
233 s->data.byte_ptr);
234 break;
235
236 case SMB_BREAD:
237 if (s->count && s->data.byte_ptr)
238 smbus_bread(parent, s->slave, s->cmd, s->count,
239 s->data.byte_ptr);
240 break;
241
242 default:
243 error = ENODEV;
244 }
245
246end:
--- 21 unchanged lines hidden ---