diff --git a/device/pwm.c b/device/pwm.c index e6ec27e..8bae2c2 100644 --- a/device/pwm.c +++ b/device/pwm.c @@ -209,8 +209,9 @@ static ssize_t mr_pwm_write(struct mr_dev *dev, int off, const void *buf, size_t for (wr_size = 0; wr_size < size; wr_size += sizeof(*wr_buf)) { /* Calculate the compare value */ - uint32_t compare_value = (uint32_t)(((float)*wr_buf / 1000000.0f) * (float)(pwm->period)); - MR_BOUND(compare_value, 0, pwm->period); + uint32_t compare_value = MR_BOUND((uint32_t)(((float)*wr_buf / 1000000.0f) * (float)(pwm->period)), + 0, + pwm->period); ops->write(pwm, off, compare_value); wr_buf++; } diff --git a/source/device.c b/source/device.c index 726bd54..a4e5d25 100644 --- a/source/device.c +++ b/source/device.c @@ -388,11 +388,13 @@ MR_INLINE ssize_t dev_ioctl(struct mr_dev *dev, int desc, int off, int cmd, void { if (args != MR_NULL) { - int *path = (int *)args; - char *buf = (char *)path[0]; - size_t bufsz = (size_t)path[1]; + struct + { + char *buf; + size_t bufsz; + } *path = args; - return dev_get_path(dev, buf, bufsz); + return dev_get_path(dev, path->buf, path->bufsz); } return MR_EINVAL; }