svn commit: r354076 - head/sys/dev/ow

Andriy Gapon avg at FreeBSD.org
Fri Oct 25 15:38:09 UTC 2019


Author: avg
Date: Fri Oct 25 15:38:09 2019
New Revision: 354076
URL: https://svnweb.freebsd.org/changeset/base/354076

Log:
  owc_gpiobus_read_data: compare times in sbintime_t units
  
  Previously the code used sbttous() before microseconds comparison in one
  place, sbttons() and nanoseconds in another, division by SBT_1US and
  microseconds in yet another.
  
  Now the code consistently uses multiplication by SBT_1US to convert
  microseconds to sbintime_t before comparing them with periods between
  calls to sbinuptime().  This is fast, this is precise enough (below
  0.03%) and the periods defined by the protocol cannot overflow.
  
  Reviewed by:	imp (D22108)
  MFC after:	2 weeks

Modified:
  head/sys/dev/ow/owc_gpiobus.c

Modified: head/sys/dev/ow/owc_gpiobus.c
==============================================================================
--- head/sys/dev/ow/owc_gpiobus.c	Fri Oct 25 15:02:50 2019	(r354075)
+++ head/sys/dev/ow/owc_gpiobus.c	Fri Oct 25 15:38:09 2019	(r354076)
@@ -296,10 +296,10 @@ owc_gpiobus_read_data(device_t dev, struct ow_timing *
 	do {
 		now = sbinuptime();
 		GETPIN(sc, &sample);
-	} while (sbttous(now - then) < t->t_rdv + 2 && sample == 0);
+	} while (now - then < (t->t_rdv + 2) * SBT_1US && sample == 0);
 	critical_exit();
 
-	if (sbttons(now - then) < t->t_rdv * 1000)
+	if (now - then < t->t_rdv * SBT_1US)
 		*bit = 1;
 	else
 		*bit = 0;
@@ -307,7 +307,7 @@ owc_gpiobus_read_data(device_t dev, struct ow_timing *
 	/* Wait out the rest of t_slot */
 	do {
 		now = sbinuptime();
-	} while ((now - then) / SBT_1US < t->t_slot);
+	} while (now - then < t->t_slot * SBT_1US);
 
 	RELBUS(sc);
 


More information about the svn-src-head mailing list