aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds
diff options
context:
space:
mode:
authorSylwester Nawrocki <sylvester.nawrocki@gmail.com>2012-06-30 08:30:26 -0400
committerBryan Wu <bryan.wu@canonical.com>2012-07-23 19:52:36 -0400
commit7d84f66f22cb511b7cb7602b2a9dab20c8906da7 (patch)
tree57aad93f06c63221b82ddf94bccfd8ad536ec58e /drivers/leds
parent7e97b58133b7cddf3be80660300bb2c77c514c6f (diff)
leds: Convert S3C24XX LED driver to gpiolib API
The s3c2410_gpio* calls are obsolete and have been scheduled for removal since several kernel releases. Remove them and use common gpiolib API instead. This patch also adds gpio_request/gpio_free call for API corectness. It is a prerequisite for removal of the S3C24XX SoC specific arch/arm/plat-samsung/include/gpio-fns.h header. Tested on Micro2440-SDK. Cc: Ben Dooks <ben-linux@fluff.org> Signed-off-by: Sylwester Nawrocki <sylvester.nawrocki@gmail.com> Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
Diffstat (limited to 'drivers/leds')
-rw-r--r--drivers/leds/leds-s3c24xx.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/drivers/leds/leds-s3c24xx.c b/drivers/leds/leds-s3c24xx.c
index b816ccb9adf4..e1206407616d 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,6 +65,7 @@ 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);
68 gpio_free(led->pdata->gpio);
66 69
67 return 0; 70 return 0;
68} 71}
@@ -89,16 +92,19 @@ static int s3c24xx_led_probe(struct platform_device *dev)
89 92
90 led->pdata = pdata; 93 led->pdata = pdata;
91 94
95 ret = gpio_request(pdata->gpio, "S3C24XX_LED");
96 if (ret < 0)
97 return ret;
98
92 /* no point in having a pull-up if we are always driving */ 99 /* no point in having a pull-up if we are always driving */
93 100
94 if (pdata->flags & S3C24XX_LEDF_TRISTATE) { 101 s3c_gpio_setpull(pdata->gpio, S3C_GPIO_PULL_NONE);
95 s3c2410_gpio_setpin(pdata->gpio, 0); 102
96 s3c2410_gpio_cfgpin(pdata->gpio, S3C2410_GPIO_INPUT); 103 if (pdata->flags & S3C24XX_LEDF_TRISTATE)
97 } else { 104 gpio_direction_input(pdata->gpio);
98 s3c2410_gpio_pullup(pdata->gpio, 0); 105 else
99 s3c2410_gpio_setpin(pdata->gpio, 0); 106 gpio_direction_output(pdata->gpio,
100 s3c2410_gpio_cfgpin(pdata->gpio, S3C2410_GPIO_OUTPUT); 107 pdata->flags & S3C24XX_LEDF_ACTLOW ? 1 : 0);
101 }
102 108
103 /* register our new led device */ 109 /* register our new led device */
104 110