.. | .. |
---|
185 | 185 | union power_supply_propval *val) |
---|
186 | 186 | { |
---|
187 | 187 | struct axp20x_batt_ps *axp20x_batt = power_supply_get_drvdata(psy); |
---|
188 | | - struct iio_channel *chan; |
---|
189 | 188 | int ret = 0, reg, val1; |
---|
190 | 189 | |
---|
191 | 190 | switch (psp) { |
---|
.. | .. |
---|
265 | 264 | if (ret) |
---|
266 | 265 | return ret; |
---|
267 | 266 | |
---|
268 | | - if (reg & AXP20X_PWR_STATUS_BAT_CHARGING) |
---|
269 | | - chan = axp20x_batt->batt_chrg_i; |
---|
270 | | - else |
---|
271 | | - chan = axp20x_batt->batt_dischrg_i; |
---|
272 | | - |
---|
273 | | - ret = iio_read_channel_processed(chan, &val->intval); |
---|
| 267 | + if (reg & AXP20X_PWR_STATUS_BAT_CHARGING) { |
---|
| 268 | + ret = iio_read_channel_processed(axp20x_batt->batt_chrg_i, &val->intval); |
---|
| 269 | + } else { |
---|
| 270 | + ret = iio_read_channel_processed(axp20x_batt->batt_dischrg_i, &val1); |
---|
| 271 | + val->intval = -val1; |
---|
| 272 | + } |
---|
274 | 273 | if (ret) |
---|
275 | 274 | return ret; |
---|
276 | 275 | |
---|