ab8500-bmdata: Re-jiggle bmdevs_of_probe to be more succinct

We can actually write bmdevs_of_probe to be easier to follow, use
less lines of code and we can even render a variable unused so
that we can remove it completely.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
This commit is contained in:
Lee Jones 2012-11-30 09:16:40 +00:00
parent 43dc4470e3
commit 8e3a71e56c

View File

@ -456,38 +456,29 @@ int __devinit bmdevs_of_probe(struct device *dev,
struct device_node *np, struct device_node *np,
struct abx500_bm_data **battery) struct abx500_bm_data **battery)
{ {
struct abx500_battery_type *btype; struct batres_vs_temp *tmp_batres_tbl;
struct device_node *np_bat_supply; struct device_node *np_bat_supply;
struct abx500_bm_data *bat; struct abx500_bm_data *bat;
const char *btech; const char *btech;
int i, thermistor; int i;
*battery = &ab8500_bm_data; *battery = &ab8500_bm_data;
/* get phandle to 'battery-info' node */ /* get phandle to 'battery-info' node */
np_bat_supply = of_parse_phandle(np, "battery", 0); np_bat_supply = of_parse_phandle(np, "battery", 0);
if (!np_bat_supply) { if (!np_bat_supply) {
dev_err(dev, "missing property battery\n"); dev_err(dev, "battery node or reference missing\n");
return -EINVAL; return -EINVAL;
} }
if (of_property_read_bool(np_bat_supply, "thermistor-on-batctrl"))
thermistor = NTC_INTERNAL;
else
thermistor = NTC_EXTERNAL;
bat = *battery;
if (thermistor == NTC_EXTERNAL) {
bat->n_btypes = 4;
bat->bat_type = bat_type_ext_thermistor;
bat->adc_therm = ABx500_ADC_THERM_BATTEMP;
}
btech = of_get_property(np_bat_supply, "stericsson,battery-type", NULL); btech = of_get_property(np_bat_supply, "stericsson,battery-type", NULL);
if (!btech) { if (!btech) {
dev_warn(dev, "missing property battery-name/type\n"); dev_warn(dev, "missing property battery-name/type\n");
return -EINVAL; return -EINVAL;
} }
bat = *battery;
if (strncmp(btech, "LION", 4) == 0) { if (strncmp(btech, "LION", 4) == 0) {
bat->no_maintenance = true; bat->no_maintenance = true;
bat->chg_unknown_bat = true; bat->chg_unknown_bat = true;
@ -498,20 +489,22 @@ int __devinit bmdevs_of_probe(struct device *dev,
bat->bat_type[BATTERY_UNKNOWN].normal_vol_lvl = 4200; bat->bat_type[BATTERY_UNKNOWN].normal_vol_lvl = 4200;
} }
/* select the battery resolution table */ if (of_property_read_bool(np_bat_supply, "thermistor-on-batctrl")) {
for (i = 0; i < bat->n_btypes; ++i) { if (strncmp(btech, "LION", 4) == 0)
btype = (bat->bat_type + i); tmp_batres_tbl = temp_to_batres_tbl_9100;
if (thermistor == NTC_EXTERNAL) { else
btype->batres_tbl = tmp_batres_tbl = temp_to_batres_tbl_thermistor;
temp_to_batres_tbl_ext_thermistor; } else {
} else if (strncmp(btech, "LION", 4) == 0) { bat->n_btypes = 4;
btype->batres_tbl = bat->bat_type = bat_type_ext_thermistor;
temp_to_batres_tbl_9100; bat->adc_therm = ABx500_ADC_THERM_BATTEMP;
} else { tmp_batres_tbl = temp_to_batres_tbl_ext_thermistor;
btype->batres_tbl =
temp_to_batres_tbl_thermistor;
}
} }
/* select the battery resolution table */
for (i = 0; i < bat->n_btypes; ++i)
bat->bat_type[i]->batres_tbl = tmp_batres_tbl;
of_node_put(np_bat_supply); of_node_put(np_bat_supply);
return 0; return 0;