aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorRene Herman <rene.herman@gmail.com>2008-10-14 11:30:03 -0400
committerJean Delvare <khali@mahadeva.delvare>2008-10-14 11:30:03 -0400
commitce5640330b10c6cecfbda50569b9f53c081d10c6 (patch)
tree93a3cbb3ecea9be12b468781b36ea3039724ccb4 /drivers/i2c
parent9df013b3e46c67dd3745df91eaccdc719118e0cc (diff)
i2c-pca-isa: Don't grab arbitrary resources
Grabbing ISA bus resources without anything or anyone telling us we should can break boot on randconfig/allyesconfig builds by keeping resources that are in fact owned by different hardware busy and does as reported by Ingo Molnar. Generally it's also dangerous to just poke at random I/O ports and especially those in the range where other old easily confused ISA hardware might live. For this specialized I2C bus driver, insist that the user specifies the resources before grabbing them. The^WA user of this driver is a one time echo "options i2c-pca-isa base=0x330 irq=10" >> /etc/modprobe.conf away from the old behaviour. Signed-off-by: Rene Herman <rene.herman@gmail.com> Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/busses/i2c-pca-isa.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/drivers/i2c/busses/i2c-pca-isa.c b/drivers/i2c/busses/i2c-pca-isa.c
index a119784bae10..f80df9ae5054 100644
--- a/drivers/i2c/busses/i2c-pca-isa.c
+++ b/drivers/i2c/busses/i2c-pca-isa.c
@@ -36,8 +36,8 @@
36#define DRIVER "i2c-pca-isa" 36#define DRIVER "i2c-pca-isa"
37#define IO_SIZE 4 37#define IO_SIZE 4
38 38
39static unsigned long base = 0x330; 39static unsigned long base;
40static int irq = 10; 40static int irq = -1;
41 41
42/* Data sheet recommends 59kHz for 100kHz operation due to variation 42/* Data sheet recommends 59kHz for 100kHz operation due to variation
43 * in the actual clock rate */ 43 * in the actual clock rate */
@@ -107,6 +107,19 @@ static struct i2c_adapter pca_isa_ops = {
107 .timeout = 100, 107 .timeout = 100,
108}; 108};
109 109
110static int __devinit pca_isa_match(struct device *dev, unsigned int id)
111{
112 int match = base != 0;
113
114 if (match) {
115 if (irq <= -1)
116 dev_warn(dev, "Using polling mode (specify irq)\n");
117 } else
118 dev_err(dev, "Please specify I/O base\n");
119
120 return match;
121}
122
110static int __devinit pca_isa_probe(struct device *dev, unsigned int id) 123static int __devinit pca_isa_probe(struct device *dev, unsigned int id)
111{ 124{
112 init_waitqueue_head(&pca_wait); 125 init_waitqueue_head(&pca_wait);
@@ -153,7 +166,7 @@ static int __devexit pca_isa_remove(struct device *dev, unsigned int id)
153{ 166{
154 i2c_del_adapter(&pca_isa_ops); 167 i2c_del_adapter(&pca_isa_ops);
155 168
156 if (irq > 0) { 169 if (irq > -1) {
157 disable_irq(irq); 170 disable_irq(irq);
158 free_irq(irq, &pca_isa_ops); 171 free_irq(irq, &pca_isa_ops);
159 } 172 }
@@ -163,6 +176,7 @@ static int __devexit pca_isa_remove(struct device *dev, unsigned int id)
163} 176}
164 177
165static struct isa_driver pca_isa_driver = { 178static struct isa_driver pca_isa_driver = {
179 .match = pca_isa_match,
166 .probe = pca_isa_probe, 180 .probe = pca_isa_probe,
167 .remove = __devexit_p(pca_isa_remove), 181 .remove = __devexit_p(pca_isa_remove),
168 .driver = { 182 .driver = {