sch56xx-common.c (75bf465f0bc33e9b776a46d6a1b9b990f5fb7c37) | sch56xx-common.c (2be5f0d7532566d41194fe99d35d022ad399460d) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-or-later 2/*************************************************************************** 3 * Copyright (C) 2010-2012 Hans de Goede <hdegoede@redhat.com> * 4 * * 5 ***************************************************************************/ 6 7#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 8 --- 364 unchanged lines hidden (view full) --- 373static const struct watchdog_ops watchdog_ops = { 374 .owner = THIS_MODULE, 375 .start = watchdog_start, 376 .stop = watchdog_stop, 377 .ping = watchdog_trigger, 378 .set_timeout = watchdog_set_timeout, 379}; 380 | 1// SPDX-License-Identifier: GPL-2.0-or-later 2/*************************************************************************** 3 * Copyright (C) 2010-2012 Hans de Goede <hdegoede@redhat.com> * 4 * * 5 ***************************************************************************/ 6 7#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 8 --- 364 unchanged lines hidden (view full) --- 373static const struct watchdog_ops watchdog_ops = { 374 .owner = THIS_MODULE, 375 .start = watchdog_start, 376 .stop = watchdog_stop, 377 .ping = watchdog_trigger, 378 .set_timeout = watchdog_set_timeout, 379}; 380 |
381struct sch56xx_watchdog_data *sch56xx_watchdog_register(struct device *parent, 382 u16 addr, u32 revision, struct mutex *io_lock, int check_enabled) | 381void sch56xx_watchdog_register(struct device *parent, u16 addr, u32 revision, 382 struct mutex *io_lock, int check_enabled) |
383{ 384 struct sch56xx_watchdog_data *data; 385 int err, control, output_enable; 386 387 /* Cache the watchdog registers */ 388 mutex_lock(io_lock); 389 control = 390 sch56xx_read_virtual_reg(addr, SCH56XX_REG_WDOG_CONTROL); 391 output_enable = 392 sch56xx_read_virtual_reg(addr, SCH56XX_REG_WDOG_OUTPUT_ENABLE); 393 mutex_unlock(io_lock); 394 395 if (control < 0) | 383{ 384 struct sch56xx_watchdog_data *data; 385 int err, control, output_enable; 386 387 /* Cache the watchdog registers */ 388 mutex_lock(io_lock); 389 control = 390 sch56xx_read_virtual_reg(addr, SCH56XX_REG_WDOG_CONTROL); 391 output_enable = 392 sch56xx_read_virtual_reg(addr, SCH56XX_REG_WDOG_OUTPUT_ENABLE); 393 mutex_unlock(io_lock); 394 395 if (control < 0) |
396 return NULL; | 396 return; |
397 if (output_enable < 0) | 397 if (output_enable < 0) |
398 return NULL; | 398 return; |
399 if (check_enabled && !(output_enable & SCH56XX_WDOG_OUTPUT_ENABLE)) { 400 pr_warn("Watchdog not enabled by BIOS, not registering\n"); | 399 if (check_enabled && !(output_enable & SCH56XX_WDOG_OUTPUT_ENABLE)) { 400 pr_warn("Watchdog not enabled by BIOS, not registering\n"); |
401 return NULL; | 401 return; |
402 } 403 | 402 } 403 |
404 data = kzalloc(sizeof(struct sch56xx_watchdog_data), GFP_KERNEL); | 404 data = devm_kzalloc(parent, sizeof(struct sch56xx_watchdog_data), GFP_KERNEL); |
405 if (!data) | 405 if (!data) |
406 return NULL; | 406 return; |
407 408 data->addr = addr; 409 data->io_lock = io_lock; 410 411 strlcpy(data->wdinfo.identity, "sch56xx watchdog", 412 sizeof(data->wdinfo.identity)); 413 data->wdinfo.firmware_version = revision; 414 data->wdinfo.options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT; --- 18 unchanged lines hidden (view full) --- 433 data->watchdog_preset = 60; /* seconds */ 434 else 435 data->watchdog_preset = 1; /* minute */ 436 437 data->watchdog_control = control; 438 data->watchdog_output_enable = output_enable; 439 440 watchdog_set_drvdata(&data->wddev, data); | 407 408 data->addr = addr; 409 data->io_lock = io_lock; 410 411 strlcpy(data->wdinfo.identity, "sch56xx watchdog", 412 sizeof(data->wdinfo.identity)); 413 data->wdinfo.firmware_version = revision; 414 data->wdinfo.options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT; --- 18 unchanged lines hidden (view full) --- 433 data->watchdog_preset = 60; /* seconds */ 434 else 435 data->watchdog_preset = 1; /* minute */ 436 437 data->watchdog_control = control; 438 data->watchdog_output_enable = output_enable; 439 440 watchdog_set_drvdata(&data->wddev, data); |
441 err = watchdog_register_device(&data->wddev); | 441 err = devm_watchdog_register_device(parent, &data->wddev); |
442 if (err) { 443 pr_err("Registering watchdog chardev: %d\n", err); | 442 if (err) { 443 pr_err("Registering watchdog chardev: %d\n", err); |
444 kfree(data); 445 return NULL; | 444 devm_kfree(parent, data); |
446 } | 445 } |
447 448 return data; | |
449} 450EXPORT_SYMBOL(sch56xx_watchdog_register); 451 | 446} 447EXPORT_SYMBOL(sch56xx_watchdog_register); 448 |
452void sch56xx_watchdog_unregister(struct sch56xx_watchdog_data *data) 453{ 454 watchdog_unregister_device(&data->wddev); 455 kfree(data); 456} 457EXPORT_SYMBOL(sch56xx_watchdog_unregister); 458 | |
459/* 460 * platform dev find, add and remove functions 461 */ 462 463static int __init sch56xx_find(int sioaddr, const char **name) 464{ 465 u8 devid; 466 unsigned short address; --- 110 unchanged lines hidden --- | 449/* 450 * platform dev find, add and remove functions 451 */ 452 453static int __init sch56xx_find(int sioaddr, const char **name) 454{ 455 u8 devid; 456 unsigned short address; --- 110 unchanged lines hidden --- |