static ssize_t show_voltage(struct device *dev, struct device_attribute *attr, char *buf) { struct wm8350 *wm8350 = dev_get_drvdata(dev); int channel = to_sensor_dev_attr(attr)->index; int val; val = wm8350_read_auxadc(wm8350, channel, 0, 0) * WM8350_AUX_COEFF; val = DIV_ROUND_CLOSEST(val, 1000); return sprintf(buf, "%d\n", val); }
static int wm8350_read_line_uvolts(struct wm8350 *wm8350) { return wm8350_read_auxadc(wm8350, WM8350_AUXADC_LINE, 0, 0) * WM8350_AUX_COEFF; }
static int wm8350_read_usb_uvolts(struct wm8350 *wm8350) { return wm8350_read_auxadc(wm8350, WM8350_AUXADC_USB, 0, 0) * WM8350_AUX_COEFF; }
static int wm8350_read_battery_uvolts(struct wm8350 *wm8350) { return wm8350_read_auxadc(wm8350, WM8350_AUXADC_BATT, 0, 0) * WM8350_AUX_COEFF; }