Prechádzať zdrojové kódy

1、优化编译warning。2、修复batteryLED bug

liu qidong [url ssh://qidong.liu@10.2.90.253:29418/] 1 mesiac pred
rodič
commit
3d848900ff
13 zmenil súbory, kde vykonal 101 pridanie a 416 odobranie
  1. 3 2
      Makefile
  2. 3 0
      batteryled.c
  3. 8 8
      buzzer.c
  4. 3 3
      lcd_2x20.c
  5. 4 3
      led_heartbeat.c
  6. 1 1
      main.c
  7. 10 6
      myname.c
  8. 12 8
      ssegment.c
  9. 9 6
      switches.c
  10. 25 170
      sysfs_power.c
  11. 10 197
      vbat.c
  12. 8 7
      voltage_sysfs.c
  13. 5 5
      writeprotect.c

+ 3 - 2
Makefile

@@ -5,9 +5,10 @@ obj-m := opal.o
 
 opal-objs := main.o led.o light_ring.o ssegment.o ec_version.o buzzer.o fan.o writeprotect.o myname.o cash_drawers.o batteryled.o watchdog.o power.o switches.o backlight.o gsensor.o lcd_2x20.o smart_battery.o voltage_sysfs.o led_heartbeat.o sysfs_power.o vbat.o temperature_sysfs.o
 
-PROJECT_NAME := POS
+PROJECT_NAME ?= 1
+POS ?= 1
 KERNELDIR := ~/timesys/SDK64Bit-V6_02_00/kernel-source/linux-5.15/
-ccflags-y += -I./include -DPROJECT=$(PROJECT_NAME)
+ccflags-y += -I./include -DPROJECT=$(PROJECT_NAME) -DPOS=$(POS)
 EXTRA_CFLAGS +=-g -I$(PWD)/include
 
 INSTALL_DIR := /lib/modules/$(shell uname -r)/extra

+ 3 - 0
batteryled.c

@@ -73,6 +73,7 @@ static int wait_obf(void)
     return 0;
 }
 
+#if 0
 static int ec_read_ram(uint8_t offset, uint8_t *data)
 {
     if (wait_ibf() < 0)
@@ -106,6 +107,7 @@ static int ec_write_ram(uint8_t offset, uint8_t data)
 
     return 0;
 }
