diff options
author | Ezequiel Garcia <ezequiel.garcia@free-electrons.com> | 2014-03-15 14:17:56 -0400 |
---|---|---|
committer | Wim Van Sebroeck <wim@iguana.be> | 2014-06-10 15:43:54 -0400 |
commit | aaaac9ec79b7c4e21741df35d2247a1187836129 (patch) | |
tree | 9aa06c2fb1f5e21a71d3585c3e3dcd48fadb161a /drivers/watchdog/orion_wdt.c | |
parent | 9ebf1855dbe0a170e45a2000d6f8e16d88b5fd7c (diff) |
watchdog: orion: Move the register ioremap'ing to its own function
Follow-up patches will extend the registers ioremap and request
to handle SoC-specific quirks on the RSTOUT register. Therefore,
in order to keep the code readable, this commit introduces a special
function for this.
Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Jason Cooper <jason@lakedaemon.net>
Tested-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'drivers/watchdog/orion_wdt.c')
-rw-r--r-- | drivers/watchdog/orion_wdt.c | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/drivers/watchdog/orion_wdt.c b/drivers/watchdog/orion_wdt.c index 9b3c41d18703..afa38314fb18 100644 --- a/drivers/watchdog/orion_wdt.c +++ b/drivers/watchdog/orion_wdt.c | |||
@@ -313,12 +313,32 @@ static const struct of_device_id orion_wdt_of_match_table[] = { | |||
313 | }; | 313 | }; |
314 | MODULE_DEVICE_TABLE(of, orion_wdt_of_match_table); | 314 | MODULE_DEVICE_TABLE(of, orion_wdt_of_match_table); |
315 | 315 | ||
316 | static int orion_wdt_get_regs(struct platform_device *pdev, | ||
317 | struct orion_watchdog *dev) | ||
318 | { | ||
319 | struct resource *res; | ||
320 | |||
321 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
322 | if (!res) | ||
323 | return -ENODEV; | ||
324 | dev->reg = devm_ioremap(&pdev->dev, res->start, | ||
325 | resource_size(res)); | ||
326 | if (!dev->reg) | ||
327 | return -ENOMEM; | ||
328 | |||
329 | dev->rstout = orion_wdt_ioremap_rstout(pdev, res->start & | ||
330 | INTERNAL_REGS_MASK); | ||
331 | if (!dev->rstout) | ||
332 | return -ENODEV; | ||
333 | |||
334 | return 0; | ||
335 | } | ||
336 | |||
316 | static int orion_wdt_probe(struct platform_device *pdev) | 337 | static int orion_wdt_probe(struct platform_device *pdev) |
317 | { | 338 | { |
318 | struct orion_watchdog *dev; | 339 | struct orion_watchdog *dev; |
319 | const struct of_device_id *match; | 340 | const struct of_device_id *match; |
320 | unsigned int wdt_max_duration; /* (seconds) */ | 341 | unsigned int wdt_max_duration; /* (seconds) */ |
321 | struct resource *res; | ||
322 | int ret, irq; | 342 | int ret, irq; |
323 | 343 | ||
324 | dev = devm_kzalloc(&pdev->dev, sizeof(struct orion_watchdog), | 344 | dev = devm_kzalloc(&pdev->dev, sizeof(struct orion_watchdog), |
@@ -336,19 +356,9 @@ static int orion_wdt_probe(struct platform_device *pdev) | |||
336 | dev->wdt.min_timeout = 1; | 356 | dev->wdt.min_timeout = 1; |
337 | dev->data = match->data; | 357 | dev->data = match->data; |
338 | 358 | ||
339 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 359 | ret = orion_wdt_get_regs(pdev, dev); |
340 | if (!res) | 360 | if (ret) |
341 | return -ENODEV; | 361 | return ret; |
342 | |||
343 | dev->reg = devm_ioremap(&pdev->dev, res->start, | ||
344 | resource_size(res)); | ||
345 | if (!dev->reg) | ||
346 | return -ENOMEM; | ||
347 | |||
348 | dev->rstout = orion_wdt_ioremap_rstout(pdev, res->start & | ||
349 | INTERNAL_REGS_MASK); | ||
350 | if (!dev->rstout) | ||
351 | return -ENODEV; | ||
352 | 362 | ||
353 | ret = dev->data->clock_init(pdev, dev); | 363 | ret = dev->data->clock_init(pdev, dev); |
354 | if (ret) { | 364 | if (ret) { |