pwm: rockchip: fix lock warning
author黄涛 <huangtao@rock-chips.com>
Wed, 7 May 2014 11:47:44 +0000 (19:47 +0800)
committer黄涛 <huangtao@rock-chips.com>
Wed, 7 May 2014 11:47:44 +0000 (19:47 +0800)
INFO: trying to register non-static key.
the code is fine but needs lockdep annotation.
turning off the locking correctness validator.
CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.10.0 #43
[<c00142ec>] (unwind_backtrace+0x0/0xe0) from [<c0011c08>] (show_stack+0x10/0x14)
[<c0011c08>] (show_stack+0x10/0x14) from [<c007e018>] (__lock_acquire.isra.24+0x1a4/0x7a4)
[<c007e018>] (__lock_acquire.isra.24+0x1a4/0x7a4) from [<c007ebd0>] (lock_acquire+0x120/0x144)
[<c007ebd0>] (lock_acquire+0x120/0x144) from [<c0717f84>] (_raw_spin_lock_irqsave+0x4c/0x60)
[<c0717f84>] (_raw_spin_lock_irqsave+0x4c/0x60) from [<c0288750>] (rk_pwm_config_v2+0xd4/0x15c)
[<c0288750>] (rk_pwm_config_v2+0xd4/0x15c) from [<c0288b98>] (rk_pwm_config+0x60/0x74)

drivers/pwm/pwm-rockchip.c

index 25c321d49749be4aa94180f8fe5e9fbfc03b3b9d..a15b38d75b809b54e91703068b6dc5e703aa6672 100644 (file)
@@ -86,15 +86,7 @@ module_param_named(dbg_level, pwm_dbg_level, int, 0644);
 
 #define PWMPCR_MIN_PERIOD              0x0001
 #define PWMPCR_MAX_PERIOD              0xFFFF
-#if 0
-static spinlock_t pwm_lock[4] = {
-        __SPIN_LOCK_UNLOCKED(pwm_lock0),
-        __SPIN_LOCK_UNLOCKED(pwm_lock1),
-        __SPIN_LOCK_UNLOCKED(pwm_lock2),
-        __SPIN_LOCK_UNLOCKED(pwm_lock3),
-};
-#endif
-int spinlock_num = 0;
+
 /********************************************
  * struct rk_pwm_chip - struct representing pwm chip
 
@@ -145,7 +137,6 @@ static int  rk_pwm_config_v1(struct pwm_chip *chip, struct pwm_device *pwm,
        struct rk_pwm_chip *pc = to_rk_pwm_chip(chip);
        u64 val, div, clk_rate;
        unsigned long prescale = PWMCR_MIN_PRESCALE, pv, dc;
-       int ret;
        u32 off, on;
        int conf=0;
        unsigned long flags;
@@ -252,7 +243,6 @@ static int  rk_pwm_config_v2(struct pwm_chip *chip, struct pwm_device *pwm,
        struct rk_pwm_chip *pc = to_rk_pwm_chip(chip);
        u64 val, div, clk_rate;
        unsigned long prescale = PWMCR_MIN_PRESCALE, pv, dc;
-       int ret;
        u32  on;
        int conf=0;
        unsigned long flags;
@@ -363,7 +353,6 @@ static int  rk_pwm_config_v3(struct pwm_chip *chip, struct pwm_device *pwm,
        struct rk_pwm_chip *pc = to_rk_pwm_chip(chip);
        u64 val, div, clk_rate;
        unsigned long prescale = PWMCR_MIN_PRESCALE, pv, dc;
-       int  ret;
        u32 on;
        int conf=0;
        unsigned long flags;
@@ -597,8 +586,7 @@ static int rk_pwm_probe(struct platform_device *pdev)
        pc->chip.ops = &rk_pwm_ops;  
        pc->chip.base = -1;
        pc->chip.npwm = NUM_PWM;
-       pc->lock = __SPIN_LOCK_UNLOCKED(PWM##spinlock_num);
-       spinlock_num ++;
+       spin_lock_init(&pc->lock);
 
        /* Following enables PWM chip, channels would still be enabled individually through their control register */
        DBG("npwm = %d, of_pwm_ncells =%d \n", pc->chip.npwm,pc->chip.of_pwm_n_cells);