diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2014-07-17 17:31:23 +0200 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-07-17 17:44:38 +0200 |
commit | 0d5e8c4313c83dc2d60519a219d517a13ba8a432 (patch) | |
tree | 5a9f6581e1cc493f7dc624e51e7b65598a419005 /drivers/media/i2c/soc_camera/mt9m001.c | |
parent | [media] DocBook improvement for U8 and U16 control types (diff) | |
download | linux-0d5e8c4313c83dc2d60519a219d517a13ba8a432.tar.xz linux-0d5e8c4313c83dc2d60519a219d517a13ba8a432.zip |
[media] Fix 64-bit division fall-out from 64-bit control ranges
Commit 0ba2aeb6dab80920edd9cf5b93b1ea4d6913b8f3 increased the internal control ranges
to 64 bit, but that caused problems in drivers that use the minimum/maximum/step/default_value
control values in a division or modulus operations since not all architectures support
those natively.
Luckily, in almost all cases it is possible to just cast to 32 bits (the control value
is known to be 32 bits, so it is safe to cast). Only in v4l2-ctrls.c was it necessary to
use do_div in one function.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media/i2c/soc_camera/mt9m001.c')
-rw-r--r-- | drivers/media/i2c/soc_camera/mt9m001.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/media/i2c/soc_camera/mt9m001.c b/drivers/media/i2c/soc_camera/mt9m001.c index df97033fa6ef..dbd8c142d6ef 100644 --- a/drivers/media/i2c/soc_camera/mt9m001.c +++ b/drivers/media/i2c/soc_camera/mt9m001.c @@ -403,7 +403,7 @@ static int mt9m001_s_ctrl(struct v4l2_ctrl *ctrl) if (ctrl->val <= ctrl->default_value) { /* Pack it into 0..1 step 0.125, register values 0..8 */ unsigned long range = ctrl->default_value - ctrl->minimum; - data = ((ctrl->val - ctrl->minimum) * 8 + range / 2) / range; + data = ((ctrl->val - (s32)ctrl->minimum) * 8 + range / 2) / range; dev_dbg(&client->dev, "Setting gain %d\n", data); data = reg_write(client, MT9M001_GLOBAL_GAIN, data); @@ -413,7 +413,7 @@ static int mt9m001_s_ctrl(struct v4l2_ctrl *ctrl) /* Pack it into 1.125..15 variable step, register values 9..67 */ /* We assume qctrl->maximum - qctrl->default_value - 1 > 0 */ unsigned long range = ctrl->maximum - ctrl->default_value - 1; - unsigned long gain = ((ctrl->val - ctrl->default_value - 1) * + unsigned long gain = ((ctrl->val - (s32)ctrl->default_value - 1) * 111 + range / 2) / range + 9; if (gain <= 32) @@ -434,7 +434,7 @@ static int mt9m001_s_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_EXPOSURE_AUTO: if (ctrl->val == V4L2_EXPOSURE_MANUAL) { unsigned long range = exp->maximum - exp->minimum; - unsigned long shutter = ((exp->val - exp->minimum) * 1048 + + unsigned long shutter = ((exp->val - (s32)exp->minimum) * 1048 + range / 2) / range + 1; dev_dbg(&client->dev, |