aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds/leds-s3c24xx.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-07-26 23:26:27 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-07-26 23:26:27 -0400
commitaa0b3b2bee1d3ca8355de76caebf65b836c9bb6e (patch)
treee1ba9eb2e96b55af1008162ec662b03ea24f9989 /drivers/leds/leds-s3c24xx.c
parent6ee127b7dd63afe4d6d0a58293786bf4bf336850 (diff)
parentd45bb11616c94c76c6e40960a120c0687b708a2e (diff)
Merge branch 'for-3.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds
Pull LED subsystem update from Bryan Wu. * 'for-3.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds: (50 commits) leds-lp8788: forgotten unlock at lp8788_led_work LEDS: propagate error codes in blinkm_detect() LEDS: memory leak in blinkm_led_common_set() leds: add new lp8788 led driver LEDS: add BlinkM RGB LED driver, documentation and update MAINTAINERS leds: max8997: Simplify max8997_led_set_mode implementation leds/leds-s3c24xx: use devm_gpio_request leds: convert Network Space v2 LED driver to devm_kzalloc() and cleanup error exit path leds: convert DAC124S085 LED driver to devm_kzalloc() leds: convert LM3530 LED driver to devm_kzalloc() and cleanup error exit path leds: convert TCA6507 LED driver to devm_kzalloc() leds: convert Freescale MC13783 LED driver to devm_kzalloc() and cleanup error exit path leds: convert ADP5520 LED driver to devm_kzalloc() and cleanup error exit path leds: convert PCA955x LED driver to devm_kzalloc() and cleanup error exit path leds: convert Sun Fire LED driver to devm_kzalloc() and cleanup error exit path leds: convert PCA9532 LED driver to devm_kzalloc() leds: convert LT3593 LED driver to devm_kzalloc() leds: convert Renesas TPU LED driver to devm_kzalloc() and cleanup error exit path leds: convert LP5523 LED driver to devm_kzalloc() and cleanup error exit path leds: convert PCA9633 LED driver to devm_kzalloc() ...
Diffstat (limited to 'drivers/leds/leds-s3c24xx.c')
-rw-r--r--drivers/leds/leds-s3c24xx.c44
1 files changed, 23 insertions, 21 deletions
diff --git a/drivers/leds/leds-s3c24xx.c b/drivers/leds/leds-s3c24xx.c
index bd0a5ed49c42..942f0ea18178 100644
--- a/drivers/leds/leds-s3c24xx.c
+++ b/drivers/leds/leds-s3c24xx.c
@@ -45,17 +45,19 @@ static void s3c24xx_led_set(struct led_classdev *led_cdev,
45{ 45{
46 struct s3c24xx_gpio_led *led = to_gpio(led_cdev); 46 struct s3c24xx_gpio_led *led = to_gpio(led_cdev);
47 struct s3c24xx_led_platdata *pd = led->pdata; 47 struct s3c24xx_led_platdata *pd = led->pdata;
48 int state = (value ? 1 : 0) ^ (pd->flags & S3C24XX_LEDF_ACTLOW);
48 49
49 /* there will be a short delay between setting the output and 50 /* there will be a short delay between setting the output and
50 * going from output to input when using tristate. */ 51 * going from output to input when using tristate. */
51 52
52 s3c2410_gpio_setpin(pd->gpio, (value ? 1 : 0) ^ 53 gpio_set_value(pd->gpio, state);
53 (pd->flags & S3C24XX_LEDF_ACTLOW));
54
55 if (pd->flags & S3C24XX_LEDF_TRISTATE)
56 s3c2410_gpio_cfgpin(pd->gpio,
57 value ? S3C2410_GPIO_OUTPUT : S3C2410_GPIO_INPUT);
58 54
55 if (pd->flags & S3C24XX_LEDF_TRISTATE) {
56 if (value)
57 gpio_direction_output(pd->gpio, state);
58 else
59 gpio_direction_input(pd->gpio);
60 }
59} 61}
60 62
61static int s3c24xx_led_remove(struct platform_device *dev) 63static int s3c24xx_led_remove(struct platform_device *dev)
@@ -63,7 +65,6 @@ static int s3c24xx_led_remove(struct platform_device *dev)
63 struct s3c24xx_gpio_led *led = pdev_to_gpio(dev); 65 struct s3c24xx_gpio_led *led = pdev_to_gpio(dev);
64 66
65 led_classdev_unregister(&led->cdev); 67 led_classdev_unregister(&led->cdev);
66 kfree(led);
67 68
68 return 0; 69 return 0;
69} 70}
@@ -74,7 +75,8 @@ static int s3c24xx_led_probe(struct platform_device *dev)
74 struct s3c24xx_gpio_led *led; 75 struct s3c24xx_gpio_led *led;
75 int ret; 76 int ret;
76 77
77 led = kzalloc(sizeof(struct s3c24xx_gpio_led), GFP_KERNEL); 78 led = devm_kzalloc(&dev->dev, sizeof(struct s3c24xx_gpio_led),
79 GFP_KERNEL);
78 if (led == NULL) { 80 if (led == NULL) {
79 dev_err(&dev->dev, "No memory for device\n"); 81 dev_err(&dev->dev, "No memory for device\n");
80 return -ENOMEM; 82 return -ENOMEM;
@@ -89,27 +91,27 @@ static int s3c24xx_led_probe(struct platform_device *dev)
89 91
90 led->pdata = pdata; 92 led->pdata = pdata;
91 93
94 ret = devm_gpio_request(&dev->dev, pdata->gpio, "S3C24XX_LED");
95 if (ret < 0)
96 return ret;
97
92 /* no point in having a pull-up if we are always driving */ 98 /* no point in having a pull-up if we are always driving */
93 99
94 if (pdata->flags & S3C24XX_LEDF_TRISTATE) { 100 s3c_gpio_setpull(pdata->gpio, S3C_GPIO_PULL_NONE);
95 s3c2410_gpio_setpin(pdata->gpio, 0); 101
96 s3c2410_gpio_cfgpin(pdata->gpio, S3C2410_GPIO_INPUT); 102 if (pdata->flags & S3C24XX_LEDF_TRISTATE)
97 } else { 103 gpio_direction_input(pdata->gpio);
98 s3c2410_gpio_pullup(pdata->gpio, 0); 104 else
99 s3c2410_gpio_setpin(pdata->gpio, 0); 105 gpio_direction_output(pdata->gpio,
100 s3c2410_gpio_cfgpin(pdata->gpio, S3C2410_GPIO_OUTPUT); 106 pdata->flags & S3C24XX_LEDF_ACTLOW ? 1 : 0);
101 }
102 107
103 /* register our new led device */ 108 /* register our new led device */
104 109
105 ret = led_classdev_register(&dev->dev, &led->cdev); 110 ret = led_classdev_register(&dev->dev, &led->cdev);
106 if (ret < 0) { 111 if (ret < 0)
107 dev_err(&dev->dev, "led_classdev_register failed\n"); 112 dev_err(&dev->dev, "led_classdev_register failed\n");
108 kfree(led);
109 return ret;
110 }
111 113
112 return 0; 114 return ret;
113} 115}
114 116
115static struct platform_driver s3c24xx_led_driver = { 117static struct platform_driver s3c24xx_led_driver = {