diff options
author | Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> | 2014-03-04 09:25:56 -0500 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> | 2014-07-02 10:01:50 -0400 |
commit | 8b2463d8cae2dda0c98ab5a15f25a0350a0e998d (patch) | |
tree | 5c314dcdf601781735b00b03b2fbc381e282e1ce /drivers/clocksource | |
parent | 1a5da0e43be0c07462e445549dbdd4a1731a3e11 (diff) |
clocksource: sh_mtu2: Replace global spinlock with a per-device spinlock
The global spinlock is used to protect the shared start/stop register.
Now that all MTU2 channels are handled by a single device instance, use
a per-device spinlock.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Tested-by: Wolfram Sang <wsa@sang-engineering.com>
Diffstat (limited to 'drivers/clocksource')
-rw-r--r-- | drivers/clocksource/sh_mtu2.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index 0342e4a01c9e..b0c229f4b4c6 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c | |||
@@ -47,14 +47,14 @@ struct sh_mtu2_device { | |||
47 | void __iomem *mapbase; | 47 | void __iomem *mapbase; |
48 | struct clk *clk; | 48 | struct clk *clk; |
49 | 49 | ||
50 | raw_spinlock_t lock; /* Protect the shared registers */ | ||
51 | |||
50 | struct sh_mtu2_channel *channels; | 52 | struct sh_mtu2_channel *channels; |
51 | unsigned int num_channels; | 53 | unsigned int num_channels; |
52 | 54 | ||
53 | bool has_clockevent; | 55 | bool has_clockevent; |
54 | }; | 56 | }; |
55 | 57 | ||
56 | static DEFINE_RAW_SPINLOCK(sh_mtu2_lock); | ||
57 | |||
58 | #define TSTR -1 /* shared register */ | 58 | #define TSTR -1 /* shared register */ |
59 | #define TCR 0 /* channel register */ | 59 | #define TCR 0 /* channel register */ |
60 | #define TMDR 1 /* channel register */ | 60 | #define TMDR 1 /* channel register */ |
@@ -192,7 +192,7 @@ static void sh_mtu2_start_stop_ch(struct sh_mtu2_channel *ch, int start) | |||
192 | unsigned long flags, value; | 192 | unsigned long flags, value; |
193 | 193 | ||
194 | /* start stop register shared by multiple timer channels */ | 194 | /* start stop register shared by multiple timer channels */ |
195 | raw_spin_lock_irqsave(&sh_mtu2_lock, flags); | 195 | raw_spin_lock_irqsave(&ch->mtu->lock, flags); |
196 | value = sh_mtu2_read(ch, TSTR); | 196 | value = sh_mtu2_read(ch, TSTR); |
197 | 197 | ||
198 | if (start) | 198 | if (start) |
@@ -201,7 +201,7 @@ static void sh_mtu2_start_stop_ch(struct sh_mtu2_channel *ch, int start) | |||
201 | value &= ~(1 << ch->index); | 201 | value &= ~(1 << ch->index); |
202 | 202 | ||
203 | sh_mtu2_write(ch, TSTR, value); | 203 | sh_mtu2_write(ch, TSTR, value); |
204 | raw_spin_unlock_irqrestore(&sh_mtu2_lock, flags); | 204 | raw_spin_unlock_irqrestore(&ch->mtu->lock, flags); |
205 | } | 205 | } |
206 | 206 | ||
207 | static int sh_mtu2_enable(struct sh_mtu2_channel *ch) | 207 | static int sh_mtu2_enable(struct sh_mtu2_channel *ch) |
@@ -402,6 +402,8 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu, | |||
402 | 402 | ||
403 | mtu->pdev = pdev; | 403 | mtu->pdev = pdev; |
404 | 404 | ||
405 | raw_spin_lock_init(&mtu->lock); | ||
406 | |||
405 | /* Get hold of clock. */ | 407 | /* Get hold of clock. */ |
406 | mtu->clk = clk_get(&mtu->pdev->dev, "fck"); | 408 | mtu->clk = clk_get(&mtu->pdev->dev, "fck"); |
407 | if (IS_ERR(mtu->clk)) { | 409 | if (IS_ERR(mtu->clk)) { |