aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2007-05-01 17:26:30 -0400
committerJean Delvare <khali@hyperion.delvare>2007-05-01 17:26:30 -0400
commit4a5d30302ec82c53613915d5eb8381b8efe1dd0e (patch)
tree9431ee719559372018bf1edac532d3b185c99e8e /drivers/i2c
parentc6e8bb2ca5e50547557650c9251d24f55a8f4cfb (diff)
i2c-elektor: Port to the new device driver model
Port the i2c-elektor driver to the new device driver model. I'm using Rene Herman's new isa bus type, as it fits the needs nicely. One benefit is that we can now give a proper parent to our i2c adapter. Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/busses/i2c-elektor.c51
1 files changed, 39 insertions, 12 deletions
diff --git a/drivers/i2c/busses/i2c-elektor.c b/drivers/i2c/busses/i2c-elektor.c
index 834967464814..804f0a551c05 100644
--- a/drivers/i2c/busses/i2c-elektor.c
+++ b/drivers/i2c/busses/i2c-elektor.c
@@ -35,6 +35,7 @@
35#include <linux/pci.h> 35#include <linux/pci.h>
36#include <linux/wait.h> 36#include <linux/wait.h>
37 37
38#include <linux/isa.h>
38#include <linux/i2c.h> 39#include <linux/i2c.h>
39#include <linux/i2c-algo-pcf.h> 40#include <linux/i2c-algo-pcf.h>
40 41
@@ -207,7 +208,7 @@ static struct i2c_adapter pcf_isa_ops = {
207 .name = "i2c-elektor", 208 .name = "i2c-elektor",
208}; 209};
209 210
210static int __init i2c_pcfisa_init(void) 211static int __devinit elektor_match(struct device *dev, unsigned int id)
211{ 212{
212#ifdef __alpha__ 213#ifdef __alpha__
213 /* check to see we have memory mapped PCF8584 connected to the 214 /* check to see we have memory mapped PCF8584 connected to the
@@ -222,9 +223,8 @@ static int __init i2c_pcfisa_init(void)
222 /* yeap, we've found cypress, let's check config */ 223 /* yeap, we've found cypress, let's check config */
223 if (!pci_read_config_byte(cy693_dev, 0x47, &config)) { 224 if (!pci_read_config_byte(cy693_dev, 0x47, &config)) {
224 225
225 pr_debug("%s: found cy82c693, config " 226 dev_dbg(dev, "found cy82c693, config "
226 "register 0x47 = 0x%02x\n", 227 "register 0x47 = 0x%02x\n", config);
227 pcf_isa_ops.name, config);
228 228
229 /* UP2000 board has this register set to 0xe1, 229 /* UP2000 board has this register set to 0xe1,
230 but the most significant bit as seems can be 230 but the most significant bit as seems can be
@@ -244,9 +244,9 @@ static int __init i2c_pcfisa_init(void)
244 8.25 MHz (PCI/4) clock 244 8.25 MHz (PCI/4) clock
245 (this can be read from cypress) */ 245 (this can be read from cypress) */
246 clock = I2C_PCF_CLK | I2C_PCF_TRNS90; 246 clock = I2C_PCF_CLK | I2C_PCF_TRNS90;
247 pr_info("%s: found API UP2000 like " 247 dev_info(dev, "found API UP2000 like "
248 "board, will probe PCF8584 " 248 "board, will probe PCF8584 "
249 "later\n", pcf_isa_ops.name); 249 "later\n");
250 } 250 }
251 } 251 }
252 pci_dev_put(cy693_dev); 252 pci_dev_put(cy693_dev);
@@ -256,22 +256,27 @@ static int __init i2c_pcfisa_init(void)
256 256
257 /* sanity checks for mmapped I/O */ 257 /* sanity checks for mmapped I/O */
258 if (mmapped && base < 0xc8000) { 258 if (mmapped && base < 0xc8000) {
259 printk(KERN_ERR "%s: incorrect base address (%#x) specified " 259 dev_err(dev, "incorrect base address (%#x) specified "
260 "for mmapped I/O\n", pcf_isa_ops.name, base); 260 "for mmapped I/O\n", base);
261 return -ENODEV; 261 return 0;
262 } 262 }
263 263
264 if (base == 0) { 264 if (base == 0) {
265 base = DEFAULT_BASE; 265 base = DEFAULT_BASE;
266 } 266 }
267 return 1;
268}
267 269
270static int __devinit elektor_probe(struct device *dev, unsigned int id)
271{
268 init_waitqueue_head(&pcf_wait); 272 init_waitqueue_head(&pcf_wait);
269 if (pcf_isa_init()) 273 if (pcf_isa_init())
270 return -ENODEV; 274 return -ENODEV;
275 pcf_isa_ops.dev.parent = dev;
271 if (i2c_pcf_add_bus(&pcf_isa_ops) < 0) 276 if (i2c_pcf_add_bus(&pcf_isa_ops) < 0)
272 goto fail; 277 goto fail;
273 278
274 dev_info(&pcf_isa_ops.dev, "found device at %#x\n", base); 279 dev_info(dev, "found device at %#x\n", base);
275 280
276 return 0; 281 return 0;
277 282
@@ -291,7 +296,7 @@ static int __init i2c_pcfisa_init(void)
291 return -ENODEV; 296 return -ENODEV;
292} 297}
293 298
294static void i2c_pcfisa_exit(void) 299static int __devexit elektor_remove(struct device *dev, unsigned int id)
295{ 300{
296 i2c_del_adapter(&pcf_isa_ops); 301 i2c_del_adapter(&pcf_isa_ops);
297 302
@@ -307,6 +312,28 @@ static void i2c_pcfisa_exit(void)
307 iounmap(base_iomem); 312 iounmap(base_iomem);
308 release_mem_region(base, 2); 313 release_mem_region(base, 2);
309 } 314 }
315
316 return 0;
317}
318
319static struct isa_driver i2c_elektor_driver = {
320 .match = elektor_match,
321 .probe = elektor_probe,
322 .remove = __devexit_p(elektor_remove),
323 .driver = {
324 .owner = THIS_MODULE,
325 .name = "i2c-elektor",
326 },
327};
328
329static int __init i2c_pcfisa_init(void)
330{
331 return isa_register_driver(&i2c_elektor_driver, 1);
332}
333
334static void __exit i2c_pcfisa_exit(void)
335{
336 isa_unregister_driver(&i2c_elektor_driver);
310} 337}
311 338
312MODULE_AUTHOR("Hans Berglund <hb@spacetec.no>"); 339MODULE_AUTHOR("Hans Berglund <hb@spacetec.no>");