mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-21 08:19:28 +00:00
watchdog: sp805: Use devm_clk_get_optional()
Replace open coded variants of devm_clk_get_optional(). While at it, drop unneeded OF and ACPI dependency as the APIs in use are provider agnostic. Cc: Srinath Mannam <srinath.mannam@broadcom.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Reviewed-by: Srinath Mannam <srinath.mannam@broadcom.com> Link: https://lore.kernel.org/r/20210517174456.22050-1-andriy.shevchenko@linux.intel.com Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
This commit is contained in:
parent
742b80c561
commit
05f0a994cd
1 changed files with 19 additions and 21 deletions
|
@ -11,7 +11,6 @@
|
||||||
* warranty of any kind, whether express or implied.
|
* warranty of any kind, whether express or implied.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <linux/acpi.h>
|
|
||||||
#include <linux/device.h>
|
#include <linux/device.h>
|
||||||
#include <linux/resource.h>
|
#include <linux/resource.h>
|
||||||
#include <linux/amba/bus.h>
|
#include <linux/amba/bus.h>
|
||||||
|
@ -23,8 +22,8 @@
|
||||||
#include <linux/math64.h>
|
#include <linux/math64.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/moduleparam.h>
|
#include <linux/moduleparam.h>
|
||||||
#include <linux/of.h>
|
|
||||||
#include <linux/pm.h>
|
#include <linux/pm.h>
|
||||||
|
#include <linux/property.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/spinlock.h>
|
#include <linux/spinlock.h>
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
|
@ -231,6 +230,7 @@ static int
|
||||||
sp805_wdt_probe(struct amba_device *adev, const struct amba_id *id)
|
sp805_wdt_probe(struct amba_device *adev, const struct amba_id *id)
|
||||||
{
|
{
|
||||||
struct sp805_wdt *wdt;
|
struct sp805_wdt *wdt;
|
||||||
|
u64 rate = 0;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
wdt = devm_kzalloc(&adev->dev, sizeof(*wdt), GFP_KERNEL);
|
wdt = devm_kzalloc(&adev->dev, sizeof(*wdt), GFP_KERNEL);
|
||||||
|
@ -243,25 +243,23 @@ sp805_wdt_probe(struct amba_device *adev, const struct amba_id *id)
|
||||||
if (IS_ERR(wdt->base))
|
if (IS_ERR(wdt->base))
|
||||||
return PTR_ERR(wdt->base);
|
return PTR_ERR(wdt->base);
|
||||||
|
|
||||||
if (adev->dev.of_node) {
|
/*
|
||||||
wdt->clk = devm_clk_get(&adev->dev, NULL);
|
* When driver probe with ACPI device, clock devices
|
||||||
if (IS_ERR(wdt->clk)) {
|
* are not available, so watchdog rate get from
|
||||||
dev_err(&adev->dev, "Clock not found\n");
|
* clock-frequency property given in _DSD object.
|
||||||
return PTR_ERR(wdt->clk);
|
*/
|
||||||
}
|
device_property_read_u64(&adev->dev, "clock-frequency", &rate);
|
||||||
wdt->rate = clk_get_rate(wdt->clk);
|
|
||||||
} else if (has_acpi_companion(&adev->dev)) {
|
wdt->clk = devm_clk_get_optional(&adev->dev, NULL);
|
||||||
/*
|
if (IS_ERR(wdt->clk))
|
||||||
* When Driver probe with ACPI device, clock devices
|
return dev_err_probe(&adev->dev, PTR_ERR(wdt->clk), "Clock not found\n");
|
||||||
* are not available, so watchdog rate get from
|
|
||||||
* clock-frequency property given in _DSD object.
|
wdt->rate = clk_get_rate(wdt->clk);
|
||||||
*/
|
if (!wdt->rate)
|
||||||
device_property_read_u64(&adev->dev, "clock-frequency",
|
wdt->rate = rate;
|
||||||
&wdt->rate);
|
if (!wdt->rate) {
|
||||||
if (!wdt->rate) {
|
dev_err(&adev->dev, "no clock-frequency property\n");
|
||||||
dev_err(&adev->dev, "no clock-frequency property\n");
|
return -ENODEV;
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wdt->adev = adev;
|
wdt->adev = adev;
|
||||||
|
|
Loading…
Reference in a new issue