hc
2024-05-14 bedbef8ad3e75a304af6361af235302bcc61d06b
kernel/drivers/watchdog/sunxi_wdt.c
....@@ -1,13 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * sunxi Watchdog Driver
34 *
45 * Copyright (c) 2013 Carlo Caione
56 * 2012 Henrik Nordstrom
6
- *
7
- * This program is free software; you can redistribute it and/or
8
- * modify it under the terms of the GNU General Public License
9
- * as published by the Free Software Foundation; either version
10
- * 2 of the License, or (at your option) any later version.
117 *
128 * Based on xen_wdt.c
139 * (c) Copyright 2010 Novell, Inc.
....@@ -233,20 +229,19 @@
233229
234230 static int sunxi_wdt_probe(struct platform_device *pdev)
235231 {
232
+ struct device *dev = &pdev->dev;
236233 struct sunxi_wdt_dev *sunxi_wdt;
237
- struct resource *res;
238234 int err;
239235
240
- sunxi_wdt = devm_kzalloc(&pdev->dev, sizeof(*sunxi_wdt), GFP_KERNEL);
236
+ sunxi_wdt = devm_kzalloc(dev, sizeof(*sunxi_wdt), GFP_KERNEL);
241237 if (!sunxi_wdt)
242
- return -EINVAL;
238
+ return -ENOMEM;
243239
244
- sunxi_wdt->wdt_regs = of_device_get_match_data(&pdev->dev);
240
+ sunxi_wdt->wdt_regs = of_device_get_match_data(dev);
245241 if (!sunxi_wdt->wdt_regs)
246242 return -ENODEV;
247243
248
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
249
- sunxi_wdt->wdt_base = devm_ioremap_resource(&pdev->dev, res);
244
+ sunxi_wdt->wdt_base = devm_platform_ioremap_resource(pdev, 0);
250245 if (IS_ERR(sunxi_wdt->wdt_base))
251246 return PTR_ERR(sunxi_wdt->wdt_base);
252247
....@@ -255,9 +250,9 @@
255250 sunxi_wdt->wdt_dev.timeout = WDT_MAX_TIMEOUT;
256251 sunxi_wdt->wdt_dev.max_timeout = WDT_MAX_TIMEOUT;
257252 sunxi_wdt->wdt_dev.min_timeout = WDT_MIN_TIMEOUT;
258
- sunxi_wdt->wdt_dev.parent = &pdev->dev;
253
+ sunxi_wdt->wdt_dev.parent = dev;
259254
260
- watchdog_init_timeout(&sunxi_wdt->wdt_dev, timeout, &pdev->dev);
255
+ watchdog_init_timeout(&sunxi_wdt->wdt_dev, timeout, dev);
261256 watchdog_set_nowayout(&sunxi_wdt->wdt_dev, nowayout);
262257 watchdog_set_restart_priority(&sunxi_wdt->wdt_dev, 128);
263258
....@@ -266,12 +261,12 @@
266261 sunxi_wdt_stop(&sunxi_wdt->wdt_dev);
267262
268263 watchdog_stop_on_reboot(&sunxi_wdt->wdt_dev);
269
- err = devm_watchdog_register_device(&pdev->dev, &sunxi_wdt->wdt_dev);
264
+ err = devm_watchdog_register_device(dev, &sunxi_wdt->wdt_dev);
270265 if (unlikely(err))
271266 return err;
272267
273
- dev_info(&pdev->dev, "Watchdog enabled (timeout=%d sec, nowayout=%d)",
274
- sunxi_wdt->wdt_dev.timeout, nowayout);
268
+ dev_info(dev, "Watchdog enabled (timeout=%d sec, nowayout=%d)",
269
+ sunxi_wdt->wdt_dev.timeout, nowayout);
275270
276271 return 0;
277272 }