aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorStewart Smith <stewart@linux.vnet.ibm.com>2015-11-10 15:25:36 +1100
committerStewart Smith <stewart@linux.vnet.ibm.com>2015-11-10 15:25:36 +1100
commit316f3dd6f878660da28f9e35b2e6b3c11857fe7f (patch)
tree77c86ff82f1cc216e51e64576c96e9bc66be5d09 /hw
parentd5ab95829c21041c7d0137470bb03b8a6af6354a (diff)
downloadskiboot-316f3dd6f878660da28f9e35b2e6b3c11857fe7f.zip
skiboot-316f3dd6f878660da28f9e35b2e6b3c11857fe7f.tar.gz
skiboot-316f3dd6f878660da28f9e35b2e6b3c11857fe7f.tar.bz2
llvm-scan-build: fix potential division by zero
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/p8-i2c.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/hw/p8-i2c.c b/hw/p8-i2c.c
index 848d400..66510f1 100644
--- a/hw/p8-i2c.c
+++ b/hw/p8-i2c.c
@@ -1036,6 +1036,7 @@ static void p8_i2c_free_request(struct i2c_request *req)
static inline uint32_t p8_i2c_get_bit_rate_divisor(uint32_t lb_freq,
uint32_t bus_speed)
{
+ assert(bus_speed > 0);
return (((lb_freq / bus_speed) - 1) / 4);
}
@@ -1043,6 +1044,8 @@ static inline uint64_t p8_i2c_get_poll_interval(uint32_t bus_speed)
{
uint64_t usec;
+ assert(bus_speed > 0);
+
/* Polling Interval = 8 * (1/bus_speed) * (1/10) -> convert to uSec */
usec = ((8 * USEC_PER_SEC) / (10 * bus_speed));
return usecs_to_tb(usec);