summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1998-07-29 18:48:20 +0000
committerbde <bde@FreeBSD.org>1998-07-29 18:48:20 +0000
commit616a3e30947322b50b8c80c7c28ecaf4682a98a6 (patch)
treebfef5d00cbf875f26aea3550e5f7a73d63b6a0d5
parent1d772123c10bb8b25fbd288ee977968f04596548 (diff)
downloadFreeBSD-src-616a3e30947322b50b8c80c7c28ecaf4682a98a6.zip
FreeBSD-src-616a3e30947322b50b8c80c7c28ecaf4682a98a6.tar.gz
Fixed sign extension bugs awoken by changing speed_t to an unsigned
type. 19200, 1200 and other relatively uninteresting speeds were broken. Submitted by: Rob Mallory <rmallory@qualcomm.com>
-rw-r--r--sys/dev/cy/cy.c6
-rw-r--r--sys/dev/cy/cy_isa.c6
-rw-r--r--sys/i386/isa/cy.c6
3 files changed, 12 insertions, 6 deletions
diff --git a/sys/dev/cy/cy.c b/sys/dev/cy/cy.c
index 7ddfbc0..38bac42 100644
--- a/sys/dev/cy/cy.c
+++ b/sys/dev/cy/cy.c
@@ -27,7 +27,7 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: cy.c,v 1.63 1998/06/07 17:10:16 dfr Exp $
+ * $Id: cy.c,v 1.64 1998/07/15 12:18:12 bde Exp $
*/
#include "opt_compat.h"
@@ -2482,7 +2482,9 @@ comspeed(speed, prescaler_io)
if (divider > 255)
divider = 255;
actual = CY_CLOCK/prescaler/divider;
- error = ((actual - speed) * 2000 / speed + 1) / 2; /* percentage */
+
+ /* 10 times error in percent: */
+ error = ((actual - (long)speed) * 2000 / (long)speed + 1) / 2;
/* 3.0% max error tolerance */
if (error < -30 || error > 30)
diff --git a/sys/dev/cy/cy_isa.c b/sys/dev/cy/cy_isa.c
index 7ddfbc0..38bac42 100644
--- a/sys/dev/cy/cy_isa.c
+++ b/sys/dev/cy/cy_isa.c
@@ -27,7 +27,7 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: cy.c,v 1.63 1998/06/07 17:10:16 dfr Exp $
+ * $Id: cy.c,v 1.64 1998/07/15 12:18:12 bde Exp $
*/
#include "opt_compat.h"
@@ -2482,7 +2482,9 @@ comspeed(speed, prescaler_io)
if (divider > 255)
divider = 255;
actual = CY_CLOCK/prescaler/divider;
- error = ((actual - speed) * 2000 / speed + 1) / 2; /* percentage */
+
+ /* 10 times error in percent: */
+ error = ((actual - (long)speed) * 2000 / (long)speed + 1) / 2;
/* 3.0% max error tolerance */
if (error < -30 || error > 30)
diff --git a/sys/i386/isa/cy.c b/sys/i386/isa/cy.c
index 7ddfbc0..38bac42 100644
--- a/sys/i386/isa/cy.c
+++ b/sys/i386/isa/cy.c
@@ -27,7 +27,7 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: cy.c,v 1.63 1998/06/07 17:10:16 dfr Exp $
+ * $Id: cy.c,v 1.64 1998/07/15 12:18:12 bde Exp $
*/
#include "opt_compat.h"
@@ -2482,7 +2482,9 @@ comspeed(speed, prescaler_io)
if (divider > 255)
divider = 255;
actual = CY_CLOCK/prescaler/divider;
- error = ((actual - speed) * 2000 / speed + 1) / 2; /* percentage */
+
+ /* 10 times error in percent: */
+ error = ((actual - (long)speed) * 2000 / (long)speed + 1) / 2;
/* 3.0% max error tolerance */
if (error < -30 || error > 30)
OpenPOWER on IntegriCloud