+#include <linux/uaccess.h>
+
+static bool v5v_power_proc_enabled;
+static bool exp_power_proc_enabled;
+
+static int v5v_enable_read(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ if (IS_ERR_OR_NULL(v5v_power))
+ return -ENODEV;
+
+ *eof = 1;
+ return sprintf(page, "%d\n", v5v_power_proc_enabled);
+}
+
+static int v5v_enable_write(struct file *file, const char __user *buffer,
+ unsigned long count, void *data)
+{
+ char buff[32];
+ long val;
+ int ret;
+
+ if (IS_ERR_OR_NULL(v5v_power))
+ return -ENODEV;
+
+ count = strncpy_from_user(buff, buffer,
+ count < sizeof(buff) ? count : sizeof(buff) - 1);
+ buff[count] = 0;
+
+ ret = strict_strtol(buff, 0, &val);
+ if (ret < 0)
+ return ret;
+
+ val = !!val;
+ if (val == v5v_power_proc_enabled)
+ return count;
+ if (val)
+ ret = regulator_enable(v5v_power);
+ else
+ ret = regulator_disable(v5v_power);
+ if (ret < 0)
+ return ret;
+
+ v5v_power_proc_enabled = val;
+ return count;
+}
+
+static int exp_power_read(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ int ret = 0;
+
+ if (IS_ERR_OR_NULL(exp_power))
+ return -ENODEV;
+
+ if (regulator_is_enabled(exp_power) > 0) {
+ ret = regulator_get_voltage(exp_power);
+ if (ret < 0)
+ return ret;
+ ret /= 1000;
+ }
+
+ *eof = 1;
+ return sprintf(page, "%d\n", ret);
+}
+
+static int exp_power_write(struct file *file, const char __user *buffer,
+ unsigned long count, void *data)
+{
+ char buff[32];
+ bool enable;
+ long val;
+ int ret;
+
+ if (IS_ERR_OR_NULL(exp_power))
+ return -ENODEV;
+
+ count = strncpy_from_user(buff, buffer,
+ count < sizeof(buff) ? count : sizeof(buff) - 1);
+ buff[count] = 0;
+
+ ret = strict_strtol(buff, 0, &val);
+ if (ret < 0)
+ return ret;
+
+ if (val != 0) {
+ val *= 1000;
+ ret = regulator_set_voltage(exp_power, val, val);
+ if (ret < 0)
+ return ret;
+ }
+ enable = !!val;
+ if (enable == exp_power_proc_enabled)
+ return count;
+ if (enable)
+ ret = regulator_enable(exp_power);
+ else
+ ret = regulator_disable(exp_power);
+ if (ret < 0)
+ return ret;
+
+ exp_power_proc_enabled = enable;
+ return count;
+}