Commit 3b6aa907f316a51345987327083aa266870d06cc

Authored by Jingoo Han
Committed by Linus Torvalds
1 parent caa3af259d

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: Jingoo Han <jg1.han@samsung.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 5 additions and 20 deletions Side-by-side Diff

drivers/rtc/rtc-jz4740.c
... ... @@ -38,7 +38,6 @@
38 38 #define JZ_RTC_CTRL_ENABLE BIT(0)
39 39  
40 40 struct jz4740_rtc {
41   - struct resource *mem;
42 41 void __iomem *base;
43 42  
44 43 struct rtc_device *rtc;
... ... @@ -216,6 +215,7 @@
216 215 int ret;
217 216 struct jz4740_rtc *rtc;
218 217 uint32_t scratchpad;
  218 + struct resource *mem;
219 219  
220 220 rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL);
221 221 if (!rtc)
... ... @@ -227,25 +227,10 @@
227 227 return -ENOENT;
228 228 }
229 229  
230   - rtc->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
231   - if (!rtc->mem) {
232   - dev_err(&pdev->dev, "Failed to get platform mmio memory\n");
233   - return -ENOENT;
234   - }
235   -
236   - rtc->mem = devm_request_mem_region(&pdev->dev, rtc->mem->start,
237   - resource_size(rtc->mem), pdev->name);
238   - if (!rtc->mem) {
239   - dev_err(&pdev->dev, "Failed to request mmio memory region\n");
240   - return -EBUSY;
241   - }
242   -
243   - rtc->base = devm_ioremap_nocache(&pdev->dev, rtc->mem->start,
244   - resource_size(rtc->mem));
245   - if (!rtc->base) {
246   - dev_err(&pdev->dev, "Failed to ioremap mmio memory\n");
247   - return -EBUSY;
248   - }
  230 + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  231 + rtc->base = devm_ioremap_resource(&pdev->dev, mem);
  232 + if (IS_ERR(rtc->base))
  233 + return PTR_ERR(rtc->base);
249 234  
250 235 spin_lock_init(&rtc->lock);
251 236