kernel: bump 5.4 to 5.4.48
[oweals/openwrt.git] / target / linux / bcm27xx / patches-5.4 / 950-0113-Add-ability-to-export-gpio-used-by-gpio-poweroff.patch
1 From 4c957b11a439d372c26d5f90ef81ec52d1839a0c Mon Sep 17 00:00:00 2001
2 From: Nick Bulleid <nedbulleid@fastmail.com>
3 Date: Thu, 10 May 2018 21:57:02 +0100
4 Subject: [PATCH] Add ability to export gpio used by gpio-poweroff
5
6 Signed-off-by: Nick Bulleid <nedbulleid@fastmail.com>
7
8 Added export feature to gpio-poweroff documentation
9
10 Signed-off-by: Nick Bulleid <nedbulleid@fastmail.com>
11 ---
12  .../devicetree/bindings/power/reset/gpio-poweroff.txt    | 1 +
13  drivers/power/reset/gpio-poweroff.c                      | 9 +++++++++
14  2 files changed, 10 insertions(+)
15
16 --- a/Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt
17 +++ b/Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt
18 @@ -31,6 +31,7 @@ Optional properties:
19  - inactive-delay-ms: Delay (default 100) to wait after driving gpio inactive
20  - timeout-ms: Time to wait before asserting a WARN_ON(1). If nothing is
21                specified, 3000 ms is used.
22 +- export : Export the GPIO line to the sysfs system
23  
24  Examples:
25  
26 --- a/drivers/power/reset/gpio-poweroff.c
27 +++ b/drivers/power/reset/gpio-poweroff.c
28 @@ -51,6 +51,7 @@ static int gpio_poweroff_probe(struct pl
29         bool input = false;
30         enum gpiod_flags flags;
31         bool force = false;
32 +       bool export = false;
33  
34         /* If a pm_power_off function has already been added, leave it alone */
35         force = of_property_read_bool(pdev->dev.of_node, "force");
36 @@ -76,6 +77,12 @@ static int gpio_poweroff_probe(struct pl
37         if (IS_ERR(reset_gpio))
38                 return PTR_ERR(reset_gpio);
39  
40 +       export = of_property_read_bool(pdev->dev.of_node, "export");
41 +       if (export) {
42 +               gpiod_export(reset_gpio, false);
43 +               gpiod_export_link(&pdev->dev, "poweroff-gpio", reset_gpio);
44 +       }
45 +
46         pm_power_off = &gpio_poweroff_do_poweroff;
47         return 0;
48  }
49 @@ -85,6 +92,8 @@ static int gpio_poweroff_remove(struct p
50         if (pm_power_off == &gpio_poweroff_do_poweroff)
51                 pm_power_off = NULL;
52  
53 +       gpiod_unexport(reset_gpio);
54 +
55         return 0;
56  }
57