diff options
author | Davide Garberi <dade.garberi@gmail.com> | 2020-04-28 08:55:21 +0200 |
---|---|---|
committer | Michael Bestas <mkbestas@lineageos.org> | 2020-05-01 18:21:36 +0300 |
commit | 3ade4980dd8e960be06b80808f9dc4737bdf46d8 (patch) | |
tree | d93d3b86c8b1b846cbc1153a9411306490a2a945 /drivers | |
parent | 8287b3013efcad569b7a65226eafaaa12639c3fc (diff) |
input: hall_e7s: Cleanup a bit
* Just clean the coding style and indentation a little bit
Change-Id: I1e1e6ab911071c94fd1f9a1c02c9cae577265212
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/input/hall_e7s.c | 120 |
1 files changed, 35 insertions, 85 deletions
diff --git a/drivers/input/hall_e7s.c b/drivers/input/hall_e7s.c index 23ce56a5ce53..172087f54089 100644 --- a/drivers/input/hall_e7s.c +++ b/drivers/input/hall_e7s.c @@ -1,4 +1,4 @@ -#include <linux/init.h> +#include <linux/init.h> #include <linux/miscdevice.h> #include <linux/module.h> #include <linux/kernel.h> @@ -14,7 +14,7 @@ #include <linux/workqueue.h> #include <linux/mutex.h> #include <linux/regulator/consumer.h> -#include <linux/jiffies.h> +#include <linux/jiffies.h> #include <linux/fb.h> /*add by Wenke Ma, for hall switch key code*/ @@ -49,23 +49,20 @@ static void hall_irq_event_workfunc(struct work_struct *work) pr_err("Macle hall gpio state = %d\n",global_hall_info->hall_switch_state); hall_gpio = gpio_get_value_cansleep(global_hall_info->irq_gpio); pr_err("Macle hall irq interrupt gpio = %d\n", hall_gpio); - if(hall_gpio == global_hall_info->hall_switch_state){ + if (hall_gpio == global_hall_info->hall_switch_state) { enable_irq(global_hall_info->irq); return; - }else{ + } else { global_hall_info->hall_switch_state = hall_gpio; pr_err("Macle hall report key s "); } - if (hall_gpio) { - - - input_report_switch(global_hall_info->ipdev, SW_LID, 0); - input_sync(global_hall_info->ipdev); - }else{ - - input_report_switch(global_hall_info->ipdev, SW_LID, 1); - input_sync(global_hall_info->ipdev); + if (hall_gpio) { + input_report_switch(global_hall_info->ipdev, SW_LID, 0); + input_sync(global_hall_info->ipdev); + } else { + input_report_switch(global_hall_info->ipdev, SW_LID, 1); + input_sync(global_hall_info->ipdev); } enable_irq(global_hall_info->irq); pr_err("Macle hall en irq\n"); @@ -74,11 +71,10 @@ static void hall_irq_event_workfunc(struct work_struct *work) static irqreturn_t hall_interrupt(int irq, void *data) { - disable_irq_nosync(irq); queue_delayed_work(hall_irq_event_wq, &hall_irq_event_work, msecs_to_jiffies(200)); - return IRQ_HANDLED; + return IRQ_HANDLED; } static int hall_parse_dt(struct device *dev, struct hall_switch_info *pdata) @@ -100,70 +96,43 @@ static int hall_power_on(struct device *pdev) int ret = 0; struct regulator *hall_vio; - #if 0 - hall_vdd = regulator_get(pdev, "vdd"); - if (IS_ERR(hall_vdd)) { - ret = -1; - dev_err(pdev, "Regulator get failed vdd ret=%d\n", ret); - return ret; - } - - if (regulator_count_voltages(hall_vdd) > 0) { - ret = regulator_set_voltage(hall_vdd, 2850000, 2850000); - if (ret) { - dev_err(pdev, "Regulator set_vtg failed vdd ret=%d\n", ret); - goto reg_vdd_put; - } - } - - ret = regulator_enable(hall_vdd); - if (ret) { - dev_err(pdev, "Regulator vdd enable failed ret=%d\n", ret); - return ret; - } - #endif - #if 1 hall_vio = regulator_get(pdev, "vdd-io"); if (IS_ERR(hall_vio)) { ret = -1; dev_err(pdev, "Regulator get failed vio ret=%d\n", ret); return ret; } - + if (regulator_count_voltages(hall_vio) > 0) { ret = regulator_set_voltage(hall_vio, 1800000, 1800000); if (ret) { - dev_err(pdev, "Regulator set_vtg failed vio ret=%d\n", ret); + dev_err(pdev, "Regulator set_vtg failed vio ret=%d\n", ret); goto reg_vio_put; } } - ret = regulator_enable(hall_vio); + ret = regulator_enable(hall_vio); if (ret) { dev_err(pdev, "Regulator vio enable failed ret=%d\n", ret); return ret; } - #endif - return ret; reg_vio_put: regulator_put(hall_vio); - - return ret; } #ifdef CONFIG_HALL_SYS static ssize_t hall_state_show(struct class *class, struct class_attribute *attr, char *buf) -{ +{ int state; - if (global_hall_info->hall_switch_state) { + if (global_hall_info->hall_switch_state) state = 3; - }else{ + else state = 2; - } + pr_err("Macle hall_state_show state = %d, custome_state=%d\n", global_hall_info->hall_switch_state, state); return sprintf(buf, "%d\n", state); } @@ -197,9 +166,9 @@ static int hall_probe(struct platform_device *pdev) int err; struct hall_switch_info *hall_info; pr_err("Macle hall_probe\n"); - + if (pdev->dev.of_node) { - hall_info = kzalloc(sizeof(struct hall_switch_info), GFP_KERNEL); + hall_info = kzalloc(sizeof(struct hall_switch_info), GFP_KERNEL); if (!hall_info) { pr_err("Macle %s:hall failed to alloc memory for module data\n",__func__); return -ENOMEM; @@ -216,7 +185,7 @@ static int hall_probe(struct platform_device *pdev) platform_set_drvdata(pdev, hall_info); -/*input system config*/ + /* input system config */ hall_info->ipdev = input_allocate_device(); if (!hall_info->ipdev) { pr_err("hall_probe: input_allocate_device fail\n"); @@ -234,27 +203,26 @@ static int hall_probe(struct platform_device *pdev) } hall_power_on(&pdev->dev); - - -/*interrupt config*/ + + /* interrupt config */ if (gpio_is_valid(hall_info->irq_gpio)) { rc = gpio_request(hall_info->irq_gpio, "hall-switch-gpio"); if (rc < 0) { - pr_err("hall_probe: gpio_request fail rc=%d\n", rc); - goto free_input_device; + pr_err("hall_probe: gpio_request fail rc=%d\n", rc); + goto free_input_device; } rc = gpio_direction_input(hall_info->irq_gpio); if (rc < 0) { - pr_err("hall_probe: gpio_direction_input fail rc=%d\n", rc); - goto err_irq; + pr_err("hall_probe: gpio_direction_input fail rc=%d\n", rc); + goto err_irq; } hall_info->hall_switch_state = gpio_get_value(hall_info->irq_gpio); pr_err("hall_probe: gpios = %d, gpion=%d\n", hall_info->hall_switch_state, hall_info->hall_switch_state); hall_info->irq = gpio_to_irq(hall_info->irq_gpio); pr_err("Macle hall irq = %d\n", hall_info->irq); - + rc = devm_request_threaded_irq(&pdev->dev, hall_info->irq, NULL, hall_interrupt, IRQF_TRIGGER_RISING|IRQF_TRIGGER_FALLING|IRQF_ONESHOT, "hall-switch-irq", hall_info); @@ -264,20 +232,20 @@ static int hall_probe(struct platform_device *pdev) } device_init_wakeup(&pdev->dev, true); irq_set_irq_wake(hall_info->irq,1); - - }else{ + + } else { pr_err("Macle hall irq gpio not provided\n"); - goto free_input_device; + goto free_input_device; } INIT_DELAYED_WORK(&hall_irq_event_work, hall_irq_event_workfunc); hall_irq_event_wq = create_workqueue("hall_irq_event_wq"); - pr_err("hall_probe end\n"); + pr_err("hall_probe end\n"); #ifdef CONFIG_HALL_SYS hall_register_class_dev(hall_info); #endif - global_hall_info = hall_info; - return 0; + global_hall_info = hall_info; + return 0; err_irq: disable_irq_wake(hall_info->irq); device_init_wakeup(&pdev->dev, 0); @@ -310,12 +278,10 @@ static int hall_remove(struct platform_device *pdev) return 0; } - - static struct of_device_id sn_match_table[] = { { .compatible = "hall-switch,och175", }, { }, -}; +}; static struct platform_driver hall_driver = { .probe = hall_probe, @@ -329,21 +295,7 @@ static struct platform_driver hall_driver = { static int __init hall_init(void) { - - - - - - - - - - return platform_driver_register(&hall_driver); - - - - } static void __exit hall_exit(void) @@ -351,8 +303,6 @@ static void __exit hall_exit(void) platform_driver_unregister(&hall_driver); } - - module_init(hall_init); module_exit(hall_exit); MODULE_LICENSE("GPL v2"); |