]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
sh: heartbeat: Support access size specification via resource flags.
authorPaul Mundt <lethal@linux-sh.org>
Fri, 15 Jan 2010 03:08:31 +0000 (12:08 +0900)
committerPaul Mundt <lethal@linux-sh.org>
Fri, 15 Jan 2010 03:08:31 +0000 (12:08 +0900)
This permits the resource access size to be handed off through the
resource flags, which saves platforms from having to establish
platform data only to specify the register width.

Signed-off-by: Paul Mundt <lethal@linux-sh.org>
arch/sh/drivers/heartbeat.c

index a9339a6174fc5d1fd527a5f6d76e378f2623c5a3..2acbc793032de7da013c16db1c3e1e4eb3ed2c12 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Generic heartbeat driver for regular LED banks
  *
- * Copyright (C) 2007  Paul Mundt
+ * Copyright (C) 2007 - 2010  Paul Mundt
  *
  * Most SH reference boards include a number of individual LEDs that can
  * be independently controlled (either via a pre-defined hardware
@@ -27,7 +27,7 @@
 #include <asm/heartbeat.h>
 
 #define DRV_NAME "heartbeat"
-#define DRV_VERSION "0.1.1"
+#define DRV_VERSION "0.1.2"
 
 static unsigned char default_bit_pos[] = { 0, 1, 2, 3, 4, 5, 6, 7 };
 
@@ -98,7 +98,7 @@ static int heartbeat_drv_probe(struct platform_device *pdev)
                        return -ENOMEM;
        }
 
-       hd->base = ioremap_nocache(res->start, res->end - res->start + 1);
+       hd->base = ioremap_nocache(res->start, resource_size(res));
        if (unlikely(!hd->base)) {
                dev_err(&pdev->dev, "ioremap failed\n");
 
@@ -117,8 +117,20 @@ static int heartbeat_drv_probe(struct platform_device *pdev)
        for (i = 0; i < hd->nr_bits; i++)
                hd->mask |= (1 << hd->bit_pos[i]);
 
-       if (!hd->regsize)
-               hd->regsize = 8;        /* default access size */
+       if (!hd->regsize) {
+               switch (res->flags & IORESOURCE_MEM_TYPE_MASK) {
+               case IORESOURCE_MEM_32BIT:
+                       hd->regsize = 32;
+                       break;
+               case IORESOURCE_MEM_16BIT:
+                       hd->regsize = 16;
+                       break;
+               case IORESOURCE_MEM_8BIT:
+               default:
+                       hd->regsize = 8;
+                       break;
+               }
+       }
 
        setup_timer(&hd->timer, heartbeat_timer, (unsigned long)hd);
        platform_set_drvdata(pdev, hd);