]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
ENGR00174747 ASRC:fix spinlock bug
authorChen Liangjun <b36089@freescale.com>
Fri, 17 Feb 2012 06:33:50 +0000 (14:33 +0800)
committerOliver Wendt <ow@karo-electronics.de>
Mon, 30 Sep 2013 12:10:58 +0000 (14:10 +0200)
When use clk_enable and clk_disable function, system may enter
sleep. so these 2 funciton can not used surrounding with spin
lock/unlock. And the clk_enable/disable function already keep
the counter of open and close and it is no need to keep the counter
in driver.

Signed-off-by: Chen Liangjun <b36089@freescale.com>
drivers/mxc/asrc/mxc_asrc.c
include/linux/mxc_asrc.h

index 0a3860afc986299fa5359a19cc7b9d4d37b2d9d0..f088e401de37f47d65c1d72bbd296298802bf711 100644 (file)
@@ -51,7 +51,6 @@ static struct class *asrc_class;
 DEFINE_SPINLOCK(data_lock);
 DEFINE_SPINLOCK(input_int_lock);
 DEFINE_SPINLOCK(output_int_lock);
-DEFINE_SPINLOCK(asrc_clock_lock);
 
 #define AICPA          0       /* Input Clock Divider A Offset */
 #define AICDA          3       /* Input Clock Prescaler A Offset */
@@ -1523,13 +1522,8 @@ static int mxc_asrc_open(struct inode *inode, struct file *file)
 {
        int err = 0;
        struct asrc_pair_params *pair_params;
-       unsigned long lock_flags;
 
-       spin_lock_irqsave(&asrc_clock_lock, lock_flags);
-       g_asrc_data->counter++;
        clk_enable(mxc_asrc_data->asrc_core_clk);
-       spin_unlock_irqrestore(&asrc_clock_lock, lock_flags);
-
        if (signal_pending(current))
                return -EINTR;
        pair_params = kzalloc(sizeof(struct asrc_pair_params), GFP_KERNEL);
@@ -1554,7 +1548,6 @@ static int mxc_asrc_open(struct inode *inode, struct file *file)
 static int mxc_asrc_close(struct inode *inode, struct file *file)
 {
        struct asrc_pair_params *pair_params;
-       unsigned long lock_flags;
        pair_params = file->private_data;
 
        if (pair_params->asrc_active == 1) {
@@ -1573,12 +1566,8 @@ static int mxc_asrc_close(struct inode *inode, struct file *file)
 
        kfree(pair_params);
        file->private_data = NULL;
+       clk_disable(mxc_asrc_data->asrc_core_clk);
 
-       spin_lock_irqsave(&asrc_clock_lock, lock_flags);
-       g_asrc_data->counter--;
-       if (g_asrc_data->counter == 0)
-               clk_disable(mxc_asrc_data->asrc_core_clk);
-       spin_unlock_irqrestore(&asrc_clock_lock, lock_flags);
        return 0;
 }
 
@@ -1728,7 +1717,6 @@ static int mxc_asrc_probe(struct platform_device *pdev)
        g_asrc_data->asrc_pair[0].overload_error = 0;
        g_asrc_data->asrc_pair[1].overload_error = 0;
        g_asrc_data->asrc_pair[2].overload_error = 0;
-       g_asrc_data->counter = 0;
 
        asrc_major = register_chrdev(asrc_major, "mxc_asrc", &asrc_fops);
        if (asrc_major < 0) {
index 516b0b69f286ff58a0b9a526d14f3e0ff7e2b2cf..f0136f0502f0038497da25dc712ba4bff2f86dc8 100644 (file)
@@ -197,7 +197,6 @@ struct asrc_pair_params {
 
 struct asrc_data {
        struct asrc_pair asrc_pair[3];
-       unsigned int     counter;
 };
 
 extern int asrc_req_pair(int chn_num, enum asrc_pair_index *index);