]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ENGR00138480: mxc_iim can't be open twice
authorTerry Lv <r65388@freescale.com>
Tue, 25 Jan 2011 18:34:56 +0000 (02:34 +0800)
committerOliver Wendt <ow@karo-electronics.de>
Mon, 30 Sep 2013 12:08:51 +0000 (14:08 +0200)
mxc_iim can't be open twice.
The reason is that request_irq failed when open mxc_iim again.
So put request_irq function to probe function.

Signed-off-by: Terry Lv <r65388@freescale.com>
drivers/char/mxc_iim.c

index 77132fe0b148adea677c8f15d0937388ee9cb494..44b1de3d104668395a132145dd0e66de0d1b47a3 100644 (file)
@@ -1,14 +1,21 @@
 /*
- * Copyright 2009-2011 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright (C) 2009-2011 Freescale Semiconductor, Inc. All Rights Reserved.
  */
 
 /*
- * The code contained herein is licensed under the GNU General Public
- * License. You may obtain a copy of the GNU General Public License
- * Version 2 or later at the following locations:
- *
- * http://www.opensource.org/licenses/gpl-license.html
- * http://www.gnu.org/copyleft/gpl.html
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 #include <linux/fs.h>
 #include <linux/init.h>
@@ -415,9 +422,13 @@ static ssize_t mxc_iim_write(struct file *filp, const char __user *buf,
 
        retval = count;
 out:
+       if (tmp_buf)
+               kfree(tmp_buf);
        dev_dbg(iim_data->dev, "<= %s\n", __func__);
        return retval;
 invald_arg_out:
+       if (tmp_buf)
+               kfree(tmp_buf);
        retval = -EINVAL;
        return retval;
 }
@@ -477,10 +488,6 @@ static int mxc_iim_open(struct inode *inode, struct file *filp)
                (u32)ioremap(iim_data->reg_base, iim_data->reg_size);
 
        mxc_iim_disable_irq();
-       ret = request_irq(iim_data->irq, mxc_iim_irq, IRQF_DISABLED,
-                               iim_data->name, iim_data);
-       if (ret)
-               return ret;
 
        dev_dbg(iim_data->dev, "<= %s\n", __func__);
 
@@ -499,7 +506,6 @@ static int mxc_iim_release(struct inode *inode, struct file *filp)
 {
        clk_disable(iim_data->clk);
        clk_put(iim_data->clk);
-       free_irq(iim_data->irq, iim_data);
        iounmap((void *)iim_data->virt_base);
        return 0;
 }
@@ -533,12 +539,12 @@ static __devinit int mxc_iim_probe(struct platform_device *pdev)
        struct resource *res;
        int ret;
 
-       dev_dbg(iim_data->dev, "=> %s\n", __func__);
-
        iim_data = pdev->dev.platform_data;
        iim_data->dev = &pdev->dev;
        iim_data->name = mxc_iim_miscdev.name;
 
+       dev_dbg(iim_data->dev, "=> %s\n", __func__);
+
        dev_dbg(iim_data->dev, "iim_data addr: 0x%08x "
                "bank_start: 0x%04x bank_end: 0x%04x "
                "enable_fuse: 0x%08x disable_fuse: 0x%08x\n",
@@ -560,6 +566,11 @@ static __devinit int mxc_iim_probe(struct platform_device *pdev)
                return ret;
        }
 
+       ret = request_irq(iim_data->irq, mxc_iim_irq, IRQF_DISABLED,
+                       iim_data->name, iim_data);
+       if (ret)
+               return ret;
+
        iim_data->reg_base = res->start;
        iim_data->reg_end = res->end;
        iim_data->reg_size =
@@ -579,6 +590,7 @@ static __devinit int mxc_iim_probe(struct platform_device *pdev)
 
 static int __devexit mxc_iim_remove(struct platform_device *pdev)
 {
+       free_irq(iim_data->irq, iim_data);
        misc_deregister(&mxc_iim_miscdev);
        return 0;
 }