.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Maxim MAX77620 Watchdog Driver |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2016 NVIDIA CORPORATION. All rights reserved. |
---|
5 | 6 | * |
---|
6 | 7 | * Author: Laxman Dewangan <ldewangan@nvidia.com> |
---|
7 | | - * |
---|
8 | | - * This program is free software; you can redistribute it and/or modify |
---|
9 | | - * it under the terms of the GNU General Public License version 2 as |
---|
10 | | - * published by the Free Software Foundation. |
---|
11 | 8 | */ |
---|
12 | 9 | |
---|
13 | 10 | #include <linux/err.h> |
---|
.. | .. |
---|
112 | 109 | |
---|
113 | 110 | static int max77620_wdt_probe(struct platform_device *pdev) |
---|
114 | 111 | { |
---|
| 112 | + struct device *dev = &pdev->dev; |
---|
115 | 113 | struct max77620_wdt *wdt; |
---|
116 | 114 | struct watchdog_device *wdt_dev; |
---|
117 | 115 | unsigned int regval; |
---|
118 | 116 | int ret; |
---|
119 | 117 | |
---|
120 | | - wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); |
---|
| 118 | + wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); |
---|
121 | 119 | if (!wdt) |
---|
122 | 120 | return -ENOMEM; |
---|
123 | 121 | |
---|
124 | | - wdt->dev = &pdev->dev; |
---|
125 | | - wdt->rmap = dev_get_regmap(pdev->dev.parent, NULL); |
---|
| 122 | + wdt->dev = dev; |
---|
| 123 | + wdt->rmap = dev_get_regmap(dev->parent, NULL); |
---|
126 | 124 | if (!wdt->rmap) { |
---|
127 | 125 | dev_err(wdt->dev, "Failed to get parent regmap\n"); |
---|
128 | 126 | return -ENODEV; |
---|
.. | .. |
---|
183 | 181 | watchdog_set_nowayout(wdt_dev, nowayout); |
---|
184 | 182 | watchdog_set_drvdata(wdt_dev, wdt); |
---|
185 | 183 | |
---|
186 | | - ret = watchdog_register_device(wdt_dev); |
---|
187 | | - if (ret < 0) { |
---|
188 | | - dev_err(&pdev->dev, "watchdog registration failed: %d\n", ret); |
---|
189 | | - return ret; |
---|
190 | | - } |
---|
191 | | - |
---|
192 | | - return 0; |
---|
193 | | -} |
---|
194 | | - |
---|
195 | | -static int max77620_wdt_remove(struct platform_device *pdev) |
---|
196 | | -{ |
---|
197 | | - struct max77620_wdt *wdt = platform_get_drvdata(pdev); |
---|
198 | | - |
---|
199 | | - max77620_wdt_stop(&wdt->wdt_dev); |
---|
200 | | - watchdog_unregister_device(&wdt->wdt_dev); |
---|
201 | | - |
---|
202 | | - return 0; |
---|
| 184 | + watchdog_stop_on_unregister(wdt_dev); |
---|
| 185 | + return devm_watchdog_register_device(dev, wdt_dev); |
---|
203 | 186 | } |
---|
204 | 187 | |
---|
205 | 188 | static const struct platform_device_id max77620_wdt_devtype[] = { |
---|
.. | .. |
---|
213 | 196 | .name = "max77620-watchdog", |
---|
214 | 197 | }, |
---|
215 | 198 | .probe = max77620_wdt_probe, |
---|
216 | | - .remove = max77620_wdt_remove, |
---|
217 | 199 | .id_table = max77620_wdt_devtype, |
---|
218 | 200 | }; |
---|
219 | 201 | |
---|