da9055-hwmon.c (688d794c4c3f8b08c814381ee2edd3ede5856056) da9055-hwmon.c (088ce2ac9ebac5c74faf4d39083627875fa6f0f0)
1/*
2 * HWMON Driver for Dialog DA9055
3 *
4 * Copyright(c) 2012 Dialog Semiconductor Ltd.
5 *
6 * Author: David Dajun Chen <dchen@diasemi.com>
7 *
8 * This program is free software; you can redistribute it and/or modify it

--- 105 unchanged lines hidden (view full) ---

114 struct da9055_hwmon *hwmon = irq_data;
115
116 complete(&hwmon->done);
117
118 return IRQ_HANDLED;
119}
120
121/* Conversion function for VSYS and ADCINx */
1/*
2 * HWMON Driver for Dialog DA9055
3 *
4 * Copyright(c) 2012 Dialog Semiconductor Ltd.
5 *
6 * Author: David Dajun Chen <dchen@diasemi.com>
7 *
8 * This program is free software; you can redistribute it and/or modify it

--- 105 unchanged lines hidden (view full) ---

114 struct da9055_hwmon *hwmon = irq_data;
115
116 complete(&hwmon->done);
117
118 return IRQ_HANDLED;
119}
120
121/* Conversion function for VSYS and ADCINx */
122static inline int volt_reg_to_mV(int value, int channel)
122static inline int volt_reg_to_mv(int value, int channel)
123{
124 if (channel == DA9055_ADC_VSYS)
125 return DIV_ROUND_CLOSEST(value * 1000, DA9055_VSYS_DIV) + 2500;
126 else
127 return DIV_ROUND_CLOSEST(value * 1000, DA9055_ADCIN_DIV);
128}
129
130static int da9055_enable_auto_mode(struct da9055 *da9055, int channel)

--- 32 unchanged lines hidden (view full) ---

163 }
164
165 ret = da9055_disable_auto_mode(hwmon->da9055, channel);
166 if (ret < 0)
167 goto hwmon_err;
168
169 mutex_unlock(&hwmon->hwmon_lock);
170
123{
124 if (channel == DA9055_ADC_VSYS)
125 return DIV_ROUND_CLOSEST(value * 1000, DA9055_VSYS_DIV) + 2500;
126 else
127 return DIV_ROUND_CLOSEST(value * 1000, DA9055_ADCIN_DIV);
128}
129
130static int da9055_enable_auto_mode(struct da9055 *da9055, int channel)

--- 32 unchanged lines hidden (view full) ---

163 }
164
165 ret = da9055_disable_auto_mode(hwmon->da9055, channel);
166 if (ret < 0)
167 goto hwmon_err;
168
169 mutex_unlock(&hwmon->hwmon_lock);
170
171 return sprintf(buf, "%d\n", volt_reg_to_mV(adc, channel));
171 return sprintf(buf, "%d\n", volt_reg_to_mv(adc, channel));
172
173hwmon_err_release:
174 da9055_disable_auto_mode(hwmon->da9055, channel);
175hwmon_err:
176 mutex_unlock(&hwmon->hwmon_lock);
177 return ret;
178}
179

--- 157 unchanged lines hidden ---
172
173hwmon_err_release:
174 da9055_disable_auto_mode(hwmon->da9055, channel);
175hwmon_err:
176 mutex_unlock(&hwmon->hwmon_lock);
177 return ret;
178}
179

--- 157 unchanged lines hidden ---