hc
2024-05-14 bedbef8ad3e75a304af6361af235302bcc61d06b
kernel/drivers/watchdog/bcm_kona_wdt.c
....@@ -90,7 +90,7 @@
9090
9191 #ifdef CONFIG_BCM_KONA_WDT_DEBUG
9292
93
-static int bcm_kona_wdt_dbg_show(struct seq_file *s, void *data)
93
+static int bcm_kona_show(struct seq_file *s, void *data)
9494 {
9595 int ctl_val, cur_val;
9696 unsigned long flags;
....@@ -130,17 +130,7 @@
130130 return 0;
131131 }
132132
133
-static int bcm_kona_dbg_open(struct inode *inode, struct file *file)
134
-{
135
- return single_open(file, bcm_kona_wdt_dbg_show, inode->i_private);
136
-}
137
-
138
-static const struct file_operations bcm_kona_dbg_operations = {
139
- .open = bcm_kona_dbg_open,
140
- .read = seq_read,
141
- .llseek = seq_lseek,
142
- .release = single_release,
143
-};
133
+DEFINE_SHOW_ATTRIBUTE(bcm_kona);
144134
145135 static void bcm_kona_wdt_debug_init(struct platform_device *pdev)
146136 {
....@@ -153,24 +143,18 @@
153143 wdt->debugfs = NULL;
154144
155145 dir = debugfs_create_dir(BCM_KONA_WDT_NAME, NULL);
156
- if (IS_ERR_OR_NULL(dir))
157
- return;
158146
159
- if (debugfs_create_file("info", S_IFREG | S_IRUGO, dir, wdt,
160
- &bcm_kona_dbg_operations))
161
- wdt->debugfs = dir;
162
- else
163
- debugfs_remove_recursive(dir);
147
+ debugfs_create_file("info", S_IFREG | S_IRUGO, dir, wdt,
148
+ &bcm_kona_fops);
149
+ wdt->debugfs = dir;
164150 }
165151
166152 static void bcm_kona_wdt_debug_exit(struct platform_device *pdev)
167153 {
168154 struct bcm_kona_wdt *wdt = platform_get_drvdata(pdev);
169155
170
- if (wdt && wdt->debugfs) {
156
+ if (wdt)
171157 debugfs_remove_recursive(wdt->debugfs);
172
- wdt->debugfs = NULL;
173
- }
174158 }
175159
176160 #else
....@@ -281,16 +265,10 @@
281265 .timeout = SECWDOG_MAX_COUNT >> SECWDOG_DEFAULT_RESOLUTION,
282266 };
283267
284
-static void bcm_kona_wdt_shutdown(struct platform_device *pdev)
285
-{
286
- bcm_kona_wdt_stop(&bcm_kona_wdt_wdd);
287
-}
288
-
289268 static int bcm_kona_wdt_probe(struct platform_device *pdev)
290269 {
291270 struct device *dev = &pdev->dev;
292271 struct bcm_kona_wdt *wdt;
293
- struct resource *res;
294272 int ret;
295273
296274 wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL);
....@@ -299,10 +277,9 @@
299277
300278 spin_lock_init(&wdt->lock);
301279
302
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
303
- wdt->base = devm_ioremap_resource(dev, res);
280
+ wdt->base = devm_platform_ioremap_resource(pdev, 0);
304281 if (IS_ERR(wdt->base))
305
- return -ENODEV;
282
+ return PTR_ERR(wdt->base);
306283
307284 wdt->resolution = SECWDOG_DEFAULT_RESOLUTION;
308285 ret = bcm_kona_wdt_set_resolution_reg(wdt);
....@@ -313,7 +290,7 @@
313290
314291 platform_set_drvdata(pdev, wdt);
315292 watchdog_set_drvdata(&bcm_kona_wdt_wdd, wdt);
316
- bcm_kona_wdt_wdd.parent = &pdev->dev;
293
+ bcm_kona_wdt_wdd.parent = dev;
317294
318295 ret = bcm_kona_wdt_set_timeout_reg(&bcm_kona_wdt_wdd, 0);
319296 if (ret) {
....@@ -321,11 +298,11 @@
321298 return ret;
322299 }
323300
324
- ret = watchdog_register_device(&bcm_kona_wdt_wdd);
325
- if (ret) {
326
- dev_err(dev, "Failed to register watchdog device");
301
+ watchdog_stop_on_reboot(&bcm_kona_wdt_wdd);
302
+ watchdog_stop_on_unregister(&bcm_kona_wdt_wdd);
303
+ ret = devm_watchdog_register_device(dev, &bcm_kona_wdt_wdd);
304
+ if (ret)
327305 return ret;
328
- }
329306
330307 bcm_kona_wdt_debug_init(pdev);
331308 dev_dbg(dev, "Broadcom Kona Watchdog Timer");
....@@ -336,8 +313,6 @@
336313 static int bcm_kona_wdt_remove(struct platform_device *pdev)
337314 {
338315 bcm_kona_wdt_debug_exit(pdev);
339
- bcm_kona_wdt_shutdown(pdev);
340
- watchdog_unregister_device(&bcm_kona_wdt_wdd);
341316 dev_dbg(&pdev->dev, "Watchdog driver disabled");
342317
343318 return 0;
....@@ -356,7 +331,6 @@
356331 },
357332 .probe = bcm_kona_wdt_probe,
358333 .remove = bcm_kona_wdt_remove,
359
- .shutdown = bcm_kona_wdt_shutdown,
360334 };
361335
362336 module_platform_driver(bcm_kona_wdt_driver);