hc
2024-05-14 bedbef8ad3e75a304af6361af235302bcc61d06b
kernel/drivers/watchdog/menf21bmc_wdt.c
....@@ -1,12 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * MEN 14F021P00 Board Management Controller (BMC) Watchdog Driver.
34 *
45 * Copyright (C) 2014 MEN Mikro Elektronik Nuernberg GmbH
5
- *
6
- * This program is free software; you can redistribute it and/or modify it
7
- * under the terms of the GNU General Public License as published by the
8
- * Free Software Foundation; either version 2 of the License, or (at your
9
- * option) any later version.
106 */
117
128 #include <linux/kernel.h>
....@@ -117,12 +113,12 @@
117113
118114 static int menf21bmc_wdt_probe(struct platform_device *pdev)
119115 {
116
+ struct device *dev = &pdev->dev;
120117 int ret, bmc_timeout;
121118 struct menf21bmc_wdt *drv_data;
122
- struct i2c_client *i2c_client = to_i2c_client(pdev->dev.parent);
119
+ struct i2c_client *i2c_client = to_i2c_client(dev->parent);
123120
124
- drv_data = devm_kzalloc(&pdev->dev,
125
- sizeof(struct menf21bmc_wdt), GFP_KERNEL);
121
+ drv_data = devm_kzalloc(dev, sizeof(struct menf21bmc_wdt), GFP_KERNEL);
126122 if (!drv_data)
127123 return -ENOMEM;
128124
....@@ -130,7 +126,7 @@
130126 drv_data->wdt.info = &menf21bmc_wdt_info;
131127 drv_data->wdt.min_timeout = BMC_WD_TIMEOUT_MIN;
132128 drv_data->wdt.max_timeout = BMC_WD_TIMEOUT_MAX;
133
- drv_data->wdt.parent = &pdev->dev;
129
+ drv_data->wdt.parent = dev;
134130 drv_data->i2c_client = i2c_client;
135131
136132 /*
....@@ -140,40 +136,26 @@
140136 bmc_timeout = i2c_smbus_read_word_data(drv_data->i2c_client,
141137 BMC_CMD_WD_TIME);
142138 if (bmc_timeout < 0) {
143
- dev_err(&pdev->dev, "failed to get current WDT timeout\n");
139
+ dev_err(dev, "failed to get current WDT timeout\n");
144140 return bmc_timeout;
145141 }
146142
147
- watchdog_init_timeout(&drv_data->wdt, bmc_timeout / 10, &pdev->dev);
143
+ watchdog_init_timeout(&drv_data->wdt, bmc_timeout / 10, dev);
148144 watchdog_set_nowayout(&drv_data->wdt, nowayout);
149145 watchdog_set_drvdata(&drv_data->wdt, drv_data);
150146 platform_set_drvdata(pdev, drv_data);
151147
152148 ret = menf21bmc_wdt_set_bootstatus(drv_data);
153149 if (ret < 0) {
154
- dev_err(&pdev->dev, "failed to set Watchdog bootstatus\n");
150
+ dev_err(dev, "failed to set Watchdog bootstatus\n");
155151 return ret;
156152 }
157153
158
- ret = watchdog_register_device(&drv_data->wdt);
159
- if (ret) {
160
- dev_err(&pdev->dev, "failed to register Watchdog device\n");
154
+ ret = devm_watchdog_register_device(dev, &drv_data->wdt);
155
+ if (ret)
161156 return ret;
162
- }
163157
164
- dev_info(&pdev->dev, "MEN 14F021P00 BMC Watchdog device enabled\n");
165
-
166
- return 0;
167
-}
168
-
169
-static int menf21bmc_wdt_remove(struct platform_device *pdev)
170
-{
171
- struct menf21bmc_wdt *drv_data = platform_get_drvdata(pdev);
172
-
173
- dev_warn(&pdev->dev,
174
- "Unregister MEN 14F021P00 BMC Watchdog device, board may reset\n");
175
-
176
- watchdog_unregister_device(&drv_data->wdt);
158
+ dev_info(dev, "MEN 14F021P00 BMC Watchdog device enabled\n");
177159
178160 return 0;
179161 }
....@@ -191,7 +173,6 @@
191173 .name = DEVNAME,
192174 },
193175 .probe = menf21bmc_wdt_probe,
194
- .remove = menf21bmc_wdt_remove,
195176 .shutdown = menf21bmc_wdt_shutdown,
196177 };
197178