hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/leds/leds-s3c24xx.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /* drivers/leds/leds-s3c24xx.c
23 *
34 * (c) 2006 Simtec Electronics
....@@ -5,28 +6,22 @@
56 * Ben Dooks <ben@simtec.co.uk>
67 *
78 * S3C24XX - LEDs GPIO driver
8
- *
9
- * This program is free software; you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License version 2 as
11
- * published by the Free Software Foundation.
129 */
1310
1411 #include <linux/kernel.h>
1512 #include <linux/platform_device.h>
1613 #include <linux/leds.h>
17
-#include <linux/gpio.h>
14
+#include <linux/gpio/consumer.h>
1815 #include <linux/slab.h>
1916 #include <linux/module.h>
2017 #include <linux/platform_data/leds-s3c24xx.h>
21
-
22
-#include <mach/regs-gpio.h>
23
-#include <plat/gpio-cfg.h>
2418
2519 /* our context */
2620
2721 struct s3c24xx_gpio_led {
2822 struct led_classdev cdev;
2923 struct s3c24xx_led_platdata *pdata;
24
+ struct gpio_desc *gpiod;
3025 };
3126
3227 static inline struct s3c24xx_gpio_led *to_gpio(struct led_classdev *led_cdev)
....@@ -38,20 +33,8 @@
3833 enum led_brightness value)
3934 {
4035 struct s3c24xx_gpio_led *led = to_gpio(led_cdev);
41
- struct s3c24xx_led_platdata *pd = led->pdata;
42
- int state = (value ? 1 : 0) ^ (pd->flags & S3C24XX_LEDF_ACTLOW);
4336
44
- /* there will be a short delay between setting the output and
45
- * going from output to input when using tristate. */
46
-
47
- gpio_set_value(pd->gpio, state);
48
-
49
- if (pd->flags & S3C24XX_LEDF_TRISTATE) {
50
- if (value)
51
- gpio_direction_output(pd->gpio, state);
52
- else
53
- gpio_direction_input(pd->gpio);
54
- }
37
+ gpiod_set_value(led->gpiod, !!value);
5538 }
5639
5740 static int s3c24xx_led_probe(struct platform_device *dev)
....@@ -72,22 +55,12 @@
7255
7356 led->pdata = pdata;
7457
75
- ret = devm_gpio_request(&dev->dev, pdata->gpio, "S3C24XX_LED");
76
- if (ret < 0)
77
- return ret;
78
-
79
- /* no point in having a pull-up if we are always driving */
80
-
81
- s3c_gpio_setpull(pdata->gpio, S3C_GPIO_PULL_NONE);
82
-
83
- if (pdata->flags & S3C24XX_LEDF_TRISTATE)
84
- gpio_direction_input(pdata->gpio);
85
- else
86
- gpio_direction_output(pdata->gpio,
87
- pdata->flags & S3C24XX_LEDF_ACTLOW ? 1 : 0);
58
+ /* Default to off */
59
+ led->gpiod = devm_gpiod_get(&dev->dev, NULL, GPIOD_OUT_LOW);
60
+ if (IS_ERR(led->gpiod))
61
+ return PTR_ERR(led->gpiod);
8862
8963 /* register our new led device */
90
-
9164 ret = devm_led_classdev_register(&dev->dev, &led->cdev);
9265 if (ret < 0)
9366 dev_err(&dev->dev, "led_classdev_register failed\n");