+#endif
 
 static int oem_ec_read_ram(uint8_t page, uint8_t offset, uint8_t *data)
 {
@@ -456,6 +458,7 @@ void batteryled_exit(void)
 {
     
     cancel_delayed_work_sync(&delay_work1);
+    cancel_delayed_work_sync(&delay_work2);
     sysfs_remove_group(batteryled_kobj, &batteryled_attr_group);
     kobject_put(batteryled_kobj);
 }

+ 8 - 8
buzzer.c

@@ -36,7 +36,7 @@ MODULE_PARM_DESC(buzzer_minor, "Minor device number");
 
 static struct class *char_class = NULL;
 static struct device *char_device = NULL;
-static struct cdev my_cdev;
+// static struct cdev my_cdev;
 static dev_t dev_num;
 
 
@@ -81,9 +81,9 @@ void BeepOn(uint16_t freq)
 }
 static void delay_work_func(struct work_struct *work)
 {
-    int status_flag = 0;
-    int freq = 0;
-    int duration = 0;
+    // int status_flag = 0;
+    // int freq = 0;
+    // int duration = 0;
     if(dev->size < 4)
     {
         return;
@@ -120,8 +120,8 @@ static ssize_t buzzer_read(struct file *filp, char __user *buf,
                              size_t count, loff_t *f_pos)
 {
     struct buzzer_dev *dev = filp->private_data;
-    ssize_t retval = 0;
-    size_t available;
+    // ssize_t retval = 0;
+    // size_t available;
     int read_count = 0;
     int ret = 0;
 
@@ -154,8 +154,8 @@ static ssize_t buzzer_write(struct file *filp, const char __user *buf,
                               size_t count, loff_t *f_pos)
 {
     struct buzzer_dev *dev = filp->private_data;
-    ssize_t retval = 0;
-    size_t available;
+    // ssize_t retval = 0;
+    // size_t available;
     int ret = 0;
     int status_flag = 0;
     int freq = 0;

+ 3 - 3
lcd_2x20.c

@@ -224,8 +224,8 @@ static void print_adapter_info(struct i2c_adapter *adap, int nr)
     char pci_str[64] = "N/A";
     
     if (!debug) return;
-    
-    pr_info("  [%d] %s (class: 0x%lx)\n", nr, adap->name, adap->class);
+
+    // pr_info("  [%d] %s (class: 0x%lx)\n", nr, adap->name, adap->class);
     
     parent = adap->dev.parent;
     while (parent) {
@@ -434,8 +434,8 @@ static struct miscdevice lcd_miscdev = {
 
 int lcd2x20_init(void)
 {
-    return 0;
     int ret;
+    return 0;
     
     pr_info("LCD2002 driver loading (PCI:%s, Bus:%d, Addr:0x%02X)...\n",
             pci_addr ? pci_addr : "none", i2c_bus, i2c_address);

+ 4 - 3
led_heartbeat.c

@@ -95,7 +95,7 @@ static int ec_write_ram(uint8_t offset, uint8_t data)
 
     return 0;
 }
-
+#if 0
 static int oem_ec_read_ram(uint8_t page, uint8_t offset, uint8_t *data)
 {
     unsigned char WEC, REC;
@@ -136,6 +136,7 @@ static int oem_ec_read_ram(uint8_t page, uint8_t offset, uint8_t *data)
 
     return 0;
 }
+#endif
 
 static int oem_ec_write_ram(uint8_t page, uint8_t offset, uint8_t data)
 {
@@ -177,7 +178,6 @@ static int oem_ec_write_ram(uint8_t page, uint8_t offset, uint8_t data)
 
     return 0;
 }
-
 static void heart_led_turn_on(void)
 {
     oem_ec_write_ram(1, OFFSET_TURNOFF_CTL, 0x00);
@@ -202,7 +202,7 @@ static int led_set_color(led_color_t color)
     heart_led_turn_on();
     return ec_write_ram(OFFSET_COLOR_CTL, val);
 }
-
+#if 0
 static int led_set_blink(int enable, uint8_t interval_unit)
 {
     uint8_t ctl;
@@ -224,6 +224,7 @@ static int led_set_blink(int enable, uint8_t interval_unit)
     heart_led_turn_on();
     return ec_write_ram(OFFSET_BLINK_CTL, ctl);
 }
+#endif
 
 static int led_heartbeat_open(struct inode *inode, struct file *filp)
 {

+ 1 - 1
main.c

@@ -162,7 +162,7 @@ static int __init all_driver_init(void)
     if(ret != 0)
     {
         printk(KERN_ERR "batteryled_init failed\n");
-        goto out_gensor;
+        goto out_lcd;
     }
 
     ret = voltage_sysfs_init();

+ 10 - 6
myname.c

@@ -34,7 +34,7 @@ MODULE_PARM_DESC(myname_minor, "Minor device number");
 
 static struct class *char_class = NULL;
 static struct device *char_device = NULL;
-static struct cdev my_cdev;
+// static struct cdev my_cdev;
 static dev_t dev_num;
 
 struct myname_dev
@@ -51,9 +51,12 @@ static struct myname_dev *dev = NULL;
 
 unsigned int myname_readl(unsigned int addr)
 {
+    unsigned int val;
     void __iomem *reg_base = NULL;
-    reg_base = ioremap(addr, 0x1000);
-    return readl(reg_base);
+    reg_base = ioremap(addr, 4);
+    val = readl(reg_base);
+    iounmap(reg_base);
+    return val;
 }
 
 static void delay_work_func(struct work_struct *work)
@@ -86,6 +89,7 @@ static ssize_t myname_read(struct file *filp, char __user *buf,
     struct myname_dev *dev = filp->private_data;
     ssize_t retval = 0;
     int ret = 0;
+    size_t available = 0;
 
     if (mutex_lock_interruptible(&dev->lock))
         return -ERESTARTSYS;
@@ -97,7 +101,7 @@ static ssize_t myname_read(struct file *filp, char __user *buf,
         return 0;
     }
 
-    size_t available = dev->size - *f_pos;
+    available = dev->size - *f_pos;
     
     if (count > available) {
         retval = available;
@@ -127,8 +131,8 @@ static ssize_t myname_write(struct file *filp, const char __user *buf,
                               size_t count, loff_t *f_pos)
 {
     struct myname_dev *dev = filp->private_data;
-    ssize_t retval = 0;
-    size_t available;
+    // ssize_t retval = 0;
+    // size_t available;
     int ret = 0;
     return -1;
 

+ 12 - 8
ssegment.c

@@ -32,7 +32,7 @@ MODULE_PARM_DESC(minor, "Minor device number");
 
 static struct class *char_class = NULL;
 static struct device *char_device = NULL;
-static struct cdev my_cdev;
+// static struct cdev my_cdev;
 static dev_t dev_num;
 
 struct ssegment_dev
@@ -49,16 +49,20 @@ static struct ssegment_dev *dev = NULL;
 
 unsigned int readl_cust(unsigned int addr)
 {
+    unsigned int val;
     void __iomem *reg_base;
-    reg_base = ioremap(addr, 0x1000);
-    return readl(reg_base);
+    reg_base = ioremap(addr, 4);
+    val = readl(reg_base);
+    iounmap(reg_base);
+    return val;
 }
 
 int writel_cust(unsigned int addr, unsigned int val)
 {
     void __iomem *reg_base;
-    reg_base = ioremap(addr, 0x1000);
+    reg_base = ioremap(addr, 4);
     writel(val, reg_base);
+    iounmap(reg_base);
     return 0;
 }
 
@@ -138,8 +142,8 @@ static ssize_t ssegment_read(struct file *filp, char __user *buf,
                              size_t count, loff_t *f_pos)
 {
     struct ssegment_dev *dev = filp->private_data;
-    ssize_t retval = 0;
-    size_t available;
+    // ssize_t retval = 0;
+    // size_t available;
     int read_count = 0;
     int ret = 0;
 
@@ -172,8 +176,8 @@ static ssize_t ssegment_write(struct file *filp, const char __user *buf,
                               size_t count, loff_t *f_pos)
 {
     struct ssegment_dev *dev = filp->private_data;
-    ssize_t retval = 0;
-    size_t available;
+    // ssize_t retval = 0;
+    // size_t available;
     int ret = 0;
 
     if (mutex_lock_interruptible(&dev->lock))

+ 9 - 6
switches.c

@@ -53,7 +53,7 @@ MODULE_PARM_DESC(switches_minor, "Minor device number");
 
 static struct class *char_class = NULL;
 static struct device *char_device = NULL;
-static struct cdev my_cdev;
+// static struct cdev my_cdev;
 static dev_t dev_num;
 
 struct switches_dev
@@ -71,9 +71,12 @@ static struct switches_dev *dev = NULL;
 
 unsigned int switch_readl(unsigned int addr)
 {
+    unsigned int val;
     void __iomem *reg_base = NULL;
-    reg_base = ioremap(addr, 0x1000);
-    return readl(reg_base);
+    reg_base = ioremap(addr, 4);
+    val = readl(reg_base);
+    iounmap(reg_base);
+    return val;
 }
 int get_switch_gpio_status(void)
 {
@@ -123,9 +126,9 @@ static ssize_t switches_read(struct file *filp, char __user *buf,
                              size_t count, loff_t *f_pos)
 {
     struct switches_dev *dev = filp->private_data;
-    ssize_t retval = 0;
-    size_t available;
-    int read_count = 0;
+    // ssize_t retval = 0;
+    // size_t available;
+    // int read_count = 0;
     int ret = 0;
     int i = 0;
     // ret = copy_to_user(buf, dev->switch_status, read_count);

+ 25 - 170
sysfs_power.c

@@ -10,73 +10,6 @@
 
 extern struct kobject *hwmon_kobj;
 
-
-/* Helper functions for IO access */
-static uint8_t hwm_read_reg(uint16_t hwm_base, uint8_t reg)
-{
-    outb(reg, hwm_base + HWM_INDEX_OFFSET);
-    return inb(hwm_base + HWM_DATA_OFFSET);
-}
-
-static void hwm_write_reg(uint16_t hwm_base, uint8_t reg, uint8_t val)
-{
-    outb(reg, hwm_base + HWM_INDEX_OFFSET);
-    outb(val, hwm_base + HWM_DATA_OFFSET);
-}
-
-static uint8_t hwm_read_reg_retry(uint16_t hwm_base, uint8_t reg)
-{
-    uint8_t v = hwm_read_reg(hwm_base, reg);
-    if (v == 0xFF) {
-        v = hwm_read_reg(hwm_base, reg);
-    }
-    return v;
-}
-
-static int vin_raw_to_volt(uint8_t raw, int r_top_kohm, int r_bottom_kohm)
-{
-    int vm = raw * 11;
-    if (r_top_kohm > 0 && r_bottom_kohm > 0) {
-        vm = (vm * (r_top_kohm + r_bottom_kohm)) / r_bottom_kohm;
-    }
-    return vm;
-}
-
-static int ec_raw_to_volt(uint8_t raw, int r_top_kohm, int r_bottom_kohm)
-{
-    int vm = raw * 12; /* EC unit: 10mV */
-    vm = (vm * (r_top_kohm + r_bottom_kohm)) / r_bottom_kohm;
-    return vm ;
-}
-
-
-static int ec_wait_ibf(void)
-{
-    int i = 0;
-    while (inb(EC_CMD_PORT) & EC_IBF) {
-        if (++i > TIMEOUT_LOOPS) {
-            printk("Error: EC IBF Timeout!\n");
-            return -1;
-        }
-        udelay(1);
-    }
-    return 0;
-}
-
-static int ec_wait_obf(void)
-{
-    int i = 0;
-    while (!(inb(EC_CMD_PORT) & EC_OBF)) {
-        if (++i > TIMEOUT_LOOPS) {
-            printk("Error: EC OBF Timeout!\n");
-            return -1;
-        }
-        udelay(1);
-    }
-    return 0;
-}
-
-
 static int wait_ibf(void)
 {
     int i = 0;
@@ -105,143 +38,65 @@ static int wait_obf(void)
     return 0;
 }
 
-static int ec_read_ram(uint8_t offset, uint8_t *data)
-{
-    if (wait_ibf() < 0)
-        return -1;
-    outb(CMD_READ_RAM, EC_CMD_PORT);
-
-    if (wait_ibf() < 0)
-        return -1;
-    outb(offset, EC_DATA_PORT);
-
-    if (wait_obf() < 0)
-        return -1;
-    *data = inb(EC_DATA_PORT);
-
-    return 0;
-}
-
-static int ec_write_ram(uint8_t offset, uint8_t data)
-{
-    if (wait_ibf() < 0)
-        return -1;
-    outb(CMD_WRITE_RAM, EC_CMD_PORT);
-
-    if (wait_ibf() < 0)
-        return -1;
-    outb(offset, EC_DATA_PORT);
-
-    if (wait_ibf() < 0)
-        return -1;
-    outb(data, EC_DATA_PORT);
-
-    return 0;
-}
-
 static int oem_ec_read_ram(uint8_t page, uint8_t offset, uint8_t *data)
 {
     unsigned char WEC, REC;
-    switch(page)
+    switch (page)
     {
-        case 0:
-        {
-            WEC = 0x96;
-            REC = 0x95;
-            break;
-        }
-        
-        case 1:
-        {
-            WEC = 0x98;
-            REC = 0x97;
-            break;
-        }
-        
-        default:
-        {
-            WEC = 0x81;
-            REC = 0x80;
-            break;
-        }
-    }    
-    if (wait_ibf() < 0)
-        return -1;
-    outb(REC, EC_CMD_PORT);
-
-    if (wait_ibf() < 0)
-        return -1;
-    outb(offset, EC_DATA_PORT);
-
-    if (wait_obf() < 0)
-        return -1;
-    *data = inb(EC_DATA_PORT);
+    case 0:
+    {
+        WEC = 0x96;
+        REC = 0x95;
+        break;
+    }
 
-    return 0;
-}
+    case 1:
+    {
+        WEC = 0x98;
+        REC = 0x97;
+        break;
+    }
 
-static int oem_ec_write_ram(uint8_t page, uint8_t offset, uint8_t data)
-{
-    unsigned char WEC, REC;
-    switch(page)
+    default:
     {
-        case 0:
-        {
-            WEC = 0x96;
-            REC = 0x95;
-            break;
-        }
-        
-        case 1:
-        {
-            WEC = 0x98;
-            REC = 0x97;
-            break;
-        }
-        
-        default:
-        {
-            WEC = 0x81;
-            REC = 0x80;
-            break;
-        }
+        WEC = 0x81;
+        REC = 0x80;
+        break;
+    }
     }
     if (wait_ibf() < 0)
         return -1;
-    outb(WEC, EC_CMD_PORT);
+    outb(REC, EC_CMD_PORT);
 
     if (wait_ibf() < 0)
         return -1;
     outb(offset, EC_DATA_PORT);
 
-    if (wait_ibf() < 0)
+    if (wait_obf() < 0)
         return -1;
-    outb(data, EC_DATA_PORT);
+    *data = inb(EC_DATA_PORT);
 
     return 0;
 }
 
-
-
 static ssize_t ac_power_show(struct kobject *kobj, struct kobj_attribute *attr,
-                         char *buf)
+                             char *buf)
 {
     int ac_power_flag = 0;
     uint8_t val = 0x00;
     if (oem_ec_read_ram(2, 0x36, &val) < 0)
         return -1;
-    ac_power_flag = (val  & 0x03) ? 1 : 0;
+    ac_power_flag = (val & 0x03) ? 1 : 0;
 
-	return sprintf(buf, "%d\n", ac_power_flag);
+    return sprintf(buf, "%d\n", ac_power_flag);
 }
 
 static ssize_t ac_power_store(struct kobject *kobj, struct kobj_attribute *attr,
-                                 const char *buf, size_t count)
+                              const char *buf, size_t count)
 {
     return -EINVAL;
 }
 
-
 static struct kobj_attribute ac_power =
     __ATTR(ac_power, 0644, ac_power_show, ac_power_store);
 

+ 10 - 197
vbat.c

@@ -10,7 +10,6 @@
 
 extern struct kobject *hwmon_kobj;
 
-
 /* Helper functions for IO access */
 static uint8_t hwm_read_reg(uint16_t hwm_base, uint8_t reg)
 {
@@ -18,16 +17,11 @@ static uint8_t hwm_read_reg(uint16_t hwm_base, uint8_t reg)
     return inb(hwm_base + HWM_DATA_OFFSET);
 }
 
-static void hwm_write_reg(uint16_t hwm_base, uint8_t reg, uint8_t val)
-{
-    outb(reg, hwm_base + HWM_INDEX_OFFSET);
-    outb(val, hwm_base + HWM_DATA_OFFSET);
-}
-
 static uint8_t hwm_read_reg_retry(uint16_t hwm_base, uint8_t reg)
 {
     uint8_t v = hwm_read_reg(hwm_base, reg);
-    if (v == 0xFF) {
+    if (v == 0xFF)
+    {
         v = hwm_read_reg(hwm_base, reg);
     }
     return v;
@@ -36,212 +30,31 @@ static uint8_t hwm_read_reg_retry(uint16_t hwm_base, uint8_t reg)
 static int vin_raw_to_volt(uint8_t raw, int r_top_kohm, int r_bottom_kohm)
 {
     int vm = raw * 11;
-    if (r_top_kohm > 0 && r_bottom_kohm > 0) {
+    if (r_top_kohm > 0 && r_bottom_kohm > 0)
+    {
         vm = (vm * (r_top_kohm + r_bottom_kohm)) / r_bottom_kohm;
     }
     return vm;
 }
 
-static int ec_raw_to_volt(uint8_t raw, int r_top_kohm, int r_bottom_kohm)
-{
-    int vm = raw * 12; /* EC unit: 10mV */
-    vm = (vm * (r_top_kohm + r_bottom_kohm)) / r_bottom_kohm;
-    return vm ;
-}
-
-
-static int ec_wait_ibf(void)
-{
-    int i = 0;
-    while (inb(EC_CMD_PORT) & EC_IBF) {
-        if (++i > TIMEOUT_LOOPS) {
-            printk("Error: EC IBF Timeout!\n");
-            return -1;
-        }
-        udelay(1);
-    }
-    return 0;
-}
-
-static int ec_wait_obf(void)
-{
-    int i = 0;
-    while (!(inb(EC_CMD_PORT) & EC_OBF)) {
-        if (++i > TIMEOUT_LOOPS) {
-            printk("Error: EC OBF Timeout!\n");
-            return -1;
-        }
-        udelay(1);
-    }
-    return 0;
-}
-
-
-static int wait_ibf(void)
-{
-    int i = 0;
-    while (inb(EC_CMD_PORT) & EC_IBF)
-    {
-        if (++i > TIMEOUT_LOOPS)
-        {
-            return -1;
-        }
-        udelay(1);
-    }
-    return 0;
-}
-
-static int wait_obf(void)
-{
-    int i = 0;
-    while (!(inb(EC_CMD_PORT) & EC_OBF))
-    {
-        if (++i > TIMEOUT_LOOPS)
-        {
-            return -1;
-        }
-        udelay(1);
-    }
-    return 0;
-}
-
-static int ec_read_ram(uint8_t offset, uint8_t *data)
-{
-    if (wait_ibf() < 0)
-        return -1;
-    outb(CMD_READ_RAM, EC_CMD_PORT);
-
-    if (wait_ibf() < 0)
-        return -1;
-    outb(offset, EC_DATA_PORT);
-
-    if (wait_obf() < 0)
-        return -1;
-    *data = inb(EC_DATA_PORT);
-
-    return 0;
-}
-
-static int ec_write_ram(uint8_t offset, uint8_t data)
-{
-    if (wait_ibf() < 0)
-        return -1;
-    outb(CMD_WRITE_RAM, EC_CMD_PORT);
-
-    if (wait_ibf() < 0)
-        return -1;
-    outb(offset, EC_DATA_PORT);
-
-    if (wait_ibf() < 0)
-        return -1;
-    outb(data, EC_DATA_PORT);
-
-    return 0;
-}
-
-static int oem_ec_read_ram(uint8_t page, uint8_t offset, uint8_t *data)
-{
-    unsigned char WEC, REC;
-    switch(page)
-    {
-        case 0:
-        {
-            WEC = 0x96;
-            REC = 0x95;
-            break;
-        }
-        
-        case 1:
-        {
-            WEC = 0x98;
-            REC = 0x97;
-            break;
-        }
-        
-        default:
-        {
-            WEC = 0x81;
-            REC = 0x80;
-            break;
-        }
-    }    
-    if (wait_ibf() < 0)
-        return -1;
-    outb(REC, EC_CMD_PORT);
-
-    if (wait_ibf() < 0)
-        return -1;
-    outb(offset, EC_DATA_PORT);
-
-    if (wait_obf() < 0)
-        return -1;
-    *data = inb(EC_DATA_PORT);
-
-    return 0;
-}
-
-static int oem_ec_write_ram(uint8_t page, uint8_t offset, uint8_t data)
-{
-    unsigned char WEC, REC;
-    switch(page)
-    {
-        case 0:
-        {
-            WEC = 0x96;
-            REC = 0x95;
-            break;
-        }
-        
-        case 1:
-        {
-            WEC = 0x98;
-            REC = 0x97;
-            break;
-        }
-        
-        default:
-        {
-            WEC = 0x81;
-            REC = 0x80;
-            break;
-        }
-    }
-    if (wait_ibf() < 0)
-        return -1;
-    outb(WEC, EC_CMD_PORT);
-
-    if (wait_ibf() < 0)
-        return -1;
-    outb(offset, EC_DATA_PORT);
-
-    if (wait_ibf() < 0)
-        return -1;
-    outb(data, EC_DATA_PORT);
-
-    return 0;
-}
-
-
-
 static ssize_t voltage_vbat_show(struct kobject *kobj, struct kobj_attribute *attr,
-                         char *buf)
+                                 char *buf)
 {
-	int vlotage = 0;
+    int vlotage = 0;
     uint8_t raw;
-	raw = hwm_read_reg_retry(IT8786_HWM_BASE_DEFAULT, 0x28);
+    raw = hwm_read_reg_retry(IT8786_HWM_BASE_DEFAULT, 0x28);
 
-	vlotage = vin_raw_to_volt(raw, 10, 10);
+    vlotage = vin_raw_to_volt(raw, 10, 10);
 
-	return sprintf(buf, "%d\n", vlotage);
+    return sprintf(buf, "%d\n", vlotage);
 }
 
 static ssize_t voltage_vbat_store(struct kobject *kobj, struct kobj_attribute *attr,
-                                 const char *buf, size_t count)
+                                  const char *buf, size_t count)
 {
     return -EINVAL;
 }
 
-
 static struct kobj_attribute voltage_vbat =
     __ATTR(voltage_vbat, 0644, voltage_vbat_show, voltage_vbat_store);
 

+ 8 - 7
voltage_sysfs.c

@@ -17,12 +17,13 @@ static uint8_t hwm_read_reg(uint16_t hwm_base, uint8_t reg)
     outb(reg, hwm_base + HWM_INDEX_OFFSET);
     return inb(hwm_base + HWM_DATA_OFFSET);
 }
-
+#if 0
 static void hwm_write_reg(uint16_t hwm_base, uint8_t reg, uint8_t val)
 {
     outb(reg, hwm_base + HWM_INDEX_OFFSET);
     outb(val, hwm_base + HWM_DATA_OFFSET);
 }
+#endif
 
 static uint8_t hwm_read_reg_retry(uint16_t hwm_base, uint8_t reg)
 {
@@ -49,7 +50,7 @@ static int ec_raw_to_volt(uint8_t raw, int r_top_kohm, int r_bottom_kohm)
     return vm ;
 }
 
-
+#if 0
 static int ec_wait_ibf(void)
 {
     int i = 0;
@@ -75,7 +76,7 @@ static int ec_wait_obf(void)
     }
     return 0;
 }
-
+#endif
 
 static int wait_ibf(void)
 {
@@ -104,7 +105,7 @@ static int wait_obf(void)
     }
     return 0;
 }
-
+#if 0
 static int ec_read_ram(uint8_t offset, uint8_t *data)
 {
     if (wait_ibf() < 0)
@@ -138,7 +139,7 @@ static int ec_write_ram(uint8_t offset, uint8_t data)
 
     return 0;
 }
-
+#endif
 static int oem_ec_read_ram(uint8_t page, uint8_t offset, uint8_t *data)
 {
     unsigned char WEC, REC;
@@ -179,7 +180,7 @@ static int oem_ec_read_ram(uint8_t page, uint8_t offset, uint8_t *data)
 
     return 0;
 }
-
+#if 0
 static int oem_ec_write_ram(uint8_t page, uint8_t offset, uint8_t data)
 {
     unsigned char WEC, REC;
@@ -220,7 +221,7 @@ static int oem_ec_write_ram(uint8_t page, uint8_t offset, uint8_t data)
 
     return 0;
 }
-
+#endif
 
 
 

+ 5 - 5
writeprotect.c

@@ -27,7 +27,7 @@ MODULE_PARM_DESC(writeprotect_minor, "Minor device number");
 
 static struct class *char_class = NULL;
 static struct device *char_device = NULL;
-static struct cdev my_cdev;
+// static struct cdev my_cdev;
 static dev_t dev_num;
 
 struct writeprotect_dev
@@ -69,8 +69,8 @@ static ssize_t writeprotect_read(struct file *filp, char __user *buf,
                              size_t count, loff_t *f_pos)
 {
     struct writeprotect_dev *dev = filp->private_data;
-    ssize_t retval = 0;
-    size_t available;
+    // ssize_t retval = 0;
+    // size_t available;
     int read_count = 0;
     int ret = 0;
 
@@ -103,8 +103,8 @@ static ssize_t writeprotect_write(struct file *filp, const char __user *buf,
                               size_t count, loff_t *f_pos)
 {
     struct writeprotect_dev *dev = filp->private_data;
-    ssize_t retval = 0;
-    size_t available;
+    // ssize_t retval = 0;
+    // size_t available;
     int ret = 0;
 
     if (mutex_lock_interruptible(&dev->lock))