w1-gpio.c (1071ec7bc2dabd0a9d12a1ae5570f4fd3ba944ca) w1-gpio.c (c853b167e6ec1f25023cfc58ba2f43f9f6f5b49b)
1/*
2 * w1-gpio - GPIO w1 bus master driver
3 *
4 * Copyright (C) 2007 Ville Syrjala <syrjala@sci.fi>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2
8 * as published by the Free Software Foundation.

--- 42 unchanged lines hidden (view full) ---

51 { .compatible = "w1-gpio" },
52 {}
53};
54MODULE_DEVICE_TABLE(of, w1_gpio_dt_ids);
55#endif
56
57static int w1_gpio_probe_dt(struct platform_device *pdev)
58{
1/*
2 * w1-gpio - GPIO w1 bus master driver
3 *
4 * Copyright (C) 2007 Ville Syrjala <syrjala@sci.fi>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2
8 * as published by the Free Software Foundation.

--- 42 unchanged lines hidden (view full) ---

51 { .compatible = "w1-gpio" },
52 {}
53};
54MODULE_DEVICE_TABLE(of, w1_gpio_dt_ids);
55#endif
56
57static int w1_gpio_probe_dt(struct platform_device *pdev)
58{
59 struct w1_gpio_platform_data *pdata = pdev->dev.platform_data;
59 struct w1_gpio_platform_data *pdata = dev_get_platdata(&pdev->dev);
60 struct device_node *np = pdev->dev.of_node;
61 int gpio;
62
63 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
64 if (!pdata)
65 return -ENOMEM;
66
67 if (of_get_property(np, "linux,open-drain", NULL))

--- 19 unchanged lines hidden (view full) ---

87 if (of_have_populated_dt()) {
88 err = w1_gpio_probe_dt(pdev);
89 if (err < 0) {
90 dev_err(&pdev->dev, "Failed to parse DT\n");
91 return err;
92 }
93 }
94
60 struct device_node *np = pdev->dev.of_node;
61 int gpio;
62
63 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
64 if (!pdata)
65 return -ENOMEM;
66
67 if (of_get_property(np, "linux,open-drain", NULL))

--- 19 unchanged lines hidden (view full) ---

87 if (of_have_populated_dt()) {
88 err = w1_gpio_probe_dt(pdev);
89 if (err < 0) {
90 dev_err(&pdev->dev, "Failed to parse DT\n");
91 return err;
92 }
93 }
94
95 pdata = pdev->dev.platform_data;
95 pdata = dev_get_platdata(&pdev->dev);
96
97 if (!pdata) {
98 dev_err(&pdev->dev, "No configuration data\n");
99 return -ENXIO;
100 }
101
102 master = devm_kzalloc(&pdev->dev, sizeof(struct w1_bus_master),
103 GFP_KERNEL);

--- 45 unchanged lines hidden (view full) ---

149 platform_set_drvdata(pdev, master);
150
151 return 0;
152}
153
154static int w1_gpio_remove(struct platform_device *pdev)
155{
156 struct w1_bus_master *master = platform_get_drvdata(pdev);
96
97 if (!pdata) {
98 dev_err(&pdev->dev, "No configuration data\n");
99 return -ENXIO;
100 }
101
102 master = devm_kzalloc(&pdev->dev, sizeof(struct w1_bus_master),
103 GFP_KERNEL);

--- 45 unchanged lines hidden (view full) ---

149 platform_set_drvdata(pdev, master);
150
151 return 0;
152}
153
154static int w1_gpio_remove(struct platform_device *pdev)
155{
156 struct w1_bus_master *master = platform_get_drvdata(pdev);
157 struct w1_gpio_platform_data *pdata = pdev->dev.platform_data;
157 struct w1_gpio_platform_data *pdata = dev_get_platdata(&pdev->dev);
158
159 if (pdata->enable_external_pullup)
160 pdata->enable_external_pullup(0);
161
162 if (gpio_is_valid(pdata->ext_pullup_enable_pin))
163 gpio_set_value(pdata->ext_pullup_enable_pin, 0);
164
165 w1_remove_master_device(master);
166
167 return 0;
168}
169
170#ifdef CONFIG_PM
171
172static int w1_gpio_suspend(struct platform_device *pdev, pm_message_t state)
173{
158
159 if (pdata->enable_external_pullup)
160 pdata->enable_external_pullup(0);
161
162 if (gpio_is_valid(pdata->ext_pullup_enable_pin))
163 gpio_set_value(pdata->ext_pullup_enable_pin, 0);
164
165 w1_remove_master_device(master);
166
167 return 0;
168}
169
170#ifdef CONFIG_PM
171
172static int w1_gpio_suspend(struct platform_device *pdev, pm_message_t state)
173{
174 struct w1_gpio_platform_data *pdata = pdev->dev.platform_data;
174 struct w1_gpio_platform_data *pdata = dev_get_platdata(&pdev->dev);
175
176 if (pdata->enable_external_pullup)
177 pdata->enable_external_pullup(0);
178
179 return 0;
180}
181
182static int w1_gpio_resume(struct platform_device *pdev)
183{
175
176 if (pdata->enable_external_pullup)
177 pdata->enable_external_pullup(0);
178
179 return 0;
180}
181
182static int w1_gpio_resume(struct platform_device *pdev)
183{
184 struct w1_gpio_platform_data *pdata = pdev->dev.platform_data;
184 struct w1_gpio_platform_data *pdata = dev_get_platdata(&pdev->dev);
185
186 if (pdata->enable_external_pullup)
187 pdata->enable_external_pullup(1);
188
189 return 0;
190}
191
192#else

--- 21 unchanged lines hidden ---
185
186 if (pdata->enable_external_pullup)
187 pdata->enable_external_pullup(1);
188
189 return 0;
190}
191
192#else

--- 21 unchanged lines hidden ---