|
26 | 26 | #include <linux/spinlock.h>
|
27 | 27 | #include <linux/io.h>
|
28 | 28 | #include <linux/slab.h>
|
| 29 | +#include <linux/property.h> |
29 | 30 |
|
30 | 31 | #define DEFAULT_HEARTBEAT 60
|
31 | 32 | #define MAX_HEARTBEAT 60
|
@@ -99,8 +100,8 @@ static const struct max63xx_timeout max6373_table[] = {
|
99 | 100 | { },
|
100 | 101 | };
|
101 | 102 |
|
102 |
| -static struct max63xx_timeout * |
103 |
| -max63xx_select_timeout(struct max63xx_timeout *table, int value) |
| 103 | +static const struct max63xx_timeout * |
| 104 | +max63xx_select_timeout(const struct max63xx_timeout *table, int value) |
104 | 105 | {
|
105 | 106 | while (table->twd) {
|
106 | 107 | if (value <= table->twd) {
|
@@ -202,14 +203,17 @@ static int max63xx_wdt_probe(struct platform_device *pdev)
|
202 | 203 | {
|
203 | 204 | struct device *dev = &pdev->dev;
|
204 | 205 | struct max63xx_wdt *wdt;
|
205 |
| - struct max63xx_timeout *table; |
| 206 | + const struct max63xx_timeout *table; |
206 | 207 | int err;
|
207 | 208 |
|
208 | 209 | wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL);
|
209 | 210 | if (!wdt)
|
210 | 211 | return -ENOMEM;
|
211 | 212 |
|
212 |
| - table = (struct max63xx_timeout *)pdev->id_entry->driver_data; |
| 213 | + /* Attempt to use fwnode first */ |
| 214 | + table = device_get_match_data(dev); |
| 215 | + if (!table) |
| 216 | + table = (struct max63xx_timeout *)pdev->id_entry->driver_data; |
213 | 217 |
|
214 | 218 | if (heartbeat < 1 || heartbeat > MAX_HEARTBEAT)
|
215 | 219 | heartbeat = DEFAULT_HEARTBEAT;
|
@@ -255,11 +259,23 @@ static const struct platform_device_id max63xx_id_table[] = {
|
255 | 259 | };
|
256 | 260 | MODULE_DEVICE_TABLE(platform, max63xx_id_table);
|
257 | 261 |
|
| 262 | +static const struct of_device_id max63xx_dt_id_table[] = { |
| 263 | + { .compatible = "maxim,max6369", .data = max6369_table, }, |
| 264 | + { .compatible = "maxim,max6370", .data = max6369_table, }, |
| 265 | + { .compatible = "maxim,max6371", .data = max6371_table, }, |
| 266 | + { .compatible = "maxim,max6372", .data = max6371_table, }, |
| 267 | + { .compatible = "maxim,max6373", .data = max6373_table, }, |
| 268 | + { .compatible = "maxim,max6374", .data = max6373_table, }, |
| 269 | + { } |
| 270 | +}; |
| 271 | +MODULE_DEVICE_TABLE(of, max63xx_dt_id_table); |
| 272 | + |
258 | 273 | static struct platform_driver max63xx_wdt_driver = {
|
259 | 274 | .probe = max63xx_wdt_probe,
|
260 | 275 | .id_table = max63xx_id_table,
|
261 | 276 | .driver = {
|
262 | 277 | .name = "max63xx_wdt",
|
| 278 | + .of_match_table = max63xx_dt_id_table, |
263 | 279 | },
|
264 | 280 | };
|
265 | 281 |
|
|
0 commit comments