— a/kernel-4.14/drivers/leds/leds-wd3153d.c
+++ b/kernel-4.14/drivers/leds/leds-wd3153d.c
@@ -93,7 +93,7 @@
#define WD_REG_LED_BRIGHTNESS_BASE 0x34
#define WD_REG_TIMESET0_BASE 0x37
#define WD_REG_TIMESET1_BASE 0x38
+#define WD_REG_TIMESET2_BASE 0x39
/* register bits */
#define WD3153_CHIPID 0x33
#define WD_LED_MOUDLE_ENABLE_MASK 0x01
@@ -412,12 +412,17 @@ static ssize_t wd3153_led_time_store(struct device *dev,
struct wd3153_led *led =
container_of(led_cdev, struct wd3153_led, cdev);
int rc, rise_time_ms, hold_time_ms, fall_time_ms, off_time_ms;
-
u8 val; rc = sscanf(buf, "%d %d %d %d", &rise_time_ms, &hold_time_ms, &fall_time_ms, &off_time_ms); mutex_lock(&led->pdata->led->lock);
-
wd3153_read(led, WD_REG_GLOBAL_CONTROL, &val);
-
// printk("zdc WD_REG_GLOBAL_CONTROL val 0x%x", val);
-
val &= 0xFE;
-
// printk("zdc WD_REG_GLOBAL_CONTROL val 0x%x", val);
-
wd3153_write(led, WD_REG_GLOBAL_CONTROL, val); led->pdata->rise_time_ms = (rise_time_ms > MAX_RISE_TIME_MS) ? MAX_RISE_TIME_MS : rise_time_ms; led->pdata->hold_time_ms = (hold_time_ms > MAX_HOLD_TIME_MS) ?
@@ -431,12 +436,59 @@ static ssize_t wd3153_led_time_store(struct device *dev,
return len;
}
+static ssize_t wd3153_reg_show(struct device *dev,
-
struct device_attribute *attr, char *buf)
+{
-
struct led_classdev *led_cdev = dev_get_drvdata(dev);
-
struct wd3153_led *led =
-
container_of(led_cdev, struct wd3153_led, cdev);
-
u8 val;
-
int size, i;
-
char *buf0 = buf;
-
wd3153_read(led, WD_REG_RESET, &val);
-
size = snprintf(buf, PAGE_SIZE, "reg 0x%x val 0x%x\n", WD_REG_RESET, val);
-
buf += size;
-
wd3153_read(led, WD_REG_GLOBAL_CONTROL, &val);
-
size =snprintf(buf, PAGE_SIZE, "reg 0x%x val 0x%x\n", WD_REG_GLOBAL_CONTROL, val);
-
buf += size;
-
wd3153_read(led, WD_REG_LED_STATUS, &val);
-
size = snprintf(buf, PAGE_SIZE, "reg 0x%x val 0x%x\n", WD_REG_LED_STATUS, val);
-
buf += size;
-
wd3153_read(led, 0x03, &val);
-
size = snprintf(buf, PAGE_SIZE, "reg 0x%x val 0x%x\n", 0x03, val);
-
buf += size;
-
wd3153_read(led, WD_REG_LED_ENABLE, &val);
-
size = snprintf(buf, PAGE_SIZE, "reg 0x%x val 0x%x\n", WD_REG_LED_ENABLE, val);
-
buf += size;
-
for (i = 0;i < 3;i++){
-
wd3153_read(led, (WD_REG_LED_CONFIG_BASE + i), &val);
-
size = snprintf(buf, PAGE_SIZE, "reg 0x%x val 0x%x\n", (WD_REG_LED_CONFIG_BASE + i), val);
-
buf += size;
-
wd3153_read(led, (WD_REG_LED_BRIGHTNESS_BASE + i), &val);
-
size = snprintf(buf, PAGE_SIZE, "reg 0x%x val 0x%x\n", (WD_REG_LED_BRIGHTNESS_BASE + i), val);
-
buf += size;
-
wd3153_read(led, (WD_REG_TIMESET0_BASE + i * 3), &val);
-
size = snprintf(buf, PAGE_SIZE, "reg 0x%x val 0x%x\n", (WD_REG_TIMESET0_BASE + i * 3), val);
-
buf += size;
-
wd3153_read(led, (WD_REG_TIMESET1_BASE + i * 3), &val);
-
size = snprintf(buf, PAGE_SIZE, "reg 0x%x val 0x%x\n", (WD_REG_TIMESET1_BASE + i * 3), val);
-
buf += size;
-
wd3153_read(led, (WD_REG_TIMESET2_BASE + i * 3), &val);
-
size = snprintf(buf, PAGE_SIZE, "reg 0x%x val 0x%x\n", (WD_REG_TIMESET2_BASE + i * 3), val);
-
buf += size;
-
}
-
return buf - buf0;
+}
+
static DEVICE_ATTR(blink, 0664, NULL, wd3153_store_blink);
static DEVICE_ATTR(led_time, 0664, wd3153_led_time_show, wd3153_led_time_store);
+static DEVICE_ATTR(reg, 0664, wd3153_reg_show, NULL);
static struct attribute *wd3153_led_attributes[] = {
&dev_attr_blink.attr,
&dev_attr_led_time.attr,
-
&dev_attr_reg.attr, NULL,