From e451759f3ff52062ac192ec38910f87c30ce541d Mon Sep 17 00:00:00 2001 From: Chen Liangjun Date: Fri, 17 Feb 2012 14:33:50 +0800 Subject: [PATCH] ENGR00174747 ASRC:fix spinlock bug 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 --- drivers/mxc/asrc/mxc_asrc.c | 14 +------------- include/linux/mxc_asrc.h | 1 - 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/drivers/mxc/asrc/mxc_asrc.c b/drivers/mxc/asrc/mxc_asrc.c index 0a3860afc986..f088e401de37 100644 --- a/drivers/mxc/asrc/mxc_asrc.c +++ b/drivers/mxc/asrc/mxc_asrc.c @@ -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) { diff --git a/include/linux/mxc_asrc.h b/include/linux/mxc_asrc.h index 516b0b69f286..f0136f0502f0 100644 --- a/include/linux/mxc_asrc.h +++ b/include/linux/mxc_asrc.h @@ -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); -- 2.39.5