Commit 3b6aa907 authored by Jingoo Han's avatar Jingoo Han Committed by Linus Torvalds

rtc: rtc-jz4740: use devm_ioremap_resource()

Use devm_ioremap_resource() in order to make the code simpler, and move
'struct resource *mem' from 'struct jz4740_rtc' to jz4740_rtc_probe()
because the 'mem' variable is used only in jz4740_rtc_probe().  Also the
redundant return value check of platform_get_resource() is removed,
because the value is checked by devm_ioremap_resource().
Signed-off-by: default avatarJingoo Han <jg1.han@samsung.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent caa3af25
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
#define JZ_RTC_CTRL_ENABLE BIT(0) #define JZ_RTC_CTRL_ENABLE BIT(0)
struct jz4740_rtc { struct jz4740_rtc {
struct resource *mem;
void __iomem *base; void __iomem *base;
struct rtc_device *rtc; struct rtc_device *rtc;
...@@ -216,6 +215,7 @@ static int jz4740_rtc_probe(struct platform_device *pdev) ...@@ -216,6 +215,7 @@ static int jz4740_rtc_probe(struct platform_device *pdev)
int ret; int ret;
struct jz4740_rtc *rtc; struct jz4740_rtc *rtc;
uint32_t scratchpad; uint32_t scratchpad;
struct resource *mem;
rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL); rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL);
if (!rtc) if (!rtc)
...@@ -227,25 +227,10 @@ static int jz4740_rtc_probe(struct platform_device *pdev) ...@@ -227,25 +227,10 @@ static int jz4740_rtc_probe(struct platform_device *pdev)
return -ENOENT; return -ENOENT;
} }
rtc->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!rtc->mem) { rtc->base = devm_ioremap_resource(&pdev->dev, mem);
dev_err(&pdev->dev, "Failed to get platform mmio memory\n"); if (IS_ERR(rtc->base))
return -ENOENT; return PTR_ERR(rtc->base);
}
rtc->mem = devm_request_mem_region(&pdev->dev, rtc->mem->start,
resource_size(rtc->mem), pdev->name);
if (!rtc->mem) {
dev_err(&pdev->dev, "Failed to request mmio memory region\n");
return -EBUSY;
}
rtc->base = devm_ioremap_nocache(&pdev->dev, rtc->mem->start,
resource_size(rtc->mem));
if (!rtc->base) {
dev_err(&pdev->dev, "Failed to ioremap mmio memory\n");
return -EBUSY;
}
spin_lock_init(&rtc->lock); spin_lock_init(&rtc->lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment