summaryrefslogtreecommitdiffstats
path: root/target/linux/coldfire/patches/048-Fix-i2c-driver-bug-when-reinserting-as-module.patch
blob: a85aa561112e6613918d93542be926c44e22c062 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
From 2c83888b2170d3883c9316c4d94dddc4b7f9ec68 Mon Sep 17 00:00:00 2001
From: Alison Wang <b18965@freescale.com>
Date: Thu, 4 Aug 2011 09:59:55 +0800
Subject: [PATCH 48/52] Fix i2c driver bug when reinserting as module

Signed-off-by: Alison Wang <b18965@freescale.com>
---
 drivers/i2c/busses/i2c-mcf-slave.c |   14 ++++++++++++++
 drivers/i2c/busses/i2c-mcf.c       |   14 ++++++++++++++
 2 files changed, 28 insertions(+), 0 deletions(-)

--- a/drivers/i2c/busses/i2c-mcf-slave.c
+++ b/drivers/i2c/busses/i2c-mcf-slave.c
@@ -273,8 +273,15 @@ static int __init gen_i2c_proc_init(void
 		return -ENOMEM;
 	return 0;
 }
+
+static int gen_i2c_proc_deinit(void)
+{
+	remove_proc_entry("driver/i2c-adaptor-register", NULL);
+	return 0;
+}
 #else
 static inline int gen_i2c_proc_init(void) { return 0; }
+static inline int gen_i2c_proc_deinit(void) { return 0; }
 #endif /* CONFIG_PROC_FS */
 
 /*
@@ -345,6 +352,13 @@ static int __init i2c_coldfire_init(void
 
 static void __exit i2c_coldfire_exit(void)
 {
+	int retval;
+
+	retval = gen_i2c_proc_deinit();
+	if (retval < 0)
+		printk(KERN_INFO "remove /proc/i2c-adaptor-register "
+				"for i2c slave mode failed!\n");
+
 	/* disable I2C and Interrupt */
 	MCF_I2CR &= ~(MCF_I2CR_IEN | MCF_I2CR_IIEN);
 	free_irq(IRQ, NULL);
--- a/drivers/i2c/busses/i2c-mcf.c
+++ b/drivers/i2c/busses/i2c-mcf.c
@@ -669,8 +669,15 @@ static int __init gen_i2c_proc_init(void
 		return -ENOMEM;
 	return 0;
 }
+
+static int gen_i2c_proc_deinit(void)
+{
+	remove_proc_entry("driver/i2c-adaptor-register", NULL);
+	return 0;
+}
 #else
 static inline int gen_i2c_proc_init(void) { return 0; }
+static inline int gen_i2c_proc_deinit(void) { return 0; }
 #endif /* CONFIG_PROC_FS */
 
 static int __init coldfire_i2c_init(void)
@@ -687,6 +694,13 @@ static int __init coldfire_i2c_init(void
 
 static void __exit coldfire_i2c_exit(void)
 {
+	int retval;
+
+	retval = gen_i2c_proc_deinit();
+	if (retval < 0)
+		printk(KERN_INFO "remove /proc/i2c-adaptor-register "
+				"for i2c master mode failed!\n");
+
 	platform_driver_unregister(&mcf_i2c_driver);
 }