hwmon: (mcp3021) Fix broken output scaling
authorStevens, Nick <Nick.Stevens@digi.com>
Wed, 1 Jul 2015 16:07:41 +0000 (16:07 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 3 Aug 2015 16:29:13 +0000 (09:29 -0700)
commitf94402351ca06e1fd5699e3e01601d517e01d1a8
tree3680c78cd4f293d3be7b25be556d63b1f6b7bfb9
parent7640ca524e936f7e47dc8ecbc463ea1876346f4d
hwmon: (mcp3021) Fix broken output scaling

commit 347d7e45bd09ce09cbc30d5cea9de377eb22f55c upstream.

The mcp3021 scaling code is dividing the VDD (full-scale) value in
millivolts by the A2D resolution to obtain the scaling factor. When VDD
is 3300mV (the standard value) and the resolution is 12-bit (4096
divisions), the result is a scale factor of 3300/4096, which is always
one.  Effectively, the raw A2D reading is always being returned because
no scaling is applied.

This patch fixes the issue and simplifies the register-to-volts
calculation, removing the unneeded "output_scale" struct member.

Signed-off-by: Nick Stevens <Nick.Stevens@digi.com>
[Guenter Roeck: Dropped unnecessary value check]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hwmon/mcp3021.c