Trailing whitespacediff -r1.8.14.1 -r1.8.14.2 src/sys/dev/usb/moscom.c
(skrll)
--- src/sys/dev/usb/Attic/moscom.c 2014/12/06 08:37:30 1.8.14.1
+++ src/sys/dev/usb/Attic/moscom.c 2014/12/23 11:10:41 1.8.14.2
@@ -1,34 +1,34 @@ | @@ -1,34 +1,34 @@ | |||
1 | /* $NetBSD: moscom.c,v 1.8.14.1 2014/12/06 08:37:30 skrll Exp $ */ | 1 | /* $NetBSD: moscom.c,v 1.8.14.2 2014/12/23 11:10:41 skrll Exp $ */ | |
2 | /* $OpenBSD: moscom.c,v 1.11 2007/10/11 18:33:14 deraadt Exp $ */ | 2 | /* $OpenBSD: moscom.c,v 1.11 2007/10/11 18:33:14 deraadt Exp $ */ | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Copyright (c) 2006 Jonathan Gray <jsg@openbsd.org> | 5 | * Copyright (c) 2006 Jonathan Gray <jsg@openbsd.org> | |
6 | * | 6 | * | |
7 | * Permission to use, copy, modify, and distribute this software for any | 7 | * Permission to use, copy, modify, and distribute this software for any | |
8 | * purpose with or without fee is hereby granted, provided that the above | 8 | * purpose with or without fee is hereby granted, provided that the above | |
9 | * copyright notice and this permission notice appear in all copies. | 9 | * copyright notice and this permission notice appear in all copies. | |
10 | * | 10 | * | |
11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | 12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | 13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | 14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | 15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | 16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
18 | */ | 18 | */ | |
19 | 19 | |||
20 | #include <sys/cdefs.h> | 20 | #include <sys/cdefs.h> | |
21 | __KERNEL_RCSID(0, "$NetBSD: moscom.c,v 1.8.14.1 2014/12/06 08:37:30 skrll Exp $"); | 21 | __KERNEL_RCSID(0, "$NetBSD: moscom.c,v 1.8.14.2 2014/12/23 11:10:41 skrll Exp $"); | |
22 | 22 | |||
23 | #include <sys/param.h> | 23 | #include <sys/param.h> | |
24 | #include <sys/systm.h> | 24 | #include <sys/systm.h> | |
25 | #include <sys/kernel.h> | 25 | #include <sys/kernel.h> | |
26 | #include <sys/conf.h> | 26 | #include <sys/conf.h> | |
27 | #include <sys/tty.h> | 27 | #include <sys/tty.h> | |
28 | #include <sys/device.h> | 28 | #include <sys/device.h> | |
29 | 29 | |||
30 | #include <dev/usb/usb.h> | 30 | #include <dev/usb/usb.h> | |
31 | #include <dev/usb/usbdi.h> | 31 | #include <dev/usb/usbdi.h> | |
32 | #include <dev/usb/usbdi_util.h> | 32 | #include <dev/usb/usbdi_util.h> | |
33 | #include <dev/usb/usbdevs.h> | 33 | #include <dev/usb/usbdevs.h> | |
34 | 34 | |||
@@ -57,31 +57,31 @@ __KERNEL_RCSID(0, "$NetBSD: moscom.c,v 1 | @@ -57,31 +57,31 @@ __KERNEL_RCSID(0, "$NetBSD: moscom.c,v 1 | |||
57 | #define MOSCOM_DIV_LO 0x08 | 57 | #define MOSCOM_DIV_LO 0x08 | |
58 | #define MOSCOM_DIV_HI 0x09 | 58 | #define MOSCOM_DIV_HI 0x09 | |
59 | #define MOSCOM_EFR 0x0a | 59 | #define MOSCOM_EFR 0x0a | |
60 | #define MOSCOM_XON1 0x0b | 60 | #define MOSCOM_XON1 0x0b | |
61 | #define MOSCOM_XON2 0x0c | 61 | #define MOSCOM_XON2 0x0c | |
62 | #define MOSCOM_XOFF1 0x0d | 62 | #define MOSCOM_XOFF1 0x0d | |
63 | #define MOSCOM_XOFF2 0x0e | 63 | #define MOSCOM_XOFF2 0x0e | |
64 | 64 | |||
65 | #define MOSCOM_BAUDLO 0x00 | 65 | #define MOSCOM_BAUDLO 0x00 | |
66 | #define MOSCOM_BAUDHI 0x01 | 66 | #define MOSCOM_BAUDHI 0x01 | |
67 | 67 | |||
68 | #define MOSCOM_INT_RXEN 0x01 | 68 | #define MOSCOM_INT_RXEN 0x01 | |
69 | #define MOSCOM_INT_TXEN 0x02 | 69 | #define MOSCOM_INT_TXEN 0x02 | |
70 | #define MOSCOM_INT_RSEN 0x04 | 70 | #define MOSCOM_INT_RSEN 0x04 | |
71 | #define MOSCOM_INT_MDMEM 0x08 | 71 | #define MOSCOM_INT_MDMEM 0x08 | |
72 | #define MOSCOM_INT_SLEEP 0x10 | 72 | #define MOSCOM_INT_SLEEP 0x10 | |
73 | #define MOSCOM_INT_XOFF 0x20 | 73 | #define MOSCOM_INT_XOFF 0x20 | |
74 | #define MOSCOM_INT_RTS 0x40 | 74 | #define MOSCOM_INT_RTS 0x40 | |
75 | 75 | |||
76 | #define MOSCOM_FIFO_EN 0x01 | 76 | #define MOSCOM_FIFO_EN 0x01 | |
77 | #define MOSCOM_FIFO_RXCLR 0x02 | 77 | #define MOSCOM_FIFO_RXCLR 0x02 | |
78 | #define MOSCOM_FIFO_TXCLR 0x04 | 78 | #define MOSCOM_FIFO_TXCLR 0x04 | |
79 | #define MOSCOM_FIFO_DMA_BLK 0x08 | 79 | #define MOSCOM_FIFO_DMA_BLK 0x08 | |
80 | #define MOSCOM_FIFO_TXLVL_MASK 0x30 | 80 | #define MOSCOM_FIFO_TXLVL_MASK 0x30 | |
81 | #define MOSCOM_FIFO_TXLVL_8 0x00 | 81 | #define MOSCOM_FIFO_TXLVL_8 0x00 | |
82 | #define MOSCOM_FIFO_TXLVL_16 0x10 | 82 | #define MOSCOM_FIFO_TXLVL_16 0x10 | |
83 | #define MOSCOM_FIFO_TXLVL_32 0x20 | 83 | #define MOSCOM_FIFO_TXLVL_32 0x20 | |
84 | #define MOSCOM_FIFO_TXLVL_56 0x30 | 84 | #define MOSCOM_FIFO_TXLVL_56 0x30 | |
85 | #define MOSCOM_FIFO_RXLVL_MASK 0xc0 | 85 | #define MOSCOM_FIFO_RXLVL_MASK 0xc0 | |
86 | #define MOSCOM_FIFO_RXLVL_8 0x00 | 86 | #define MOSCOM_FIFO_RXLVL_8 0x00 | |
87 | #define MOSCOM_FIFO_RXLVL_16 0x40 | 87 | #define MOSCOM_FIFO_RXLVL_16 0x40 | |
@@ -143,65 +143,65 @@ struct moscom_softc { | @@ -143,65 +143,65 @@ struct moscom_softc { | |||
143 | device_t sc_subdev; | 143 | device_t sc_subdev; | |
144 | 144 | |||
145 | u_char sc_msr; | 145 | u_char sc_msr; | |
146 | u_char sc_lsr; | 146 | u_char sc_lsr; | |
147 | u_char sc_lcr; | 147 | u_char sc_lcr; | |
148 | 148 | |||
149 | u_char sc_dying; | 149 | u_char sc_dying; | |
150 | }; | 150 | }; | |
151 | 151 | |||
152 | void moscom_get_status(void *, int, u_char *, u_char *); | 152 | void moscom_get_status(void *, int, u_char *, u_char *); | |
153 | void moscom_set(void *, int, int, int); | 153 | void moscom_set(void *, int, int, int); | |
154 | int moscom_param(void *, int, struct termios *); | 154 | int moscom_param(void *, int, struct termios *); | |
155 | int moscom_open(void *, int); | 155 | int moscom_open(void *, int); | |
156 | int moscom_cmd(struct moscom_softc *, int, int); | 156 | int moscom_cmd(struct moscom_softc *, int, int); | |
157 | 157 | |||
158 | struct ucom_methods moscom_methods = { | 158 | struct ucom_methods moscom_methods = { | |
159 | .ucom_get_status = NULL, | 159 | .ucom_get_status = NULL, | |
160 | .ucom_set = moscom_set, | 160 | .ucom_set = moscom_set, | |
161 | .ucom_param = moscom_param, | 161 | .ucom_param = moscom_param, | |
162 | .ucom_ioctl = NULL, | 162 | .ucom_ioctl = NULL, | |
163 | .ucom_open = moscom_open, | 163 | .ucom_open = moscom_open, | |
164 | .ucom_close = NULL, | 164 | .ucom_close = NULL, | |
165 | .ucom_read = NULL, | 165 | .ucom_read = NULL, | |
166 | .ucom_write = NULL, | 166 | .ucom_write = NULL, | |
167 | }; | 167 | }; | |
168 | 168 | |||
169 | static const struct usb_devno moscom_devs[] = { | 169 | static const struct usb_devno moscom_devs[] = { | |
170 | { USB_VENDOR_MOSCHIP, USB_PRODUCT_MOSCHIP_MCS7703 }, | 170 | { USB_VENDOR_MOSCHIP, USB_PRODUCT_MOSCHIP_MCS7703 }, | |
171 | { USB_VENDOR_MOSCHIP, USB_PRODUCT_MOSCHIP_MCS7840 }, | 171 | { USB_VENDOR_MOSCHIP, USB_PRODUCT_MOSCHIP_MCS7840 }, | |
172 | { USB_VENDOR_ATEN, USB_PRODUCT_ATEN_UC2324 } | 172 | { USB_VENDOR_ATEN, USB_PRODUCT_ATEN_UC2324 } | |
173 | }; | 173 | }; | |
174 | #define moscom_lookup(v, p) usb_lookup(moscom_devs, v, p) | 174 | #define moscom_lookup(v, p) usb_lookup(moscom_devs, v, p) | |
175 | 175 | |||
176 | int moscom_match(device_t, cfdata_t, void *); | 176 | int moscom_match(device_t, cfdata_t, void *); | |
177 | void moscom_attach(device_t, device_t, void *); | 177 | void moscom_attach(device_t, device_t, void *); | |
178 | void moscom_childdet(device_t, device_t); | 178 | void moscom_childdet(device_t, device_t); | |
179 | int moscom_detach(device_t, int); | 179 | int moscom_detach(device_t, int); | |
180 | int moscom_activate(device_t, enum devact); | 180 | int moscom_activate(device_t, enum devact); | |
181 | 181 | |||
182 | CFATTACH_DECL2_NEW(moscom, sizeof(struct moscom_softc), moscom_match, | 182 | CFATTACH_DECL2_NEW(moscom, sizeof(struct moscom_softc), moscom_match, | |
183 | moscom_attach, moscom_detach, moscom_activate, NULL, moscom_childdet); | 183 | moscom_attach, moscom_detach, moscom_activate, NULL, moscom_childdet); | |
184 | 184 | |||
185 | int | 185 | int | |
186 | moscom_match(device_t parent, cfdata_t match, void *aux) | 186 | moscom_match(device_t parent, cfdata_t match, void *aux) | |
187 | { | 187 | { | |
188 | struct usb_attach_arg *uaa = aux; | 188 | struct usb_attach_arg *uaa = aux; | |
189 | 189 | |||
190 | return (moscom_lookup(uaa->vendor, uaa->product) != NULL ? | 190 | return (moscom_lookup(uaa->vendor, uaa->product) != NULL ? | |
191 | UMATCH_VENDOR_PRODUCT : UMATCH_NONE); | 191 | UMATCH_VENDOR_PRODUCT : UMATCH_NONE); | |
192 | } | 192 | } | |
193 | 193 | |||
194 | void | 194 | void | |
195 | moscom_attach(device_t parent, device_t self, void *aux) | 195 | moscom_attach(device_t parent, device_t self, void *aux) | |
196 | { | 196 | { | |
197 | struct moscom_softc *sc = device_private(self); | 197 | struct moscom_softc *sc = device_private(self); | |
198 | struct usb_attach_arg *uaa = aux; | 198 | struct usb_attach_arg *uaa = aux; | |
199 | usbd_device_handle dev = uaa->device; | 199 | usbd_device_handle dev = uaa->device; | |
200 | struct ucom_attach_args uca; | 200 | struct ucom_attach_args uca; | |
201 | usb_interface_descriptor_t *id; | 201 | usb_interface_descriptor_t *id; | |
202 | usb_endpoint_descriptor_t *ed; | 202 | usb_endpoint_descriptor_t *ed; | |
203 | char *devinfop; | 203 | char *devinfop; | |
204 | usbd_status error; | 204 | usbd_status error; | |
205 | int i; | 205 | int i; | |
206 | 206 | |||
207 | aprint_naive("\n"); | 207 | aprint_naive("\n"); | |
@@ -259,43 +259,43 @@ moscom_attach(device_t parent, device_t | @@ -259,43 +259,43 @@ moscom_attach(device_t parent, device_t | |||
259 | 259 | |||
260 | uca.ibufsize = MOSCOMBUFSZ; | 260 | uca.ibufsize = MOSCOMBUFSZ; | |
261 | uca.obufsize = MOSCOMBUFSZ; | 261 | uca.obufsize = MOSCOMBUFSZ; | |
262 | uca.ibufsizepad = MOSCOMBUFSZ; | 262 | uca.ibufsizepad = MOSCOMBUFSZ; | |
263 | uca.opkthdrlen = 0; | 263 | uca.opkthdrlen = 0; | |
264 | uca.device = sc->sc_udev; | 264 | uca.device = sc->sc_udev; | |
265 | uca.iface = sc->sc_iface; | 265 | uca.iface = sc->sc_iface; | |
266 | uca.methods = &moscom_methods; | 266 | uca.methods = &moscom_methods; | |
267 | uca.arg = sc; | 267 | uca.arg = sc; | |
268 | uca.info = NULL; | 268 | uca.info = NULL; | |
269 | 269 | |||
270 | usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev, | 270 | usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev, | |
271 | sc->sc_dev); | 271 | sc->sc_dev); | |
272 | 272 | |||
273 | sc->sc_subdev = config_found_sm_loc(self, "ucombus", NULL, &uca, | 273 | sc->sc_subdev = config_found_sm_loc(self, "ucombus", NULL, &uca, | |
274 | ucomprint, ucomsubmatch); | 274 | ucomprint, ucomsubmatch); | |
275 | 275 | |||
276 | return; | 276 | return; | |
277 | } | 277 | } | |
278 | 278 | |||
279 | void | 279 | void | |
280 | moscom_childdet(device_t self, device_t child) | 280 | moscom_childdet(device_t self, device_t child) | |
281 | { | 281 | { | |
282 | struct moscom_softc *sc = device_private(self); | 282 | struct moscom_softc *sc = device_private(self); | |
283 | 283 | |||
284 | KASSERT(sc->sc_subdev == child); | 284 | KASSERT(sc->sc_subdev == child); | |
285 | sc->sc_subdev = NULL; | 285 | sc->sc_subdev = NULL; | |
286 | } | 286 | } | |
287 | 287 | |||
288 | int | 288 | int | |
289 | moscom_detach(device_t self, int flags) | 289 | moscom_detach(device_t self, int flags) | |
290 | { | 290 | { | |
291 | struct moscom_softc *sc = device_private(self); | 291 | struct moscom_softc *sc = device_private(self); | |
292 | int rv = 0; | 292 | int rv = 0; | |
293 | 293 | |||
294 | sc->sc_dying = 1; | 294 | sc->sc_dying = 1; | |
295 | if (sc->sc_subdev != NULL) | 295 | if (sc->sc_subdev != NULL) | |
296 | rv = config_detach(sc->sc_subdev, flags); | 296 | rv = config_detach(sc->sc_subdev, flags); | |
297 | 297 | |||
298 | usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, | 298 | usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, | |
299 | sc->sc_dev); | 299 | sc->sc_dev); | |
300 | 300 | |||
301 | return (rv); | 301 | return (rv); | |
@@ -317,30 +317,30 @@ moscom_activate(device_t self, enum deva | @@ -317,30 +317,30 @@ moscom_activate(device_t self, enum deva | |||
317 | 317 | |||
318 | int | 318 | int | |
319 | moscom_open(void *vsc, int portno) | 319 | moscom_open(void *vsc, int portno) | |
320 | { | 320 | { | |
321 | struct moscom_softc *sc = vsc; | 321 | struct moscom_softc *sc = vsc; | |
322 | usb_device_request_t req; | 322 | usb_device_request_t req; | |
323 | 323 | |||
324 | if (sc->sc_dying) | 324 | if (sc->sc_dying) | |
325 | return (EIO); | 325 | return (EIO); | |
326 | 326 | |||
327 | /* Purge FIFOs or odd things happen */ | 327 | /* Purge FIFOs or odd things happen */ | |
328 | if (moscom_cmd(sc, MOSCOM_FIFO, 0x00) != 0) | 328 | if (moscom_cmd(sc, MOSCOM_FIFO, 0x00) != 0) | |
329 | return (EIO); | 329 | return (EIO); | |
330 | 330 | |||
331 | if (moscom_cmd(sc, MOSCOM_FIFO, MOSCOM_FIFO_EN | | 331 | if (moscom_cmd(sc, MOSCOM_FIFO, MOSCOM_FIFO_EN | | |
332 | MOSCOM_FIFO_RXCLR | MOSCOM_FIFO_TXCLR | | 332 | MOSCOM_FIFO_RXCLR | MOSCOM_FIFO_TXCLR | | |
333 | MOSCOM_FIFO_DMA_BLK | MOSCOM_FIFO_RXLVL_MASK) != 0) | 333 | MOSCOM_FIFO_DMA_BLK | MOSCOM_FIFO_RXLVL_MASK) != 0) | |
334 | return (EIO); | 334 | return (EIO); | |
335 | 335 | |||
336 | /* Magic tell device we're ready for data command */ | 336 | /* Magic tell device we're ready for data command */ | |
337 | req.bmRequestType = UT_WRITE_VENDOR_DEVICE; | 337 | req.bmRequestType = UT_WRITE_VENDOR_DEVICE; | |
338 | req.bRequest = MOSCOM_WRITE; | 338 | req.bRequest = MOSCOM_WRITE; | |
339 | USETW(req.wValue, 0x08); | 339 | USETW(req.wValue, 0x08); | |
340 | USETW(req.wIndex, MOSCOM_INT); | 340 | USETW(req.wIndex, MOSCOM_INT); | |
341 | USETW(req.wLength, 0); | 341 | USETW(req.wLength, 0); | |
342 | if (usbd_do_request(sc->sc_udev, &req, NULL) != 0) | 342 | if (usbd_do_request(sc->sc_udev, &req, NULL) != 0) | |
343 | return (EIO); | 343 | return (EIO); | |
344 | 344 | |||
345 | return (0); | 345 | return (0); | |
346 | } | 346 | } | |
@@ -426,37 +426,37 @@ moscom_param(void *vsc, int portno, stru | @@ -426,37 +426,37 @@ moscom_param(void *vsc, int portno, stru | |||
426 | /* xon/xoff flow ctl */ | 426 | /* xon/xoff flow ctl */ | |
427 | } else { | 427 | } else { | |
428 | /* disable flow ctl */ | 428 | /* disable flow ctl */ | |
429 | } | 429 | } | |
430 | #endif | 430 | #endif | |
431 | 431 | |||
432 | return (0); | 432 | return (0); | |
433 | } | 433 | } | |
434 | 434 | |||
435 | void | 435 | void | |
436 | moscom_get_status(void *vsc, int portno, u_char *lsr, u_char *msr) | 436 | moscom_get_status(void *vsc, int portno, u_char *lsr, u_char *msr) | |
437 | { | 437 | { | |
438 | struct moscom_softc *sc = vsc; | 438 | struct moscom_softc *sc = vsc; | |
439 | 439 | |||
440 | if (msr != NULL) | 440 | if (msr != NULL) | |
441 | *msr = sc->sc_msr; | 441 | *msr = sc->sc_msr; | |
442 | if (lsr != NULL) | 442 | if (lsr != NULL) | |
443 | *lsr = sc->sc_lsr; | 443 | *lsr = sc->sc_lsr; | |
444 | } | 444 | } | |
445 | 445 | |||
446 | int | 446 | int | |
447 | moscom_cmd(struct moscom_softc *sc, int reg, int val) | 447 | moscom_cmd(struct moscom_softc *sc, int reg, int val) | |
448 | { | 448 | { | |
449 | usb_device_request_t req; | 449 | usb_device_request_t req; | |
450 | usbd_status err; | 450 | usbd_status err; | |
451 | 451 | |||
452 | req.bmRequestType = UT_WRITE_VENDOR_DEVICE; | 452 | req.bmRequestType = UT_WRITE_VENDOR_DEVICE; | |
453 | req.bRequest = MOSCOM_WRITE; | 453 | req.bRequest = MOSCOM_WRITE; | |
454 | USETW(req.wValue, val + MOSCOM_UART_REG); | 454 | USETW(req.wValue, val + MOSCOM_UART_REG); | |
455 | USETW(req.wIndex, reg); | 455 | USETW(req.wIndex, reg); | |
456 | USETW(req.wLength, 0); | 456 | USETW(req.wLength, 0); | |
457 | err = usbd_do_request(sc->sc_udev, &req, NULL); | 457 | err = usbd_do_request(sc->sc_udev, &req, NULL); | |
458 | if (err) | 458 | if (err) | |
459 | return (EIO); | 459 | return (EIO); | |
460 | else | 460 | else | |
461 | return (0); | 461 | return (0); | |
462 | } | 462 | } |
--- src/sys/dev/usb/umodem.c 2014/12/06 08:37:30 1.66.4.1
+++ src/sys/dev/usb/umodem.c 2014/12/23 11:10:41 1.66.4.2
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: umodem.c,v 1.66.4.1 2014/12/06 08:37:30 skrll Exp $ */ | 1 | /* $NetBSD: umodem.c,v 1.66.4.2 2014/12/23 11:10:41 skrll Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1998 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Lennart Augustsson (lennart@augustsson.net) at | 8 | * by Lennart Augustsson (lennart@augustsson.net) at | |
9 | * Carlstedt Research & Technology. | 9 | * Carlstedt Research & Technology. | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | 13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -34,27 +34,27 @@ | @@ -34,27 +34,27 @@ | |||
34 | * Comm Class spec: http://www.usb.org/developers/devclass_docs/usbccs10.pdf | 34 | * Comm Class spec: http://www.usb.org/developers/devclass_docs/usbccs10.pdf | |
35 | * http://www.usb.org/developers/devclass_docs/usbcdc11.pdf | 35 | * http://www.usb.org/developers/devclass_docs/usbcdc11.pdf | |
36 | */ | 36 | */ | |
37 | 37 | |||
38 | /* | 38 | /* | |
39 | * TODO: | 39 | * TODO: | |
40 | * - Add error recovery in various places; the big problem is what | 40 | * - Add error recovery in various places; the big problem is what | |
41 | * to do in a callback if there is an error. | 41 | * to do in a callback if there is an error. | |
42 | * - Implement a Call Device for modems without multiplexed commands. | 42 | * - Implement a Call Device for modems without multiplexed commands. | |
43 | * | 43 | * | |
44 | */ | 44 | */ | |
45 | 45 | |||
46 | #include <sys/cdefs.h> | 46 | #include <sys/cdefs.h> | |
47 | __KERNEL_RCSID(0, "$NetBSD: umodem.c,v 1.66.4.1 2014/12/06 08:37:30 skrll Exp $"); | 47 | __KERNEL_RCSID(0, "$NetBSD: umodem.c,v 1.66.4.2 2014/12/23 11:10:41 skrll Exp $"); | |
48 | 48 | |||
49 | #include <sys/param.h> | 49 | #include <sys/param.h> | |
50 | #include <sys/systm.h> | 50 | #include <sys/systm.h> | |
51 | #include <sys/kernel.h> | 51 | #include <sys/kernel.h> | |
52 | #include <sys/ioctl.h> | 52 | #include <sys/ioctl.h> | |
53 | #include <sys/conf.h> | 53 | #include <sys/conf.h> | |
54 | #include <sys/tty.h> | 54 | #include <sys/tty.h> | |
55 | #include <sys/file.h> | 55 | #include <sys/file.h> | |
56 | #include <sys/select.h> | 56 | #include <sys/select.h> | |
57 | #include <sys/proc.h> | 57 | #include <sys/proc.h> | |
58 | #include <sys/vnode.h> | 58 | #include <sys/vnode.h> | |
59 | #include <sys/device.h> | 59 | #include <sys/device.h> | |
60 | #include <sys/poll.h> | 60 | #include <sys/poll.h> | |
@@ -81,73 +81,73 @@ Static struct ucom_methods umodem_method | @@ -81,73 +81,73 @@ Static struct ucom_methods umodem_method | |||
81 | .ucom_write = NULL, | 81 | .ucom_write = NULL, | |
82 | }; | 82 | }; | |
83 | 83 | |||
84 | int umodem_match(device_t, cfdata_t, void *); | 84 | int umodem_match(device_t, cfdata_t, void *); | |
85 | void umodem_attach(device_t, device_t, void *); | 85 | void umodem_attach(device_t, device_t, void *); | |
86 | int umodem_detach(device_t, int); | 86 | int umodem_detach(device_t, int); | |
87 | int umodem_activate(device_t, enum devact); | 87 | int umodem_activate(device_t, enum devact); | |
88 | 88 | |||
89 | extern struct cfdriver umodem_cd; | 89 | extern struct cfdriver umodem_cd; | |
90 | 90 | |||
91 | CFATTACH_DECL_NEW(umodem, sizeof(struct umodem_softc), umodem_match, | 91 | CFATTACH_DECL_NEW(umodem, sizeof(struct umodem_softc), umodem_match, | |
92 | umodem_attach, umodem_detach, umodem_activate); | 92 | umodem_attach, umodem_detach, umodem_activate); | |
93 | 93 | |||
94 | int | 94 | int | |
95 | umodem_match(device_t parent, cfdata_t match, void *aux) | 95 | umodem_match(device_t parent, cfdata_t match, void *aux) | |
96 | { | 96 | { | |
97 | struct usbif_attach_arg *uaa = aux; | 97 | struct usbif_attach_arg *uaa = aux; | |
98 | usb_interface_descriptor_t *id; | 98 | usb_interface_descriptor_t *id; | |
99 | int cm, acm; | 99 | int cm, acm; | |
100 | 100 | |||
101 | id = usbd_get_interface_descriptor(uaa->iface); | 101 | id = usbd_get_interface_descriptor(uaa->iface); | |
102 | if (uaa->subclass != UISUBCLASS_ABSTRACT_CONTROL_MODEL && | 102 | if (uaa->subclass != UISUBCLASS_ABSTRACT_CONTROL_MODEL && | |
103 | (id->bInterfaceClass == UICLASS_CDC_DATA && | 103 | (id->bInterfaceClass == UICLASS_CDC_DATA && | |
104 | id->bInterfaceSubClass == UISUBCLASS_DATA)) | 104 | id->bInterfaceSubClass == UISUBCLASS_DATA)) | |
105 | return (UMATCH_IFACECLASS_IFACESUBCLASS); | 105 | return (UMATCH_IFACECLASS_IFACESUBCLASS); | |
106 | 106 | |||
107 | if (uaa->class != UICLASS_CDC || | 107 | if (uaa->class != UICLASS_CDC || | |
108 | uaa->subclass != UISUBCLASS_ABSTRACT_CONTROL_MODEL || | 108 | uaa->subclass != UISUBCLASS_ABSTRACT_CONTROL_MODEL || | |
109 | !(uaa->proto == UIPROTO_CDC_NOCLASS || uaa->proto == UIPROTO_CDC_AT)) | 109 | !(uaa->proto == UIPROTO_CDC_NOCLASS || uaa->proto == UIPROTO_CDC_AT)) | |
110 | return (UMATCH_NONE); | 110 | return (UMATCH_NONE); | |
111 | 111 | |||
112 | if (umodem_get_caps(uaa->device, &cm, &acm, id) == -1) | 112 | if (umodem_get_caps(uaa->device, &cm, &acm, id) == -1) | |
113 | return (UMATCH_NONE); | 113 | return (UMATCH_NONE); | |
114 | 114 | |||
115 | return (UMATCH_IFACECLASS_IFACESUBCLASS_IFACEPROTO); | 115 | return (UMATCH_IFACECLASS_IFACESUBCLASS_IFACEPROTO); | |
116 | } | 116 | } | |
117 | 117 | |||
118 | void | 118 | void | |
119 | umodem_attach(device_t parent, device_t self, void *aux) | 119 | umodem_attach(device_t parent, device_t self, void *aux) | |
120 | { | 120 | { | |
121 | struct umodem_softc *sc = device_private(self); | 121 | struct umodem_softc *sc = device_private(self); | |
122 | struct usbif_attach_arg *uaa = aux; | 122 | struct usbif_attach_arg *uaa = aux; | |
123 | struct ucom_attach_args uca; | 123 | struct ucom_attach_args uca; | |
124 | 124 | |||
125 | uca.portno = UCOM_UNK_PORTNO; | 125 | uca.portno = UCOM_UNK_PORTNO; | |
126 | uca.methods = &umodem_methods; | 126 | uca.methods = &umodem_methods; | |
127 | uca.info = NULL; | 127 | uca.info = NULL; | |
128 | 128 | |||
129 | if (!pmf_device_register(self, NULL, NULL)) | 129 | if (!pmf_device_register(self, NULL, NULL)) | |
130 | aprint_error_dev(self, "couldn't establish power handler"); | 130 | aprint_error_dev(self, "couldn't establish power handler"); | |
131 | 131 | |||
132 | if (umodem_common_attach(self, sc, uaa, &uca)) | 132 | if (umodem_common_attach(self, sc, uaa, &uca)) | |
133 | return; | 133 | return; | |
134 | return; | 134 | return; | |
135 | } | 135 | } | |
136 | 136 | |||
137 | int | 137 | int | |
138 | umodem_activate(device_t self, enum devact act) | 138 | umodem_activate(device_t self, enum devact act) | |
139 | { | 139 | { | |
140 | struct umodem_softc *sc = device_private(self); | 140 | struct umodem_softc *sc = device_private(self); | |
141 | 141 | |||
142 | return umodem_common_activate(sc, act); | 142 | return umodem_common_activate(sc, act); | |
143 | } | 143 | } | |
144 | 144 | |||
145 | int | 145 | int | |
146 | umodem_detach(device_t self, int flags) | 146 | umodem_detach(device_t self, int flags) | |
147 | { | 147 | { | |
148 | struct umodem_softc *sc = device_private(self); | 148 | struct umodem_softc *sc = device_private(self); | |
149 | 149 | |||
150 | pmf_device_deregister(self); | 150 | pmf_device_deregister(self); | |
151 | 151 | |||
152 | return umodem_common_detach(sc, flags); | 152 | return umodem_common_detach(sc, flags); | |
153 | } | 153 | } |
--- src/sys/dev/usb/uvscom.c 2014/12/06 08:37:30 1.28.16.2
+++ src/sys/dev/usb/uvscom.c 2014/12/23 11:10:41 1.28.16.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: uvscom.c,v 1.28.16.2 2014/12/06 08:37:30 skrll Exp $ */ | 1 | /* $NetBSD: uvscom.c,v 1.28.16.3 2014/12/23 11:10:41 skrll Exp $ */ | |
2 | /*- | 2 | /*- | |
3 | * Copyright (c) 2001-2002, Shunsuke Akiyama <akiyama@jp.FreeBSD.org>. | 3 | * Copyright (c) 2001-2002, Shunsuke Akiyama <akiyama@jp.FreeBSD.org>. | |
4 | * All rights reserved. | 4 | * All rights reserved. | |
5 | * | 5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions | |
8 | * are met: | 8 | * are met: | |
9 | * 1. Redistributions of source code must retain the above copyright | 9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. | |
11 | * 2. Redistributions in binary form must reproduce the above copyright | 11 | * 2. Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. | |
14 | * | 14 | * | |
@@ -25,27 +25,27 @@ | @@ -25,27 +25,27 @@ | |||
25 | * SUCH DAMAGE. | 25 | * SUCH DAMAGE. | |
26 | * | 26 | * | |
27 | * $FreeBSD: src/sys/dev/usb/uvscom.c,v 1.1 2002/03/18 18:23:39 joe Exp $ | 27 | * $FreeBSD: src/sys/dev/usb/uvscom.c,v 1.1 2002/03/18 18:23:39 joe Exp $ | |
28 | */ | 28 | */ | |
29 | 29 | |||
30 | /* | 30 | /* | |
31 | * uvscom: SUNTAC Slipper U VS-10U driver. | 31 | * uvscom: SUNTAC Slipper U VS-10U driver. | |
32 | * Slipper U is a PC card to USB converter for data communication card | 32 | * Slipper U is a PC card to USB converter for data communication card | |
33 | * adapter. It supports DDI Pocket's Air H" C@rd, C@rd H" 64, NTT's P-in, | 33 | * adapter. It supports DDI Pocket's Air H" C@rd, C@rd H" 64, NTT's P-in, | |
34 | * P-in m@ater and various data communication card adapters. | 34 | * P-in m@ater and various data communication card adapters. | |
35 | */ | 35 | */ | |
36 | 36 | |||
37 | #include <sys/cdefs.h> | 37 | #include <sys/cdefs.h> | |
38 | __KERNEL_RCSID(0, "$NetBSD: uvscom.c,v 1.28.16.2 2014/12/06 08:37:30 skrll Exp $"); | 38 | __KERNEL_RCSID(0, "$NetBSD: uvscom.c,v 1.28.16.3 2014/12/23 11:10:41 skrll Exp $"); | |
39 | 39 | |||
40 | #include <sys/param.h> | 40 | #include <sys/param.h> | |
41 | #include <sys/systm.h> | 41 | #include <sys/systm.h> | |
42 | #include <sys/kernel.h> | 42 | #include <sys/kernel.h> | |
43 | #include <sys/kmem.h> | 43 | #include <sys/kmem.h> | |
44 | #include <sys/fcntl.h> | 44 | #include <sys/fcntl.h> | |
45 | #include <sys/conf.h> | 45 | #include <sys/conf.h> | |
46 | #include <sys/tty.h> | 46 | #include <sys/tty.h> | |
47 | #include <sys/file.h> | 47 | #include <sys/file.h> | |
48 | #include <sys/ioctl.h> | 48 | #include <sys/ioctl.h> | |
49 | #include <sys/device.h> | 49 | #include <sys/device.h> | |
50 | #include <sys/proc.h> | 50 | #include <sys/proc.h> | |
51 | #include <sys/poll.h> | 51 | #include <sys/poll.h> | |
@@ -208,36 +208,36 @@ static const struct usb_devno uvscom_dev | @@ -208,36 +208,36 @@ static const struct usb_devno uvscom_dev | |||
208 | { USB_VENDOR_SUNTAC, USB_PRODUCT_SUNTAC_IS96U }, | 208 | { USB_VENDOR_SUNTAC, USB_PRODUCT_SUNTAC_IS96U }, | |
209 | }; | 209 | }; | |
210 | #define uvscom_lookup(v, p) usb_lookup(uvscom_devs, v, p) | 210 | #define uvscom_lookup(v, p) usb_lookup(uvscom_devs, v, p) | |
211 | 211 | |||
212 | int uvscom_match(device_t, cfdata_t, void *); | 212 | int uvscom_match(device_t, cfdata_t, void *); | |
213 | void uvscom_attach(device_t, device_t, void *); | 213 | void uvscom_attach(device_t, device_t, void *); | |
214 | void uvscom_childdet(device_t, device_t); | 214 | void uvscom_childdet(device_t, device_t); | |
215 | int uvscom_detach(device_t, int); | 215 | int uvscom_detach(device_t, int); | |
216 | int uvscom_activate(device_t, enum devact); | 216 | int uvscom_activate(device_t, enum devact); | |
217 | extern struct cfdriver uvscom_cd; | 217 | extern struct cfdriver uvscom_cd; | |
218 | CFATTACH_DECL2_NEW(uvscom, sizeof(struct uvscom_softc), uvscom_match, | 218 | CFATTACH_DECL2_NEW(uvscom, sizeof(struct uvscom_softc), uvscom_match, | |
219 | uvscom_attach, uvscom_detach, uvscom_activate, NULL, uvscom_childdet); | 219 | uvscom_attach, uvscom_detach, uvscom_activate, NULL, uvscom_childdet); | |
220 | 220 | |||
221 | int | 221 | int | |
222 | uvscom_match(device_t parent, cfdata_t match, void *aux) | 222 | uvscom_match(device_t parent, cfdata_t match, void *aux) | |
223 | { | 223 | { | |
224 | struct usb_attach_arg *uaa = aux; | 224 | struct usb_attach_arg *uaa = aux; | |
225 | 225 | |||
226 | return (uvscom_lookup(uaa->vendor, uaa->product) != NULL ? | 226 | return (uvscom_lookup(uaa->vendor, uaa->product) != NULL ? | |
227 | UMATCH_VENDOR_PRODUCT : UMATCH_NONE); | 227 | UMATCH_VENDOR_PRODUCT : UMATCH_NONE); | |
228 | } | 228 | } | |
229 | 229 | |||
230 | void | 230 | void | |
231 | uvscom_attach(device_t parent, device_t self, void *aux) | 231 | uvscom_attach(device_t parent, device_t self, void *aux) | |
232 | { | 232 | { | |
233 | struct uvscom_softc *sc = device_private(self); | 233 | struct uvscom_softc *sc = device_private(self); | |
234 | struct usb_attach_arg *uaa = aux; | 234 | struct usb_attach_arg *uaa = aux; | |
235 | usbd_device_handle dev = uaa->device; | 235 | usbd_device_handle dev = uaa->device; | |
236 | usb_config_descriptor_t *cdesc; | 236 | usb_config_descriptor_t *cdesc; | |
237 | usb_interface_descriptor_t *id; | 237 | usb_interface_descriptor_t *id; | |
238 | usb_endpoint_descriptor_t *ed; | 238 | usb_endpoint_descriptor_t *ed; | |
239 | char *devinfop; | 239 | char *devinfop; | |
240 | usbd_status err; | 240 | usbd_status err; | |
241 | int i; | 241 | int i; | |
242 | struct ucom_attach_args uca; | 242 | struct ucom_attach_args uca; | |
243 | 243 | |||
@@ -365,27 +365,27 @@ uvscom_attach(device_t parent, device_t | @@ -365,27 +365,27 @@ uvscom_attach(device_t parent, device_t | |||
365 | 365 | |||
366 | return; | 366 | return; | |
367 | } | 367 | } | |
368 | 368 | |||
369 | void | 369 | void | |
370 | uvscom_childdet(device_t self, device_t child) | 370 | uvscom_childdet(device_t self, device_t child) | |
371 | { | 371 | { | |
372 | struct uvscom_softc *sc = device_private(self); | 372 | struct uvscom_softc *sc = device_private(self); | |
373 | 373 | |||
374 | KASSERT(sc->sc_subdev == child); | 374 | KASSERT(sc->sc_subdev == child); | |
375 | sc->sc_subdev = NULL; | 375 | sc->sc_subdev = NULL; | |
376 | } | 376 | } | |
377 | 377 | |||
378 | int | 378 | int | |
379 | uvscom_detach(device_t self, int flags) | 379 | uvscom_detach(device_t self, int flags) | |
380 | { | 380 | { | |
381 | struct uvscom_softc *sc = device_private(self); | 381 | struct uvscom_softc *sc = device_private(self); | |
382 | int rv = 0; | 382 | int rv = 0; | |
383 | 383 | |||
384 | DPRINTF(("uvscom_detach: sc = %p\n", sc)); | 384 | DPRINTF(("uvscom_detach: sc = %p\n", sc)); | |
385 | 385 | |||
386 | sc->sc_dying = 1; | 386 | sc->sc_dying = 1; | |
387 | 387 | |||
388 | if (sc->sc_intr_pipe != NULL) { | 388 | if (sc->sc_intr_pipe != NULL) { | |
389 | usbd_abort_pipe(sc->sc_intr_pipe); | 389 | usbd_abort_pipe(sc->sc_intr_pipe); | |
390 | usbd_close_pipe(sc->sc_intr_pipe); | 390 | usbd_close_pipe(sc->sc_intr_pipe); | |
391 | kmem_free(sc->sc_intr_buf, sc->sc_isize); | 391 | kmem_free(sc->sc_intr_buf, sc->sc_isize); |