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>wifi-calibration
parent
9ebf1855db
commit
aaaac9ec79
|
@ -313,12 +313,32 @@ static const struct of_device_id orion_wdt_of_match_table[] = {
|
||||||
};
|
};
|
||||||
MODULE_DEVICE_TABLE(of, orion_wdt_of_match_table);
|
MODULE_DEVICE_TABLE(of, orion_wdt_of_match_table);
|
||||||
|
|
||||||
|
static int orion_wdt_get_regs(struct platform_device *pdev,
|
||||||
|
struct orion_watchdog *dev)
|
||||||
|
{
|
||||||
|
struct resource *res;
|
||||||
|
|
||||||
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||||
|
if (!res)
|
||||||
|
return -ENODEV;
|
||||||
|
dev->reg = devm_ioremap(&pdev->dev, res->start,
|
||||||
|
resource_size(res));
|
||||||
|
if (!dev->reg)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
dev->rstout = orion_wdt_ioremap_rstout(pdev, res->start &
|
||||||
|
INTERNAL_REGS_MASK);
|
||||||
|
if (!dev->rstout)
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int orion_wdt_probe(struct platform_device *pdev)
|
static int orion_wdt_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct orion_watchdog *dev;
|
struct orion_watchdog *dev;
|
||||||
const struct of_device_id *match;
|
const struct of_device_id *match;
|
||||||
unsigned int wdt_max_duration; /* (seconds) */
|
unsigned int wdt_max_duration; /* (seconds) */
|
||||||
struct resource *res;
|
|
||||||
int ret, irq;
|
int ret, irq;
|
||||||
|
|
||||||
dev = devm_kzalloc(&pdev->dev, sizeof(struct orion_watchdog),
|
dev = devm_kzalloc(&pdev->dev, sizeof(struct orion_watchdog),
|
||||||
|
@ -336,19 +356,9 @@ static int orion_wdt_probe(struct platform_device *pdev)
|
||||||
dev->wdt.min_timeout = 1;
|
dev->wdt.min_timeout = 1;
|
||||||
dev->data = match->data;
|
dev->data = match->data;
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
ret = orion_wdt_get_regs(pdev, dev);
|
||||||
if (!res)
|
if (ret)
|
||||||
return -ENODEV;
|
return ret;
|
||||||
|
|
||||||
dev->reg = devm_ioremap(&pdev->dev, res->start,
|
|
||||||
resource_size(res));
|
|
||||||
if (!dev->reg)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
dev->rstout = orion_wdt_ioremap_rstout(pdev, res->start &
|
|
||||||
INTERNAL_REGS_MASK);
|
|
||||||
if (!dev->rstout)
|
|
||||||
return -ENODEV;
|
|
||||||
|
|
||||||
ret = dev->data->clock_init(pdev, dev);
|
ret = dev->data->clock_init(pdev, dev);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
|
Loading…
Reference in New Issue