On Mon, Feb 28, 2011 at 3:18 PM, Keerthy <j-keerthy@xxxxxx> wrote: > +static int twl4030_madc_read_channels(struct twl4030_madc_data *madc, > + u8 reg_base, unsigned > + long channels, int *buf) > +{ > + int count = 0, count_req = 0, i; > + u8 reg; > + > + for_each_set_bit(i, &channels, TWL4030_MADC_MAX_CHANNELS) { > + reg = reg_base + 2 * i; > + buf[i] = twl4030_madc_channel_raw_read(madc, reg); > + if (buf[i] < 0) { > + dev_err(madc->dev, > + "Unable to read register 0x%X\n", reg); > + count_req++; > + continue; > + } > + switch (i) { > + case 10: > + buf[i] = > + twl4030battery_current(buf[i]); Possibly fix these breaks in statements where applicable. > + if (buf[i] < 0) { > + dev_err(madc->dev, > + "error reading current"); > + count_req++; > + } else { > + count++; > + buf[i] = buf[i] - 750; > + } > + break; > + case 1: > + buf[i] = > + twl4030battery_temperature(buf[i]); > + if (buf[i] < 0) { > + dev_err(madc->dev, > + "error reading temperature"); > + count_req++; > + } else { > + count++; > + } > + break; > + default: > + count++; > + /* Analog Input (V) = conv_result * > + * step_size / R > + * conv_result = decimal value > + * of 10-bit conversion > + * result > + * step size = 1.5 / (2 ^ 10 -1) > + * R = Prescaler ratio for input > + * channels > + * Result given in mV hence multiplied > + * by 1000 > + */ > + buf[i] = (buf[i] * 3 * 1000 * > + twl4030_divider_ratios[i].denominator) > + / (2 * 1023 * > + twl4030_divider_ratios[i].numerator); > + } > + } > + if (count_req) > + dev_dbg(madc->dev, "%d channel conversion failed\n", count_req); > + > + return count; > +} > + ÿôèº{.nÇ+?·?®??+%?Ëÿ±éݶ¥?wÿº{.nÇ+?·¥?{±þ??§ø§¶?¡Ü¨}©?²Æ zÚ&j:+v?¨þø¯ù®w¥þ?à2?Þ?¨èÚ&¢)ß¡«a¶Úÿÿûàz¿äz¹Þ?ú+?ù???Ý¢jÿ?wèþf