hwmon: ina219: add precision multiplier
Deepak Nibade [Thu, 25 Oct 2012 13:25:29 +0000 (18:25 +0530)]
-Precision multiplier declared
-This multiplier will be defined in respective board files
-Finally multiplier is divided to get normalized value

Bug 1049224

Change-Id: Ia84c622c1f1f5ee845806d26b64600be4564b5b9
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/147578
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Tested-by: Bharat Nihalani <bnihalani@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User

drivers/hwmon/ina219.c
include/linux/ina219.h

index 8b5cbf4..fda40f4 100644 (file)
@@ -219,6 +219,8 @@ static s32 show_power(struct device *dev,
                INA219_POWER));
        DEBUG_INA219(("Ina219 power Reg: 0x%x\n", power_mW));
        power_mW *= data->pInfo->power_lsb;
+       if (data->pInfo->precision_multiplier)
+               power_mW /= data->pInfo->precision_multiplier;
        DEBUG_INA219(("Ina219 power Val: %d\n", power_mW));
        if (power_mW < 0)
                goto error;
@@ -295,6 +297,8 @@ static s32 show_current(struct device *dev,
                goto error;
        current_mA =
                (current_mA * data->pInfo->power_lsb) / data->pInfo->divisor;
+       if (data->pInfo->precision_multiplier)
+               current_mA /= data->pInfo->precision_multiplier;
        DEBUG_INA219(("Ina219 current Value: %d\n", current_mA));
 
        /* set ina219 to power down mode */
index cc63452..422d726 100644 (file)
@@ -29,6 +29,7 @@ struct ina219_platform_data {
        u8 divisor; /*divisor needed to get current value */
        u32 calibration_data;
        u32 power_lsb;
+       u32 precision_multiplier;
        char rail_name[INA219_RAIL_NAME_SIZE];
 };