sio.c (114293) | sio.c (114334) |
---|---|
1/*- 2 * Copyright (c) 1991 The Regents of the University of California. 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 --- 16 unchanged lines hidden (view full) --- 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * | 1/*- 2 * Copyright (c) 1991 The Regents of the University of California. 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 --- 16 unchanged lines hidden (view full) --- 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * |
33 * $FreeBSD: head/sys/dev/sio/sio.c 114293 2003-04-30 12:57:40Z markm $ | 33 * $FreeBSD: head/sys/dev/sio/sio.c 114334 2003-04-30 21:39:28Z peter $ |
34 * from: @(#)com.c 7.5 (Berkeley) 5/16/91 35 * from: i386/isa sio.c,v 1.234 36 */ 37 38#include "opt_comconsole.h" 39#include "opt_compat.h" 40#include "opt_ddb.h" 41#include "opt_sio.h" --- 1495 unchanged lines hidden (view full) --- 1537siodivisor(rclk, speed) 1538 u_long rclk; 1539 speed_t speed; 1540{ 1541 long actual_speed; 1542 u_int divisor; 1543 int error; 1544 | 34 * from: @(#)com.c 7.5 (Berkeley) 5/16/91 35 * from: i386/isa sio.c,v 1.234 36 */ 37 38#include "opt_comconsole.h" 39#include "opt_compat.h" 40#include "opt_ddb.h" 41#include "opt_sio.h" --- 1495 unchanged lines hidden (view full) --- 1537siodivisor(rclk, speed) 1538 u_long rclk; 1539 speed_t speed; 1540{ 1541 long actual_speed; 1542 u_int divisor; 1543 int error; 1544 |
1545 if (speed == 0 || speed > (ULONG_MAX - 1) / 8) | 1545 if (speed == 0) |
1546 return (0); | 1546 return (0); |
1547#if UINT_MAX > (ULONG_MAX - 1) / 8 1548 if (speed > (ULONG_MAX - 1) / 8) 1549 return (0); 1550#endif |
|
1547 divisor = (rclk / (8UL * speed) + 1) / 2; 1548 if (divisor == 0 || divisor >= 65536) 1549 return (0); 1550 actual_speed = rclk / (16UL * divisor); 1551 1552 /* 10 times error in percent: */ 1553 error = ((actual_speed - (long)speed) * 2000 / (long)speed + 1) / 2; 1554 --- 1750 unchanged lines hidden --- | 1551 divisor = (rclk / (8UL * speed) + 1) / 2; 1552 if (divisor == 0 || divisor >= 65536) 1553 return (0); 1554 actual_speed = rclk / (16UL * divisor); 1555 1556 /* 10 times error in percent: */ 1557 error = ((actual_speed - (long)speed) * 2000 / (long)speed + 1) / 2; 1558 --- 1750 unchanged lines hidden --- |