usb_serial.c (230209) | usb_serial.c (233774) |
---|---|
1/* $NetBSD: ucom.c,v 1.40 2001/11/13 06:24:54 lukem Exp $ */ 2 3/*- 4 * Copyright (c) 2001-2003, 2005, 2008 5 * Shunsuke Akiyama <akiyama@jp.FreeBSD.org>. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> | 1/* $NetBSD: ucom.c,v 1.40 2001/11/13 06:24:54 lukem Exp $ */ 2 3/*- 4 * Copyright (c) 2001-2003, 2005, 2008 5 * Shunsuke Akiyama <akiyama@jp.FreeBSD.org>. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> |
31__FBSDID("$FreeBSD: head/sys/dev/usb/serial/usb_serial.c 230209 2012-01-16 10:42:43Z hselasky $"); | 31__FBSDID("$FreeBSD: head/sys/dev/usb/serial/usb_serial.c 233774 2012-04-02 10:50:42Z hselasky $"); |
32 33/*- 34 * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. 35 * All rights reserved. 36 * 37 * This code is derived from software contributed to The NetBSD Foundation 38 * by Lennart Augustsson (lennart@augustsson.net) at 39 * Carlstedt Research & Technology. --- 191 unchanged lines hidden (view full) --- 231 * Setup a group of one or more serial ports. 232 * 233 * The mutex pointed to by "mtx" is applied before all 234 * callbacks are called back. Also "mtx" must be applied 235 * before calling into the ucom-layer! 236 */ 237int 238ucom_attach(struct ucom_super_softc *ssc, struct ucom_softc *sc, | 32 33/*- 34 * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. 35 * All rights reserved. 36 * 37 * This code is derived from software contributed to The NetBSD Foundation 38 * by Lennart Augustsson (lennart@augustsson.net) at 39 * Carlstedt Research & Technology. --- 191 unchanged lines hidden (view full) --- 231 * Setup a group of one or more serial ports. 232 * 233 * The mutex pointed to by "mtx" is applied before all 234 * callbacks are called back. Also "mtx" must be applied 235 * before calling into the ucom-layer! 236 */ 237int 238ucom_attach(struct ucom_super_softc *ssc, struct ucom_softc *sc, |
239 uint32_t subunits, void *parent, | 239 int subunits, void *parent, |
240 const struct ucom_callback *callback, struct mtx *mtx) 241{ | 240 const struct ucom_callback *callback, struct mtx *mtx) 241{ |
242 uint32_t subunit; | 242 int subunit; |
243 int error = 0; 244 245 if ((sc == NULL) || | 243 int error = 0; 244 245 if ((sc == NULL) || |
246 (subunits == 0) || | 246 (subunits <= 0) || |
247 (callback == NULL)) { 248 return (EINVAL); 249 } 250 251 /* allocate a uniq unit number */ 252 ssc->sc_unit = ucom_unit_alloc(); 253 if (ssc->sc_unit == -1) 254 return (ENOMEM); --- 33 unchanged lines hidden (view full) --- 288 289/* 290 * NOTE: the following function will do nothing if 291 * the structure pointed to by "ssc" and "sc" is zero. 292 */ 293void 294ucom_detach(struct ucom_super_softc *ssc, struct ucom_softc *sc) 295{ | 247 (callback == NULL)) { 248 return (EINVAL); 249 } 250 251 /* allocate a uniq unit number */ 252 ssc->sc_unit = ucom_unit_alloc(); 253 if (ssc->sc_unit == -1) 254 return (ENOMEM); --- 33 unchanged lines hidden (view full) --- 288 289/* 290 * NOTE: the following function will do nothing if 291 * the structure pointed to by "ssc" and "sc" is zero. 292 */ 293void 294ucom_detach(struct ucom_super_softc *ssc, struct ucom_softc *sc) 295{ |
296 uint32_t subunit; | 296 int subunit; |
297 298 if (ssc->sc_subunits == 0) 299 return; /* not initialized */ 300 301 if (ssc->sc_sysctl_ttyname != NULL) { 302 sysctl_remove_oid(ssc->sc_sysctl_ttyname, 1, 0); 303 ssc->sc_sysctl_ttyname = NULL; 304 } --- 779 unchanged lines hidden (view full) --- 1084 if (error) { 1085 goto done; 1086 } 1087 opened = 1; 1088 } 1089 DPRINTF("sc = %p\n", sc); 1090 1091 /* Check requested parameters. */ | 297 298 if (ssc->sc_subunits == 0) 299 return; /* not initialized */ 300 301 if (ssc->sc_sysctl_ttyname != NULL) { 302 sysctl_remove_oid(ssc->sc_sysctl_ttyname, 1, 0); 303 ssc->sc_sysctl_ttyname = NULL; 304 } --- 779 unchanged lines hidden (view full) --- 1084 if (error) { 1085 goto done; 1086 } 1087 opened = 1; 1088 } 1089 DPRINTF("sc = %p\n", sc); 1090 1091 /* Check requested parameters. */ |
1092 if (t->c_ospeed < 0) { 1093 DPRINTF("negative ospeed\n"); 1094 error = EINVAL; 1095 goto done; 1096 } | |
1097 if (t->c_ispeed && (t->c_ispeed != t->c_ospeed)) { 1098 DPRINTF("mismatch ispeed and ospeed\n"); 1099 error = EINVAL; 1100 goto done; 1101 } 1102 t->c_ispeed = t->c_ospeed; 1103 1104 if (sc->sc_callback->ucom_pre_param) { --- 385 unchanged lines hidden --- | 1092 if (t->c_ispeed && (t->c_ispeed != t->c_ospeed)) { 1093 DPRINTF("mismatch ispeed and ospeed\n"); 1094 error = EINVAL; 1095 goto done; 1096 } 1097 t->c_ispeed = t->c_ospeed; 1098 1099 if (sc->sc_callback->ucom_pre_param) { --- 385 unchanged lines hidden --- |