diff options
author | Kuninori Morimoto <morimoto.kuninori@renesas.com> | 2009-08-18 03:00:20 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2009-08-18 08:16:29 -0400 |
commit | e174d13010a6bd52045466bc35ca5a86e3f3ba9b (patch) | |
tree | 1ad84c9b48bae21a3a150da7caae5f938abae461 /arch/sh | |
parent | b2ea8b421515ddd692c88fc5afb0e7f93e96e6cb (diff) |
sh: Prevent heartbeat from scribbling over non-LED bits.
While most platforms implement LED banks in sets of 8/16/32, some use
different configurations. This adds a LED mask to the heartbeat platform
data to allow platforms to constrain the bitmap, which is otherwise
derived from the register size.
Signed-off-by: Kuninori Morimoto <morimoto.kuninori@renesas.com>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh')
-rw-r--r-- | arch/sh/drivers/heartbeat.c | 10 | ||||
-rw-r--r-- | arch/sh/include/asm/heartbeat.h | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/arch/sh/drivers/heartbeat.c b/arch/sh/drivers/heartbeat.c index 938817e34e2b..a9339a6174fc 100644 --- a/arch/sh/drivers/heartbeat.c +++ b/arch/sh/drivers/heartbeat.c | |||
@@ -40,14 +40,19 @@ static inline void heartbeat_toggle_bit(struct heartbeat_data *hd, | |||
40 | if (inverted) | 40 | if (inverted) |
41 | new = ~new; | 41 | new = ~new; |
42 | 42 | ||
43 | new &= hd->mask; | ||
44 | |||
43 | switch (hd->regsize) { | 45 | switch (hd->regsize) { |
44 | case 32: | 46 | case 32: |
47 | new |= ioread32(hd->base) & ~hd->mask; | ||
45 | iowrite32(new, hd->base); | 48 | iowrite32(new, hd->base); |
46 | break; | 49 | break; |
47 | case 16: | 50 | case 16: |
51 | new |= ioread16(hd->base) & ~hd->mask; | ||
48 | iowrite16(new, hd->base); | 52 | iowrite16(new, hd->base); |
49 | break; | 53 | break; |
50 | default: | 54 | default: |
55 | new |= ioread8(hd->base) & ~hd->mask; | ||
51 | iowrite8(new, hd->base); | 56 | iowrite8(new, hd->base); |
52 | break; | 57 | break; |
53 | } | 58 | } |
@@ -72,6 +77,7 @@ static int heartbeat_drv_probe(struct platform_device *pdev) | |||
72 | { | 77 | { |
73 | struct resource *res; | 78 | struct resource *res; |
74 | struct heartbeat_data *hd; | 79 | struct heartbeat_data *hd; |
80 | int i; | ||
75 | 81 | ||
76 | if (unlikely(pdev->num_resources != 1)) { | 82 | if (unlikely(pdev->num_resources != 1)) { |
77 | dev_err(&pdev->dev, "invalid number of resources\n"); | 83 | dev_err(&pdev->dev, "invalid number of resources\n"); |
@@ -107,6 +113,10 @@ static int heartbeat_drv_probe(struct platform_device *pdev) | |||
107 | hd->nr_bits = ARRAY_SIZE(default_bit_pos); | 113 | hd->nr_bits = ARRAY_SIZE(default_bit_pos); |
108 | } | 114 | } |
109 | 115 | ||
116 | hd->mask = 0; | ||
117 | for (i = 0; i < hd->nr_bits; i++) | ||
118 | hd->mask |= (1 << hd->bit_pos[i]); | ||
119 | |||
110 | if (!hd->regsize) | 120 | if (!hd->regsize) |
111 | hd->regsize = 8; /* default access size */ | 121 | hd->regsize = 8; /* default access size */ |
112 | 122 | ||
diff --git a/arch/sh/include/asm/heartbeat.h b/arch/sh/include/asm/heartbeat.h index 724a43ed245e..caaafe5a3ef1 100644 --- a/arch/sh/include/asm/heartbeat.h +++ b/arch/sh/include/asm/heartbeat.h | |||
@@ -11,6 +11,7 @@ struct heartbeat_data { | |||
11 | unsigned int nr_bits; | 11 | unsigned int nr_bits; |
12 | struct timer_list timer; | 12 | struct timer_list timer; |
13 | unsigned int regsize; | 13 | unsigned int regsize; |
14 | unsigned int mask; | ||
14 | unsigned long flags; | 15 | unsigned long flags; |
15 | }; | 16 | }; |
16 | 17 | ||