From dc9467f23641942f3cf48519f87f7d786ce19241 Mon Sep 17 00:00:00 2001 From: codeworkx Date: Fri, 14 Dec 2018 18:07:27 +0100 Subject: [PATCH] leds-qpnp: revert changes made by op Change-Id: I80c710dbee8f57fe522a82f4b5bd0c6e09c0553f --- drivers/leds/leds-qpnp.c | 100 ++++----------------------------------- 1 file changed, 10 insertions(+), 90 deletions(-) diff --git a/drivers/leds/leds-qpnp.c b/drivers/leds/leds-qpnp.c index 5c9ab25d4bab..a7cc72db3648 100755 --- a/drivers/leds/leds-qpnp.c +++ b/drivers/leds/leds-qpnp.c @@ -251,8 +251,6 @@ #define NUM_KPDBL_LEDS 4 #define KPDBL_MASTER_BIT_INDEX 0 -static u8 shutdown_enable = 0; - /** * enum qpnp_leds - QPNP supported led ids * @QPNP_ID_WLED - White led backlight @@ -2563,12 +2561,11 @@ static ssize_t duty_pcts_store(struct device *dev, struct led_classdev *led_cdev = dev_get_drvdata(dev); char *buffer; ssize_t ret; - int rets; - //int i = 0; + int i = 0; int max_duty_pcts; struct pwm_config_data *pwm_cfg; u32 previous_num_duty_pcts; - //int value; + int value; int *previous_duty_pcts; led = container_of(led_cdev, struct qpnp_led_data, cdev); @@ -2599,24 +2596,16 @@ static ssize_t duty_pcts_store(struct device *dev, buffer = (char *)buf; - rets= sscanf((const char *)buffer, - "bean %x %x %x %x %x %x %x %x %x %x %x ", - &pwm_cfg->old_duty_pcts[0], &pwm_cfg->old_duty_pcts[1], - &pwm_cfg->old_duty_pcts[2], &pwm_cfg->old_duty_pcts[3], - &pwm_cfg->old_duty_pcts[4], &pwm_cfg->old_duty_pcts[5], - &pwm_cfg->old_duty_pcts[6],&pwm_cfg->old_duty_pcts[7], - &pwm_cfg->old_duty_pcts[8], &pwm_cfg->old_duty_pcts[9], - &pwm_cfg->old_duty_pcts[10]); - printk("bean set rets = %d\n",rets); - if(rets != 11) - { - pr_err("duty_pcts_store: Invalid paramter:%d\n", rets); - return -1; + for (i = 0; i < max_duty_pcts; i++) { + if (buffer == NULL) + break; + ret = sscanf((const char *)buffer, "%u,%s", &value, buffer); + pwm_cfg->old_duty_pcts[i] = value; + num_duty_pcts++; + if (ret <= 1) + break; } - num_duty_pcts = 11; - - if (num_duty_pcts >= max_duty_pcts) { dev_err(&led->pdev->dev, "Number of duty pcts given exceeds max (%d)\n", @@ -2744,41 +2733,6 @@ static ssize_t blink_store(struct device *dev, return count; } -static ssize_t shutdown_enable_show(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - return sprintf(buf, "%d\n", shutdown_enable); -} - -static ssize_t shutdown_enable_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - - if (count < 1) - return -EINVAL; - - switch (buf[0]) { - case '0': - shutdown_enable = 0; - break; - case '3': - shutdown_enable = 3; - break; - case '4': - shutdown_enable = 4; - break; - case '5': - shutdown_enable = 5; - break; - default: - return -EINVAL; - } - - return count; -} - static inline void rgb_lock_leds(struct rgb_sync *rgb) { int i; @@ -2913,7 +2867,6 @@ static DEVICE_ATTR(ramp_step_ms, 0664, NULL, ramp_step_ms_store); static DEVICE_ATTR(lut_flags, 0664, NULL, lut_flags_store); static DEVICE_ATTR(duty_pcts, 0664, NULL, duty_pcts_store); static DEVICE_ATTR(blink, 0664, NULL, blink_store); -static DEVICE_ATTR(enable, 0644, shutdown_enable_show, shutdown_enable_store); static DEVICE_ATTR(rgb_blink, 0664, NULL, rgb_blink_store); static struct attribute *led_attrs[] = { @@ -2933,7 +2886,6 @@ static struct attribute *rgb_blink_attrs[] = { static struct attribute *pwm_attrs[] = { &dev_attr_pwm_us.attr, - &dev_attr_enable.attr, NULL }; @@ -4463,37 +4415,6 @@ static int qpnp_leds_remove(struct platform_device *pdev) return 0; } -static void qpnp_leds_shutdown(struct platform_device *pdev) -{ - struct qpnp_led_data *led_array = dev_get_drvdata(&pdev->dev); - int i, parsed_leds = led_array->num_leds; - - for (i = 0; i < parsed_leds; i++) { - if(led_array[i].id == QPNP_ID_RGB_RED){ - if(shutdown_enable == QPNP_ID_RGB_RED) - led_array[i].cdev.brightness = LED_FULL; - else - led_array[i].cdev.brightness = LED_OFF; - } - else if(led_array[i].id == QPNP_ID_RGB_GREEN){ - if(shutdown_enable == QPNP_ID_RGB_GREEN) - led_array[i].cdev.brightness = LED_FULL; - else - led_array[i].cdev.brightness = LED_OFF; - } - else if(led_array[i].id == QPNP_ID_RGB_BLUE){ - if(shutdown_enable == QPNP_ID_RGB_BLUE) - led_array[i].cdev.brightness = LED_FULL; - else - led_array[i].cdev.brightness = LED_OFF; - } - else - led_array[i].cdev.brightness = LED_OFF; - - __qpnp_led_work(led_array+i, led_array[i].cdev.brightness); - } -} - #ifdef CONFIG_OF static const struct of_device_id spmi_match_table[] = { { .compatible = "qcom,leds-qpnp",}, @@ -4510,7 +4431,6 @@ static struct platform_driver qpnp_leds_driver = { }, .probe = qpnp_leds_probe, .remove = qpnp_leds_remove, - .shutdown = qpnp_leds_shutdown, }; static int __init qpnp_led_init(void)