watchdog: coh901327_wdt: Use dev variable instead of pdev->dev
Use a local dev variable instead of dereferencing pdev->dev several times in the probe function to make the code easier to read. Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
parent
30c65b22f0
commit
9e14375880
|
@ -251,60 +251,56 @@ static int __exit coh901327_remove(struct platform_device *pdev)
|
||||||
|
|
||||||
static int __init coh901327_probe(struct platform_device *pdev)
|
static int __init coh901327_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
|
struct device *dev = &pdev->dev;
|
||||||
int ret;
|
int ret;
|
||||||
u16 val;
|
u16 val;
|
||||||
struct resource *res;
|
struct resource *res;
|
||||||
|
|
||||||
parent = &pdev->dev;
|
parent = dev;
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||||
virtbase = devm_ioremap_resource(&pdev->dev, res);
|
virtbase = devm_ioremap_resource(dev, res);
|
||||||
if (IS_ERR(virtbase))
|
if (IS_ERR(virtbase))
|
||||||
return PTR_ERR(virtbase);
|
return PTR_ERR(virtbase);
|
||||||
|
|
||||||
clk = clk_get(&pdev->dev, NULL);
|
clk = clk_get(dev, NULL);
|
||||||
if (IS_ERR(clk)) {
|
if (IS_ERR(clk)) {
|
||||||
ret = PTR_ERR(clk);
|
ret = PTR_ERR(clk);
|
||||||
dev_err(&pdev->dev, "could not get clock\n");
|
dev_err(dev, "could not get clock\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
ret = clk_prepare_enable(clk);
|
ret = clk_prepare_enable(clk);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&pdev->dev, "could not prepare and enable clock\n");
|
dev_err(dev, "could not prepare and enable clock\n");
|
||||||
goto out_no_clk_enable;
|
goto out_no_clk_enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
val = readw(virtbase + U300_WDOG_SR);
|
val = readw(virtbase + U300_WDOG_SR);
|
||||||
switch (val) {
|
switch (val) {
|
||||||
case U300_WDOG_SR_STATUS_TIMED_OUT:
|
case U300_WDOG_SR_STATUS_TIMED_OUT:
|
||||||
dev_info(&pdev->dev,
|
dev_info(dev, "watchdog timed out since last chip reset!\n");
|
||||||
"watchdog timed out since last chip reset!\n");
|
|
||||||
coh901327_wdt.bootstatus |= WDIOF_CARDRESET;
|
coh901327_wdt.bootstatus |= WDIOF_CARDRESET;
|
||||||
/* Status will be cleared below */
|
/* Status will be cleared below */
|
||||||
break;
|
break;
|
||||||
case U300_WDOG_SR_STATUS_NORMAL:
|
case U300_WDOG_SR_STATUS_NORMAL:
|
||||||
dev_info(&pdev->dev,
|
dev_info(dev, "in normal status, no timeouts have occurred.\n");
|
||||||
"in normal status, no timeouts have occurred.\n");
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
dev_info(&pdev->dev,
|
dev_info(dev, "contains an illegal status code (%08x)\n", val);
|
||||||
"contains an illegal status code (%08x)\n", val);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
val = readw(virtbase + U300_WDOG_D2R);
|
val = readw(virtbase + U300_WDOG_D2R);
|
||||||
switch (val) {
|
switch (val) {
|
||||||
case U300_WDOG_D2R_DISABLE_STATUS_DISABLED:
|
case U300_WDOG_D2R_DISABLE_STATUS_DISABLED:
|
||||||
dev_info(&pdev->dev, "currently disabled.\n");
|
dev_info(dev, "currently disabled.\n");
|
||||||
break;
|
break;
|
||||||
case U300_WDOG_D2R_DISABLE_STATUS_ENABLED:
|
case U300_WDOG_D2R_DISABLE_STATUS_ENABLED:
|
||||||
dev_info(&pdev->dev,
|
dev_info(dev, "currently enabled! (disabling it now)\n");
|
||||||
"currently enabled! (disabling it now)\n");
|
|
||||||
coh901327_disable();
|
coh901327_disable();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
dev_err(&pdev->dev,
|
dev_err(dev, "contains an illegal enable/disable code (%08x)\n",
|
||||||
"contains an illegal enable/disable code (%08x)\n",
|
|
||||||
val);
|
val);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -319,16 +315,16 @@ static int __init coh901327_probe(struct platform_device *pdev)
|
||||||
goto out_no_irq;
|
goto out_no_irq;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = watchdog_init_timeout(&coh901327_wdt, margin, &pdev->dev);
|
ret = watchdog_init_timeout(&coh901327_wdt, margin, dev);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
coh901327_wdt.timeout = 60;
|
coh901327_wdt.timeout = 60;
|
||||||
|
|
||||||
coh901327_wdt.parent = &pdev->dev;
|
coh901327_wdt.parent = dev;
|
||||||
ret = watchdog_register_device(&coh901327_wdt);
|
ret = watchdog_register_device(&coh901327_wdt);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out_no_wdog;
|
goto out_no_wdog;
|
||||||
|
|
||||||
dev_info(&pdev->dev, "initialized. timer margin=%d sec\n", margin);
|
dev_info(dev, "initialized. timer margin=%d sec\n", margin);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
out_no_wdog:
|
out_no_wdog:
|
||||||
|
|
Loading…
Reference in New Issue