Rebased from upstream / out of band repository.
[librecmc/librecmc.git] / target / linux / generic / pending-4.14 / 0931-w1-gpio-fix-problem-with-platfom-data-in-w1-gpio.patch
1 From d9c8bc8c1408f3e8529db6e4e04017b4c579c342 Mon Sep 17 00:00:00 2001
2 From: Pawel Dembicki <paweldembicki@gmail.com>
3 Date: Sun, 18 Feb 2018 17:08:04 +0100
4 Subject: [PATCH] w1: gpio: fix problem with platfom data in w1-gpio
5
6 In devices, where fdt is used, is impossible to apply platform data
7 without proper fdt node.
8
9 This patch allow to use platform data in devices with fdt.
10
11 Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
12 ---
13  drivers/w1/masters/w1-gpio.c | 7 +++----
14  1 file changed, 3 insertions(+), 4 deletions(-)
15
16 --- a/drivers/w1/masters/w1-gpio.c
17 +++ b/drivers/w1/masters/w1-gpio.c
18 @@ -112,17 +112,16 @@ static int w1_gpio_probe_dt(struct platf
19  static int w1_gpio_probe(struct platform_device *pdev)
20  {
21         struct w1_bus_master *master;
22 -       struct w1_gpio_platform_data *pdata;
23 +       struct w1_gpio_platform_data *pdata = dev_get_platdata(&pdev->dev);
24         int err;
25  
26 -       if (of_have_populated_dt()) {
27 +       if (of_have_populated_dt() && !pdata) {
28                 err = w1_gpio_probe_dt(pdev);
29                 if (err < 0)
30                         return err;
31 +               pdata = dev_get_platdata(&pdev->dev);
32         }
33  
34 -       pdata = dev_get_platdata(&pdev->dev);
35 -
36         if (!pdata) {
37                 dev_err(&pdev->dev, "No configuration data\n");
38                 return -ENXIO;