Changeset 3763
- Timestamp:
- 01/15/03 02:11:42 (10 years ago)
- Location:
- i2c/branches/lk2-4/kernel
- Files:
-
- 2 removed
- 22 modified
-
Makefile (deleted)
-
Module.mk (modified) (1 diff)
-
i2c-adap-ibm_ocp.c (modified) (6 diffs)
-
i2c-algo-8xx.c (modified) (5 diffs)
-
i2c-algo-8xx.h (modified) (1 diff)
-
i2c-algo-bit.c (modified) (6 diffs)
-
i2c-algo-biths.c (modified) (6 diffs)
-
i2c-algo-ibm_ocp.c (modified) (5 diffs)
-
i2c-algo-ibm_ocp.h (modified) (2 diffs)
-
i2c-algo-pcf.c (modified) (5 diffs)
-
i2c-core.c (modified) (14 diffs)
-
i2c-dev.c (modified) (11 diffs)
-
i2c-dev.h (modified) (2 diffs)
-
i2c-elektor.c (modified) (6 diffs)
-
i2c-elektor.h (deleted)
-
i2c-elv.c (modified) (4 diffs)
-
i2c-frodo.c (modified) (3 diffs)
-
i2c-pcf-epp.c (modified) (4 diffs)
-
i2c-philips-par.c (modified) (3 diffs)
-
i2c-pport.c (modified) (3 diffs)
-
i2c-proc.c (modified) (10 diffs)
-
i2c-rpx.c (modified) (4 diffs)
-
i2c-velleman.c (modified) (4 diffs)
-
i2c.h (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
i2c/branches/lk2-4/kernel/Module.mk
r3743 r3763 61 61 ifneq ($(shell if grep -q '^CONFIG_I2C_ELEKTOR=y' $(LINUX)/.config; then echo 1; fi),1) 62 62 KERNELTARGETS += $(MODULE_DIR)/i2c-elektor.o 63 KERNELINCLUDES += $(MODULE_DIR)/i2c- elektor.h $(MODULE_DIR)/i2c-pcf8584.h63 KERNELINCLUDES += $(MODULE_DIR)/i2c-pcf8584.h 64 64 endif 65 65 ifneq ($(shell if grep -q '^CONFIG_I2C_PROC=y' $(LINUX)/.config; then echo 1; fi),1) -
i2c/branches/lk2-4/kernel/i2c-adap-ibm_ocp.c
r3753 r3763 62 62 #include <asm/irq.h> 63 63 #include <asm/io.h> 64 #include <linux/i2c.h>65 #include <linux/i2c-algo-ibm_ocp.h>66 #include <linux/i2c-id.h>67 64 #include <asm/ocp.h> 65 66 #include "i2c.h" 67 #include "i2c-algo-ibm_ocp.h" 68 68 69 69 MODULE_LICENSE("GPL"); … … 259 259 260 260 // 261 // Description: Does nothing262 //263 static int iic_ibmocp_reg(struct i2c_client *client)264 {265 return 0;266 }267 268 269 //270 // Description: Does nothing271 //272 static int iic_ibmocp_unreg(struct i2c_client *client)273 {274 return 0;275 }276 277 278 //279 // Description: If this compiled as a module, then increment the count280 //281 static void iic_ibmocp_inc_use(struct i2c_adapter *adap)282 {283 #ifdef MODULE284 MOD_INC_USE_COUNT;285 #endif286 }287 288 289 //290 // Description: If this is a module, then decrement the count291 //292 static void iic_ibmocp_dec_use(struct i2c_adapter *adap)293 {294 #ifdef MODULE295 MOD_DEC_USE_COUNT;296 #endif297 }298 299 //300 261 // Description: Called when the module is loaded. This function starts the 301 262 // cascade of calls up through the heirarchy of i2c modules (i.e. up to the 302 263 // algorithm layer and into to the core layer) 303 264 // 304 int __init iic_ibmocp_init(void)265 static int __init iic_ibmocp_init(void) 305 266 { 306 267 int i; … … 341 302 iic_ibmocp_data[i]->udelay = 80; 342 303 iic_ibmocp_data[i]->mdelay = 80; 343 iic_ibmocp_data[i]->timeout = 100;304 iic_ibmocp_data[i]->timeout = HZ; 344 305 345 306 iic_ibmocp_ops[i] = kmalloc(sizeof(struct i2c_adapter), GFP_KERNEL); … … 349 310 memset(iic_ibmocp_ops[i], 0, sizeof(struct i2c_adapter)); 350 311 strcpy(iic_ibmocp_ops[i]->name, "IBM OCP IIC adapter"); 312 iic_ibmocp_ops[i]->owner = THIS_MODULE; 351 313 iic_ibmocp_ops[i]->id = I2C_HW_OCP; 352 314 iic_ibmocp_ops[i]->algo = NULL; 353 315 iic_ibmocp_ops[i]->algo_data = iic_ibmocp_data[i]; 354 iic_ibmocp_ops[i]->inc_use = iic_ibmocp_inc_use;355 iic_ibmocp_ops[i]->dec_use = iic_ibmocp_dec_use;356 iic_ibmocp_ops[i]->client_register = iic_ibmocp_reg;357 iic_ibmocp_ops[i]->client_unregister = iic_ibmocp_unreg;358 316 359 317 … … 371 329 372 330 373 static void iic_ibmocp_exit(void)331 static void __exit iic_ibmocp_exit(void) 374 332 { 375 333 int i; … … 380 338 iic_ibmocp_release(); 381 339 } 382 383 EXPORT_NO_SYMBOLS;384 340 385 341 // -
i2c/branches/lk2-4/kernel/i2c-algo-8xx.c
r3753 r3763 41 41 #include <asm/commproc.h> 42 42 43 #include <linux/i2c.h>44 #include <linux/i2c-algo-8xx.h>43 #include "i2c.h" 44 #include "i2c-algo-8xx.h" 45 45 46 46 #define CPM_MAX_READ 513 … … 582 582 583 583 static struct i2c_algorithm cpm_algo = { 584 "MPC8xx CPM algorithm", 585 I2C_ALGO_MPC8XX, 586 cpm_xfer, 587 NULL, 588 NULL, /* slave_xmit */ 589 NULL, /* slave_recv */ 590 algo_control, /* ioctl */ 591 cpm_func, /* functionality */ 584 .name = "MPC8xx CPM algorithm", 585 .id = I2C_ALGO_MPC8XX, 586 .master_xfer = cpm_xfer, 587 .algo_control = algo_control, 588 .functionality = cpm_func, 592 589 }; 593 590 … … 609 606 adap->algo = &cpm_algo; 610 607 611 #ifdef MODULE612 608 MOD_INC_USE_COUNT; 613 #endif614 615 609 i2c_add_adapter(adap); 616 610 cpm_iic_init(cpm_adap); … … 643 637 printk("i2c-algo-8xx.o: adapter unregistered: %s\n",adap->name); 644 638 645 #ifdef MODULE646 639 MOD_DEC_USE_COUNT; 647 #endif648 640 return 0; 649 641 } … … 652 644 EXPORT_SYMBOL(i2c_8xx_del_bus); 653 645 654 int __init i2c_algo_8xx_init (void)655 {656 printk("i2c-algo-8xx.o: i2c mpc8xx algorithm module version %s (%s)\n", I2C_VERSION, I2C_DATE);657 return 0;658 }659 660 661 #ifdef MODULE662 646 MODULE_AUTHOR("Brad Parker <brad@heeltoe.com>"); 663 647 MODULE_DESCRIPTION("I2C-Bus MPC8XX algorithm"); 664 648 MODULE_LICENSE("GPL"); 665 666 int init_module(void)667 {668 return i2c_algo_8xx_init();669 }670 671 void cleanup_module(void)672 {673 }674 #endif -
i2c/branches/lk2-4/kernel/i2c-algo-8xx.h
r3639 r3763 22 22 #define I2C_ALGO_8XX_H 1 23 23 24 #include <linux/i2c.h>24 #include "i2c.h" 25 25 26 26 struct i2c_algo_8xx_data { -
i2c/branches/lk2-4/kernel/i2c-algo-bit.c
r3753 r3763 34 34 #include <linux/errno.h> 35 35 #include <linux/sched.h> 36 36 37 #include "i2c.h" 37 38 #include "i2c-algo-bit.h" … … 547 548 548 549 static struct i2c_algorithm i2c_bit_algo = { 549 "Bit-shift algorithm", 550 I2C_ALGO_BIT, 551 bit_xfer, 552 NULL, 553 NULL, /* slave_xmit */ 554 NULL, /* slave_recv */ 555 algo_control, /* ioctl */ 556 bit_func, /* functionality */ 550 .name = "Bit-shift algorithm", 551 .id = I2C_ALGO_BIT, 552 .master_xfer = bit_xfer, 553 .algo_control = algo_control, 554 .functionality = bit_func, 557 555 }; 558 556 … … 599 597 } 600 598 601 #ifdef MODULE602 599 MOD_INC_USE_COUNT; 603 #endif604 600 i2c_add_adapter(i2c_adap); 605 606 601 return 0; 607 602 } … … 617 612 DEB2(printk(KERN_DEBUG "i2c-algo-bit.o: adapter unregistered: %s\n",i2c_adap->name)); 618 613 619 #ifdef MODULE620 614 MOD_DEC_USE_COUNT; 621 #endif622 615 return 0; 623 616 } 624 625 int __init i2c_algo_bit_init (void)626 {627 printk(KERN_INFO "i2c-algo-bit.o: i2c bit algorithm module version %s (%s)\n", I2C_VERSION, I2C_DATE);628 return 0;629 }630 631 617 632 618 … … 634 620 EXPORT_SYMBOL(i2c_bit_del_bus); 635 621 636 #ifdef MODULE637 622 MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>"); 638 623 MODULE_DESCRIPTION("I2C-Bus bit-banging algorithm"); … … 647 632 MODULE_PARM_DESC(i2c_debug, 648 633 "debug level - 0 off; 1 normal; 2,3 more verbose; 9 bit-protocol"); 649 650 int init_module(void)651 {652 return i2c_algo_bit_init();653 }654 655 void cleanup_module(void)656 {657 }658 #endif -
i2c/branches/lk2-4/kernel/i2c-algo-biths.c
r3753 r3763 366 366 if (flags & _HS_NAK) 367 367 return -EREMOTEIO; 368 369 return -1; 368 370 } 369 371 … … 591 593 592 594 static struct i2c_algorithm i2c_algo_biths = { 593 "Bit-shift algorithm", 594 I2C_ALGO_BIT, 595 bit_xfer, 596 NULL, 597 NULL, /* slave_xmit */ 598 NULL, /* slave_recv */ 599 algo_control, /* ioctl */ 600 bit_func, /* functionality */ 595 .name = "Bit-shift algorithm", 596 .id = I2C_ALGO_BIT, 597 .master_xfer = bit_xfer, 598 .algo_control = algo_control, 599 .functionality = bit_func, 601 600 }; 602 601 … … 632 631 633 632 static struct i2c_algo_biths_data _old_template = { 634 setstate:_old_setstate,635 setsda:_old_setsda,636 setscl:_old_setscl,637 getsda:_old_getsda,638 getscl:_old_getscl,633 .setstate = _old_setstate, 634 .setsda = _old_setsda, 635 .setscl = _old_setscl, 636 .getsda = _old_getsda, 637 .getscl = _old_getscl, 639 638 }; 640 639 … … 724 723 int i2c_biths_add_bus(struct i2c_adapter *i2c_adap) 725 724 { 726 int i;727 725 struct i2c_algo_biths_data *adap = i2c_adap->algo_data; 728 726 … … 749 747 DEB1(printk(KERN_DEBUG "i2c-algo-biths.o: hw routines for %s registered.\n", 750 748 i2c_adap->name)); 751 752 /* register new adapter to i2c module... */753 754 i2c_adap->id |= i2c_algo_biths.id;755 i2c_adap->algo = &i2c_algo_biths;756 757 i2c_adap->timeout = HZ; /* default values, should */758 i2c_adap->retries = 3; /* be replaced by defines */759 760 #ifdef MODULE761 MOD_INC_USE_COUNT;762 #endif763 i2c_add_adapter(i2c_adap);764 765 return 0;766 }767 768 769 int i2c_biths_del_bus(struct i2c_adapter *i2c_adap)770 {771 int res;772 773 if ((res = i2c_del_adapter(i2c_adap)) < 0)774 return res;775 776 DEB1(printk(KERN_DEBUG "i2c-algo-biths.o: adapter unregistered: %s\n",i2c_adap->name));777 778 #ifdef MODULE779 MOD_DEC_USE_COUNT;780 #endif781 return 0;782 }783 784 int __init i2c_algo_biths_init (void)785 {786 printk(KERN_INFO "i2c-algo-biths.o: i2c high-speed bit algorithm module version %s (%s)\n", I2C_VERSION, I2C_DATE);787 749 #ifdef rdtscl 788 750 DEB1(printk(KERN_DEBUG "i2c-algo-biths.o: ... will use rdtscl() for bus clock\n")); 789 751 #else 790 DEB1(printk(KERN_DEBUG "i2c-algo-biths.o: ... will use udelay() for bus clock\n") ;752 DEB1(printk(KERN_DEBUG "i2c-algo-biths.o: ... will use udelay() for bus clock\n")); 791 753 #endif 754 755 /* register new adapter to i2c module... */ 756 757 i2c_adap->id |= i2c_algo_biths.id; 758 i2c_adap->algo = &i2c_algo_biths; 759 760 i2c_adap->timeout = HZ; /* default values, should */ 761 i2c_adap->retries = 3; /* be replaced by defines */ 762 763 MOD_INC_USE_COUNT; 764 i2c_add_adapter(i2c_adap); 765 792 766 return 0; 793 767 } 794 768 795 769 770 int i2c_biths_del_bus(struct i2c_adapter *i2c_adap) 771 { 772 int res; 773 774 if ((res = i2c_del_adapter(i2c_adap)) < 0) 775 return res; 776 777 DEB1(printk(KERN_DEBUG "i2c-algo-biths.o: adapter unregistered: %s\n",i2c_adap->name)); 778 MOD_DEC_USE_COUNT; 779 return 0; 780 } 796 781 797 782 EXPORT_SYMBOL(i2c_biths_add_bus); 798 783 EXPORT_SYMBOL(i2c_biths_del_bus); 799 784 800 #ifdef MODULE801 785 MODULE_AUTHOR("Kyösti Mälkki <kmalkki@cc.hut.fi>"); 802 786 MODULE_DESCRIPTION("I2C-Bus bit-banging algorithm"); … … 809 793 MODULE_PARM_DESC(i2c_debug, 810 794 "debug level - 1 use; 2 fatal, 3 +proto; 4 all, 5 +proto"); 811 812 int init_module(void)813 {814 return i2c_algo_biths_init();815 }816 817 void cleanup_module(void)818 {819 }820 #endif -
i2c/branches/lk2-4/kernel/i2c-algo-ibm_ocp.c
r3753 r3763 63 63 #include <linux/sched.h> 64 64 65 #include <linux/i2c.h>66 #include <linux/i2c-algo-ibm_ocp.h>65 #include "i2c.h" 66 #include "i2c-algo-ibm_ocp.h" 67 67 #include <asm/ocp.h> 68 68 … … 857 857 858 858 static struct i2c_algorithm iic_algo = { 859 "IBM on-chip IIC algorithm", 860 I2C_ALGO_OCP, 861 iic_xfer, 862 NULL, 863 NULL, /* slave_xmit */ 864 NULL, /* slave_recv */ 865 algo_control, /* ioctl */ 866 iic_func, /* functionality */ 859 .name = "IBM on-chip IIC algorithm", 860 .id = I2C_ALGO_OCP, 861 .master_xfer = iic_xfer, 862 .algo_control = algo_control, 863 .functionality = iic_func, 867 864 }; 868 869 865 870 866 /* … … 891 887 adap->retries = 3; /* be replaced by defines */ 892 888 893 #ifdef MODULE894 889 MOD_INC_USE_COUNT; 895 #endif896 897 890 iic_init(iic_adap); 898 891 i2c_add_adapter(adap); … … 918 911 DEB2(printk(KERN_DEBUG "i2c-algo-iic.o: adapter unregistered: %s\n",adap->name)); 919 912 920 #ifdef MODULE921 913 MOD_DEC_USE_COUNT; 922 #endif923 914 return 0; 924 }925 926 927 //928 // Done929 //930 int __init i2c_algo_iic_init (void)931 {932 printk(KERN_INFO "IBM On-chip iic (i2c) algorithm module 2002.27.03\n");933 return 0;934 }935 936 937 void i2c_algo_iic_exit(void)938 {939 return;940 915 } 941 916 … … 960 935 "debug level - 0 off; 1 normal; 2,3 more verbose; 9 iic-protocol"); 961 936 962 963 module_init(i2c_algo_iic_init);964 module_exit(i2c_algo_iic_exit); -
i2c/branches/lk2-4/kernel/i2c-algo-ibm_ocp.h
r3714 r3763 26 26 Changes made to support the IIC peripheral on the IBM PPC 405 */ 27 27 28 #ifndef I2C_ALGO_I IC_H29 #define I2C_ALGO_I IC_H 128 #ifndef I2C_ALGO_IBM_OCP_H 29 #define I2C_ALGO_IBM_OCP_H 1 30 30 31 31 /* --- Defines for pcf-adapters --------------------------------------- */ 32 #include <linux/i2c.h>32 #include "i2c.h" 33 33 34 34 struct i2c_algo_iic_data { … … 53 53 int i2c_ocp_del_bus(struct i2c_adapter *); 54 54 55 #endif /* I2C_ALGO_I IC_H */55 #endif /* I2C_ALGO_IBM_OCP_H */ -
i2c/branches/lk2-4/kernel/i2c-algo-pcf.c
r3753 r3763 38 38 #include <linux/errno.h> 39 39 #include <linux/sched.h> 40 40 41 #include "i2c.h" 41 42 #include "i2c-algo-pcf.h" … … 442 443 443 444 static struct i2c_algorithm pcf_algo = { 444 "PCF8584 algorithm", 445 I2C_ALGO_PCF, 446 pcf_xfer, 447 NULL, 448 NULL, /* slave_xmit */ 449 NULL, /* slave_recv */ 450 algo_control, /* ioctl */ 451 pcf_func, /* functionality */ 445 .name = "PCF8584 algorithm", 446 .id = I2C_ALGO_PCF, 447 .master_xfer = pcf_xfer, 448 .algo_control = algo_control, 449 .functionality = pcf_func, 452 450 }; 453 451 … … 475 473 } 476 474 477 #ifdef MODULE478 475 MOD_INC_USE_COUNT; 479 #endif480 481 476 i2c_add_adapter(adap); 482 477 … … 510 505 int i2c_pcf_del_bus(struct i2c_adapter *adap) 511 506 { 512 int res;513 if ((res = i2c_del_adapter(adap)) < 0)514 return res;515 DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: adapter unregistered: %s\n",adap->name));516 517 #ifdef MODULE518 507 MOD_DEC_USE_COUNT; 519 #endif 520 return 0; 521 } 522 523 int __init i2c_algo_pcf_init (void) 524 { 525 printk(KERN_INFO "i2c-algo-pcf.o: i2c pcf8584 algorithm module version %s (%s)\n", I2C_VERSION, I2C_DATE); 526 return 0; 527 } 528 508 return i2c_del_adapter(adap); 509 } 529 510 530 511 EXPORT_SYMBOL(i2c_pcf_add_bus); 531 512 EXPORT_SYMBOL(i2c_pcf_del_bus); 532 513 533 #ifdef MODULE534 514 MODULE_AUTHOR("Hans Berglund <hb@spacetec.no>"); 535 515 MODULE_DESCRIPTION("I2C-Bus PCF8584 algorithm"); … … 542 522 MODULE_PARM_DESC(i2c_debug, 543 523 "debug level - 0 off; 1 normal; 2,3 more verbose; 9 pcf-protocol"); 544 545 546 int init_module(void)547 {548 return i2c_algo_pcf_init();549 }550 551 void cleanup_module(void)552 {553 }554 #endif -
i2c/branches/lk2-4/kernel/i2c-core.c
r3753 r3763 37 37 #include <linux/init.h> 38 38 39 40 39 #include <asm/uaccess.h> 41 40 … … 78 77 79 78 #ifdef CONFIG_PROC_FS 80 81 static int i2cproc_init(void);82 static int i2cproc_cleanup(void);83 84 85 79 static ssize_t i2cproc_bus_read(struct file * file, char * buf,size_t count, 86 80 loff_t *ppos); … … 88 82 int *eof , void *private); 89 83 84 static int i2cproc_register(struct i2c_adapter *adap, int bus); 85 static void i2cproc_remove(int bus); 90 86 /* To implement the dynamic /proc/bus/i2c-? files, we need our own 91 87 implementation of the read hook */ … … 93 89 .read = i2cproc_bus_read, 94 90 }; 95 96 97 static int i2cproc_initialized = 0;98 99 #else /* undef CONFIG_PROC_FS */100 101 #define i2cproc_init() 0102 #define i2cproc_cleanup() 0103 104 91 #endif /* CONFIG_PROC_FS */ 105 92 … … 139 126 140 127 #ifdef CONFIG_PROC_FS 141 142 if (i2cproc_initialized) { 143 char name[8]; 144 struct proc_dir_entry *proc_entry; 145 146 sprintf(name,"i2c-%d", i); 147 148 proc_entry = create_proc_entry(name,0,proc_bus); 149 if (! proc_entry) { 150 printk(KERN_ERR "i2c-core.o: Could not create /proc/bus/%s\n", 151 name); 152 res = -ENOENT; 153 goto ERROR1; 154 } 155 156 proc_entry->proc_fops = &i2cproc_operations; 157 proc_entry->owner = THIS_MODULE; 158 adap->inode = proc_entry->low_ino; 159 } 160 128 res = i2cproc_register(adap, i); 129 if (res<0) 130 goto ERROR1; 161 131 #endif /* def CONFIG_PROC_FS */ 162 132 … … 237 207 } 238 208 #ifdef CONFIG_PROC_FS 239 if (i2cproc_initialized) { 240 char name[8]; 241 sprintf(name,"i2c-%d", i); 242 remove_proc_entry(name,proc_bus); 243 } 209 i2cproc_remove(i); 244 210 #endif /* def CONFIG_PROC_FS */ 245 211 … … 462 428 } 463 429 464 void i2c_inc_use_client(struct i2c_client *client) 465 { 466 467 if (client->driver->inc_use != NULL) 468 client->driver->inc_use(client); 469 470 if (client->adapter->inc_use != NULL) 471 client->adapter->inc_use(client->adapter); 472 } 473 474 void i2c_dec_use_client(struct i2c_client *client) 475 { 476 477 if (client->driver->dec_use != NULL) 478 client->driver->dec_use(client); 479 480 if (client->adapter->dec_use != NULL) 481 client->adapter->dec_use(client->adapter); 430 static void i2c_inc_use_client(struct i2c_client *client) 431 { 432 __MOD_INC_USE_COUNT(client->driver->owner); 433 __MOD_INC_USE_COUNT(client->adapter->owner); 434 } 435 436 static void i2c_dec_use_client(struct i2c_client *client) 437 { 438 __MOD_DEC_USE_COUNT(client->driver->owner); 439 __MOD_DEC_USE_COUNT(client->adapter->owner); 482 440 } 483 441 … … 551 509 int i2c_use_client(struct i2c_client *client) 552 510 { 553 if (client->flags & I2C_CLIENT_ALLOW_USE) {554 if (client->flags & I2C_CLIENT_ALLOW_MULTIPLE_USE) 511 if (client->flags & I2C_CLIENT_ALLOW_USE) { 512 if (client->flags & I2C_CLIENT_ALLOW_MULTIPLE_USE) 555 513 client->usage_count++; 556 else { 557 if(client->usage_count > 0) 558 return -EBUSY; 559 else 560 client->usage_count++; 561 } 514 else if (client->usage_count > 0) 515 return -EBUSY; 516 else 517 client->usage_count++; 562 518 } 563 519 … … 590 546 591 547 #ifdef CONFIG_PROC_FS 592 593 548 594 549 /* This function generates the output for /proc/bus/i2c */ … … 683 638 } 684 639 685 int i2cproc_init(void) 686 { 687 640 641 static int i2cproc_register(struct i2c_adapter *adap, int bus) 642 { 643 char name[8]; 644 struct proc_dir_entry *proc_entry; 645 646 sprintf(name,"i2c-%d", bus); 647 proc_entry = create_proc_entry(name,0,proc_bus); 648 if (! proc_entry) { 649 printk(KERN_ERR "i2c-core.o: Could not create /proc/bus/%s\n", 650 name); 651 return -ENOENT; 652 } 653 654 proc_entry->proc_fops = &i2cproc_operations; 655 proc_entry->owner = THIS_MODULE; 656 adap->inode = proc_entry->low_ino; 657 return 0; 658 } 659 660 static void i2cproc_remove(int bus) 661 { 662 char name[8]; 663 sprintf(name,"i2c-%d", bus); 664 remove_proc_entry(name, proc_bus); 665 } 666 667 static int __init i2cproc_init(void) 668 { 688 669 struct proc_dir_entry *proc_bus_i2c; 689 670 690 i2cproc_initialized = 0;691 692 if (! proc_bus) {693 printk(KERN_ERR "i2c-core.o: /proc/bus/ does not exist");694 i2cproc_cleanup();695 return -ENOENT;696 }697 671 proc_bus_i2c = create_proc_entry("i2c",0,proc_bus); 698 672 if (!proc_bus_i2c) { 699 673 printk(KERN_ERR "i2c-core.o: Could not create /proc/bus/i2c"); 700 i2cproc_cleanup();701 674 return -ENOENT; 702 675 } 676 703 677 proc_bus_i2c->read_proc = &read_bus_i2c; 704 678 proc_bus_i2c->owner = THIS_MODULE; 705 i2cproc_initialized += 2;706 679 return 0; 707 680 } 708 681 709 int i2cproc_cleanup(void) 710 { 711 712 if (i2cproc_initialized >= 1) { 713 remove_proc_entry("i2c",proc_bus); 714 i2cproc_initialized -= 2; 715 } 716 return 0; 717 } 718 719 682 static void __exit i2cproc_cleanup(void) 683 { 684 remove_proc_entry("i2c",proc_bus); 685 } 720 686 #endif /* def CONFIG_PROC_FS */ 687 721 688 722 689 /* ---------------------------------------------------- … … 1454 1421 init_MUTEX(&driver_lock); 1455 1422 1423 #ifdef CONFIG_PROC_FS 1456 1424 i2cproc_init(); 1457 1425 #endif 1426 1458 1427 return 0; 1459 1428 } … … 1461 1430 static void __exit i2c_exit(void) 1462 1431 { 1432 #ifdef CONFIG_PROC_FS 1463 1433 i2cproc_cleanup(); 1464 }1465 1466 #ifndef MODULE1467 #ifdef CONFIG_I2C_CHARDEV1468 extern int i2c_dev_init(void);1469 1434 #endif 1470 #ifdef CONFIG_I2C_ALGOBIT 1471 extern int i2c_algo_bit_init(void); 1472 #endif 1473 #ifdef CONFIG_I2C_PHILIPSPAR 1474 extern int i2c_bitlp_init(void); 1475 #endif 1476 #ifdef CONFIG_I2C_ELV 1477 extern int i2c_bitelv_init(void); 1478 #endif 1479 #ifdef CONFIG_I2C_VELLEMAN 1480 extern int i2c_bitvelle_init(void); 1481 #endif 1482 #ifdef CONFIG_I2C_PPORT 1483 extern int i2c_bitpport_init(void); 1484 #endif 1485 #ifdef CONFIG_I2C_FRODO 1486 extern int i2c_frodo_init(void); 1487 #endif 1488 #ifdef CONFIG_I2C_BITVIA 1489 extern int i2c_bitvia_init(void); 1490 #endif 1491 1492 #ifdef CONFIG_I2C_ALGOPCF 1493 extern int i2c_algo_pcf_init(void); 1494 #endif 1495 #ifdef CONFIG_I2C_ELEKTOR 1496 extern int i2c_pcfisa_init(void); 1497 #endif 1498 #ifdef CONFIG_I2C_PCFEPP 1499 extern int i2c_pcfepp_init(void); 1500 #endif 1501 1502 #ifdef CONFIG_I2C_ALGO8XX 1503 extern int i2c_algo_8xx_init(void); 1504 #endif 1505 #ifdef CONFIG_I2C_RPXLITE 1506 extern int i2c_rpx_init(void); 1507 #endif 1508 #ifdef CONFIG_I2C_IBM_OCP_ALGO 1509 extern int i2c_algo_iic_init(void); 1510 #endif 1511 #ifdef CONFIG_I2C_IBM_OCP_ADAP 1512 extern int iic_ibmocp_init(void); 1513 #endif 1514 #ifdef CONFIG_I2C_PROC 1515 extern int sensors_init(void); 1516 #endif 1517 1518 /* This is needed for automatic patch generation: sensors code starts here */ 1519 /* This is needed for automatic patch generation: sensors code ends here */ 1520 1521 int __init i2c_init_all(void) 1522 { 1523 /* --------------------- global ----- */ 1524 i2c_init(); 1525 1526 #ifdef CONFIG_I2C_CHARDEV 1527 i2c_dev_init(); 1528 #endif 1529 /* --------------------- bit -------- */ 1530 #ifdef CONFIG_I2C_ALGOBIT 1531 i2c_algo_bit_init(); 1532 #endif 1533 #ifdef CONFIG_I2C_PHILIPSPAR 1534 i2c_bitlp_init(); 1535 #endif 1536 #ifdef CONFIG_I2C_ELV 1537 i2c_bitelv_init(); 1538 #endif 1539 #ifdef CONFIG_I2C_VELLEMAN 1540 i2c_bitvelle_init(); 1541 #endif 1542 #ifdef CONFIG_I2C_PPORT 1543 i2c_bitpport_init(); 1544 #endif 1545 #ifdef CONFIG_I2C_FRODO 1546 i2c_frodo_init(); 1547 #endif 1548 #ifdef CONFIG_I2C_BITVIA 1549 i2c_bitvia_init(); 1550 #endif 1551 1552 /* --------------------- pcf -------- */ 1553 #ifdef CONFIG_I2C_ALGOPCF 1554 i2c_algo_pcf_init(); 1555 #endif 1556 #ifdef CONFIG_I2C_ELEKTOR 1557 i2c_pcfisa_init(); 1558 #endif 1559 #ifdef CONFIG_I2C_PCFEPP 1560 i2c_pcfepp_init(); 1561 #endif 1562 1563 /* --------------------- 8xx -------- */ 1564 #ifdef CONFIG_I2C_ALGO8XX 1565 i2c_algo_8xx_init(); 1566 #endif 1567 #ifdef CONFIG_I2C_RPXLITE 1568 i2c_rpx_init(); 1569 #endif 1570 #ifdef CONFIG_I2C_IBM_OCP_ALGO 1571 i2c_algo_iic_init(); 1572 #endif 1573 #ifdef CONFIG_I2C_IBM_OCP_ADAP 1574 iic_ibmocp_init(); 1575 #endif 1576 1577 /* -------------- proc interface ---- */ 1578 #ifdef CONFIG_I2C_PROC 1579 sensors_init(); 1580 #endif 1581 /* This is needed for automatic patch generation: sensors code starts here */ 1582 /* This is needed for automatic patch generation: sensors code ends here */ 1583 1584 return 0; 1585 } 1586 1587 #endif 1588 1589 1435 } 1590 1436 1591 1437 EXPORT_SYMBOL(i2c_add_adapter); … … 1595 1441 EXPORT_SYMBOL(i2c_attach_client); 1596 1442 EXPORT_SYMBOL(i2c_detach_client); 1597 EXPORT_SYMBOL(i2c_inc_use_client);1598 EXPORT_SYMBOL(i2c_dec_use_client);1599 1443 EXPORT_SYMBOL(i2c_get_client); 1600 1444 EXPORT_SYMBOL(i2c_use_client); … … 1629 1473 MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>"); 1630 1474 MODULE_DESCRIPTION("I2C-Bus main module"); 1475 MODULE_LICENSE("GPL"); 1476 1631 1477 MODULE_PARM(i2c_debug, "i"); 1632 1478 MODULE_PARM_DESC(i2c_debug,"debug level"); 1633 MODULE_LICENSE("GPL");1634 1479 1635 1480 module_init(i2c_init); -
i2c/branches/lk2-4/kernel/i2c-dev.c
r3753 r3763 102 102 }; 103 103 104 static int i2cdev_initialized;105 106 107 104 static ssize_t i2cdev_read (struct file *file, char *buf, size_t count, 108 105 loff_t *offset) … … 126 123 127 124 #ifdef DEBUG 128 printk(KERN_DEBUG "i2c-dev.o: i2c-%d reading %d bytes.\n", MINOR(inode->i_rdev),125 printk(KERN_DEBUG "i2c-dev.o: i2c-%d reading %d bytes.\n",minor(inode->i_rdev), 129 126 count); 130 127 #endif … … 161 158 162 159 #ifdef DEBUG 163 printk(KERN_DEBUG "i2c-dev.o: i2c-%d writing %d bytes.\n", MINOR(inode->i_rdev),160 printk(KERN_DEBUG "i2c-dev.o: i2c-%d writing %d bytes.\n",minor(inode->i_rdev), 164 161 count); 165 162 #endif … … 182 179 #ifdef DEBUG 183 180 printk(KERN_DEBUG "i2c-dev.o: i2c-%d ioctl, cmd: 0x%x, arg: %lx.\n", 184 MINOR(inode->i_rdev),cmd, arg);181 minor(inode->i_rdev),cmd, arg); 185 182 #endif /* DEBUG */ 186 183 … … 355 352 int i2cdev_open (struct inode *inode, struct file *file) 356 353 { 357 unsigned int minor = MINOR(inode->i_rdev);354 unsigned int minor = minor(inode->i_rdev); 358 355 struct i2c_client *client; 359 356 … … 374 371 file->private_data = client; 375 372 376 if (i2cdev_adaps[minor]->inc_use) 377 i2cdev_adaps[minor]->inc_use(i2cdev_adaps[minor]); 373 __MOD_INC_USE_COUNT(i2cdev_adaps[minor]->owner); 378 374 379 375 #ifdef DEBUG … … 385 381 static int i2cdev_release (struct inode *inode, struct file *file) 386 382 { 387 unsigned int minor = MINOR(inode->i_rdev);383 unsigned int minor = minor(inode->i_rdev); 388 384 kfree(file->private_data); 389 385 file->private_data=NULL; … … 391 387 printk(KERN_DEBUG "i2c-dev.o: Closed: i2c-%d\n", minor); 392 388 #endif 393 lock_kernel(); 394 if (i2cdev_adaps[minor]->dec_use) 395 i2cdev_adaps[minor]->dec_use(i2cdev_adaps[minor]); 396 unlock_kernel(); 389 __MOD_DEC_USE_COUNT(i2cdev_adaps[minor]->owner); 397 390 return 0; 398 391 } … … 447 440 } 448 441 449 static void i2cdev_cleanup(void)442 int __init i2c_dev_init(void) 450 443 { 451 444 int res; 452 445 453 if (i2cdev_initialized >= 2) {454 if ((res = i2c_del_driver(&i2cdev_driver))) {455 printk(KERN_ERR "i2c-dev.o: Driver deregistration failed, "456 "module not removed.\n");457 }458 i2cdev_initialized --;459 }460 461 if (i2cdev_initialized >= 1) {462 #ifdef CONFIG_DEVFS_FS463 devfs_unregister(devfs_handle);464 #endif465 if ((res = unregister_chrdev(I2C_MAJOR,"i2c"))) {466 printk(KERN_ERR "i2c-dev.o: unable to release major %d for i2c bus\n",467 I2C_MAJOR);468 }469 i2cdev_initialized --;470 }471 }472 473 int __init i2c_dev_init(void)474 {475 int res;476 477 446 printk(KERN_INFO "i2c-dev.o: i2c /dev entries driver module version %s (%s)\n", I2C_VERSION, I2C_DATE); 478 447 479 i2cdev_initialized = 0;480 448 #ifdef CONFIG_DEVFS_FS 481 449 if (devfs_register_chrdev(I2C_MAJOR, "i2c", &i2cdev_fops)) { … … 490 458 devfs_handle = devfs_mk_dir(NULL, "i2c", NULL); 491 459 #endif 492 i2cdev_initialized ++;493 494 460 if ((res = i2c_add_driver(&i2cdev_driver))) { 495 461 printk(KERN_ERR "i2c-dev.o: Driver registration failed, module not inserted.\n"); 496 i2cdev_cleanup(); 462 #ifdef CONFIG_DEVFS_FS 463 devfs_unregister(devfs_handle); 464 #endif 465 unregister_chrdev(I2C_MAJOR,"i2c"); 497 466 return res; 498 467 } 499 i2cdev_initialized ++; 500 return 0; 501 } 502 503 EXPORT_NO_SYMBOLS; 468 return 0; 469 } 470 471 static void __exit i2c_dev_exit(void) 472 { 473 i2c_del_driver(&i2cdev_driver); 474 #ifdef CONFIG_DEVFS_FS 475 devfs_unregister(devfs_handle); 476 #endif 477 unregister_chrdev(I2C_MAJOR,"i2c"); 478 } 504 479 505 480 MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl> and Simon G. Vogl <simon@tk.uni-linz.ac.at>"); … … 508 483 509 484 module_init(i2c_dev_init); 510 module_exit(i2c dev_cleanup);485 module_exit(i2c_dev_exit); -
i2c/branches/lk2-4/kernel/i2c-dev.h
r3661 r3763 22 22 /* $Id$ */ 23 23 24 #ifndef I2C_DEV_H25 #define I2C_DEV_H26 27 24 #ifndef _LINUX_I2C_DEV_H 25 #define _LINUX_I2C_DEV_H 26 27 #include <linux/version.h> 28 28 #include <linux/types.h> 29 29 #include "i2c.h" 30 31 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,18) 32 #define minor(d) MINOR(d) 33 #endif 30 34 31 35 /* Some IOCTL commands are defined in <linux/i2c.h> */ … … 216 220 #endif /* ndef __KERNEL__ */ 217 221 218 #endif 222 #endif /* _LINUX_I2C_DEV_H */ -
i2c/branches/lk2-4/kernel/i2c-elektor.c
r3754 r3763 36 36 #include <linux/pci.h> 37 37 #include <linux/wait.h> 38 38 39 #include "i2c.h" 39 40 #include "i2c-algo-pcf.h" 40 #include "i2c-elektor.h"41 41 42 42 #include <asm/io.h> … … 143 143 { 144 144 if (!mmapped) { 145 if (check_region(base, 2) < 0 ) { 146 printk(KERN_ERR "i2c-elektor.o: requested I/O region (0x%X:2) is in use.\n", base); 145 if (!request_region(base, 2, "i2c (isa bus adapter)")) { 146 printk(KERN_ERR 147 "i2c-elektor.o: requested I/O region (0x%X:2) " 148 "is in use.\n", base); 147 149 return -ENODEV; 148 } else {149 request_region(base, 2, "i2c (isa bus adapter)");150 150 } 151 151 } … … 158 158 } 159 159 return 0; 160 }161 162 163 static void __exit pcf_isa_exit(void)164 {165 if (irq > 0) {166 disable_irq(irq);167 free_irq(irq, 0);168 }169 if (!mmapped) {170 release_region(base , 2);171 }172 }173 174 175 static int pcf_isa_reg(struct i2c_client *client)176 {177 return 0;178 }179 180 181 static int pcf_isa_unreg(struct i2c_client *client)182 {183 return 0;184 }185 186 static void pcf_isa_inc_use(struct i2c_adapter *adap)187 {188 #ifdef MODULE189 MOD_INC_USE_COUNT;190 #endif191 }192 193 static void pcf_isa_dec_use(struct i2c_adapter *adap)194 {195 #ifdef MODULE196 MOD_DEC_USE_COUNT;197 #endif198 160 } 199 161 … … 211 173 .udelay = 10, 212 174 .mdelay = 10, 213 .timeout = 100,175 .timeout = HZ, 214 176 }; 215 177 216 178 static struct i2c_adapter pcf_isa_ops = { 179 .owner = THIS_MODULE, 217 180 .name = "PCF8584 ISA adapter", 218 181 .id = I2C_HW_P_ELEK, 219 182 .algo_data = &pcf_isa_data, 220 .inc_use = pcf_isa_inc_use,221 .dec_use = pcf_isa_dec_use,222 .client_register = pcf_isa_reg,223 .client_unregister = pcf_isa_unreg,224 183 }; 225 184 226 int __init i2c_pcfisa_init(void)185 static int __init i2c_pcfisa_init(void) 227 186 { 228 187 #ifdef __alpha__ … … 282 241 283 242 init_waitqueue_head(&pcf_wait); 284 if (pcf_isa_init() == 0) { 285 if (i2c_pcf_add_bus(&pcf_isa_ops) < 0) { 286 pcf_isa_exit(); 287 return -ENODEV; 288 } 289 } else { 243 if (pcf_isa_init()) 290 244 return -ENODEV; 291 } 245 if (i2c_pcf_add_bus(&pcf_isa_ops) < 0) 246 goto fail; 292 247 293 248 printk(KERN_ERR "i2c-elektor.o: found device at %#x.\n", base); 294 249 295 250 return 0; 296 } 297 298 299 EXPORT_NO_SYMBOLS; 300 301 #ifdef MODULE 251 252 fail: 253 if (irq > 0) { 254 disable_irq(irq); 255 free_irq(irq, 0); 256 } 257 258 if (!mmapped) 259 release_region(base , 2); 260 return -ENODEV; 261 } 262 263 264 static void i2c_pcfisa_exit(void) 265 { 266 i2c_pcf_del_bus(&pcf_isa_ops); 267 268 if (irq > 0) { 269 disable_irq(irq); 270 free_irq(irq, 0); 271 } 272 273 if (!mmapped) 274 release_region(base , 2); 275 } 276 302 277 MODULE_AUTHOR("Hans Berglund <hb@spacetec.no>"); 303 278 MODULE_DESCRIPTION("I2C-Bus adapter routines for PCF8584 ISA bus adapter"); … … 311 286 MODULE_PARM(i2c_debug, "i"); 312 287 313 int init_module(void) 314 { 315 return i2c_pcfisa_init(); 316 } 317 318 void cleanup_module(void) 319 { 320 i2c_pcf_del_bus(&pcf_isa_ops); 321 pcf_isa_exit(); 322 } 323 324 #endif 288 module_init(i2c_pcfisa_init); 289 module_exit(i2c_pcfisa_exit); -
i2c/branches/lk2-4/kernel/i2c-elv.c
r3753 r3763 89 89 static int bit_elv_init(void) 90 90 { 91 if (check_region(base,(base == 0x3bc)? 3 : 8) < 0 ) { 92 return -ENODEV; 93 } else { 94 /* test for ELV adap. */ 95 if (inb(base+1) & 0x80) { /* BUSY should be high */ 96 DEBINIT(printk(KERN_DEBUG "i2c-elv.o: Busy was low.\n")); 97 return -ENODEV; 98 } else { 99 outb(0x0c,base+2); /* SLCT auf low */ 100 udelay(400); 101 if ( !(inb(base+1) && 0x10) ) { 102 outb(0x04,base+2); 103 DEBINIT(printk(KERN_DEBUG "i2c-elv.o: Select was high.\n")); 104 return -ENODEV; 105 } 106 } 107 request_region(base,(base == 0x3bc)? 3 : 8, 108 "i2c (ELV adapter)"); 109 PortData = 0; 110 bit_elv_setsda((void*)base,1); 111 bit_elv_setscl((void*)base,1); 91 if (!request_region(base, (base == 0x3bc) ? 3 : 8, 92 "i2c (ELV adapter)")) 93 return -ENODEV; 94 95 if (inb(base+1) & 0x80) { /* BUSY should be high */ 96 DEBINIT(printk(KERN_DEBUG "i2c-elv.o: Busy was low.\n")); 97 goto fail; 98 } 99 100 outb(0x0c,base+2); /* SLCT auf low */ 101 udelay(400); 102 if (!(inb(base+1) && 0x10)) { 103 outb(0x04,base+2); 104 DEBINIT(printk(KERN_DEBUG "i2c-elv.o: Select was high.\n")); 105 goto fail; 112 106 } 107 108 PortData = 0; 109 bit_elv_setsda((void*)base,1); 110 bit_elv_setscl((void*)base,1); 113 111 return 0; 114 }115 112 116 static void __exit bit_elv_exit(void) 117 { 118 release_region( base , (base == 0x3bc)? 3 : 8 ); 119 } 120 121 static int bit_elv_reg(struct i2c_client *client) 122 { 123 return 0; 124 } 125 126 static int bit_elv_unreg(struct i2c_client *client) 127 { 128 return 0; 129 } 130 131 static void bit_elv_inc_use(struct i2c_adapter *adap) 132 { 133 #ifdef MODULE 134 MOD_INC_USE_COUNT; 135 #endif 136 } 137 138 static void bit_elv_dec_use(struct i2c_adapter *adap) 139 { 140 #ifdef MODULE 141 MOD_DEC_USE_COUNT; 142 #endif 113 fail: 114 release_region(base , (base == 0x3bc) ? 3 : 8); 115 return -ENODEV; 143 116 } 144 117 … … 148 121 */ 149 122 static struct i2c_algo_bit_data bit_elv_data = { 150 NULL, 151 bit_elv_setsda, 152 bit_elv_setscl, 153 bit_elv_getsda, 154 bit_elv_getscl, 155 80, 80, HZ, /* waits, timeout */ 123 .setsda = bit_elv_setsda, 124 .setscl = bit_elv_setscl, 125 .getsda = bit_elv_getsda, 126 .getscl = bit_elv_getscl, 127 .udelay = 80, 128 .mdelay = 80, 129 .timeout = HZ 156 130 }; 157 131 158 132 static struct i2c_adapter bit_elv_ops = { 159 "ELV Parallel port adaptor", 160 I2C_HW_B_ELV, 161 NULL, 162 &bit_elv_data, 163 bit_elv_inc_use, 164 bit_elv_dec_use, 165 bit_elv_reg, 166 bit_elv_unreg, 133 .owner = THIS_MODULE, 134 .name = "ELV Parallel port adaptor", 135 .id = I2C_HW_B_ELV, 136 .algo_data = &bit_elv_data, 167 137 }; 168 138 169 int __init i2c_bitelv_init(void)139 static int __init i2c_bitelv_init(void) 170 140 { 171 141 printk(KERN_INFO "i2c-elv.o: i2c ELV parallel port adapter module version %s (%s)\n", I2C_VERSION, I2C_DATE); … … 193 163 } 194 164 165 static void __exit i2c_bitelv_exit(void) 166 { 167 i2c_bit_del_bus(&bit_elv_ops); 168 release_region(base , (base == 0x3bc) ? 3 : 8); 169 } 195 170 196 171 EXPORT_NO_SYMBOLS; 197 172 198 #ifdef MODULE199 173 MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>"); 200 174 MODULE_DESCRIPTION("I2C-Bus adapter routines for ELV parallel port adapter"); … … 203 177 MODULE_PARM(base, "i"); 204 178 205 int init_module(void) 206 { 207 return i2c_bitelv_init(); 208 } 209 210 void cleanup_module(void) 211 { 212 i2c_bit_del_bus(&bit_elv_ops); 213 bit_elv_exit(); 214 } 215 216 #endif 179 module_init(i2c_bitelv_init); 180 module_exit(i2c_bitelv_exit); -
i2c/branches/lk2-4/kernel/i2c-frodo.c
r3753 r3763 23 23 #include <asm/hardware.h> 24 24 25 #include <linux/i2c.h>26 #include <linux/i2c-algo-bit.h>25 #include "i2c.h" 26 #include "i2c-algo-bit.h" 27 27 28 28 static void frodo_setsda (void *data,int state) … … 62 62 }; 63 63 64 static int frodo_client_register (struct i2c_client *client)65 {66 return (0);67 }68 69 static int frodo_client_unregister (struct i2c_client *client)70 {71 return (0);72 }73 74 static void frodo_inc_use (struct i2c_adapter *adapter)75 {76 MOD_INC_USE_COUNT;77 }78 79 static void frodo_dec_use (struct i2c_adapter *adapter)80 {81 MOD_DEC_USE_COUNT;82 }83 84 64 static struct i2c_adapter frodo_ops = { 65 .owner = THIS_MODULE, 85 66 .name = "Frodo adapter driver", 86 67 .id = I2C_HW_B_FRODO, 87 68 .algo_data = &bit_frodo_data, 88 .inc_use = frodo_inc_use,89 .dec_use = frodo_dec_use,90 .client_register = frodo_client_register,91 .client_unregister = frodo_client_unregister92 69 }; 93 70 94 int __init i2c_frodo_init (void)71 static int __init i2c_frodo_init (void) 95 72 { 96 return (i2c_bit_add_bus (&frodo_ops));73 return i2c_bit_add_bus(&frodo_ops); 97 74 } 98 99 EXPORT_NO_SYMBOLS;100 75 101 76 static void __exit i2c_frodo_exit (void) 102 77 { 103 i2c_bit_del_bus (&frodo_ops);78 i2c_bit_del_bus(&frodo_ops); 104 79 } 105 80 … … 108 83 MODULE_LICENSE ("GPL"); 109 84 110 EXPORT_NO_SYMBOLS;111 112 85 module_init (i2c_frodo_init); 113 86 module_exit (i2c_frodo_exit); -
i2c/branches/lk2-4/kernel/i2c-pcf-epp.c
r3754 r3763 175 175 } 176 176 177 178 static void __exit pcf_epp_exit(void)179 {180 if (gpe.pe_irq > 0) {181 disable_irq(gpe.pe_irq);182 free_irq(gpe.pe_irq, 0);183 }184 release_region(gpe.pe_base , 5);185 }186 187 188 static int pcf_epp_reg(struct i2c_client *client)189 {190 return 0;191 }192 193 194 static int pcf_epp_unreg(struct i2c_client *client)195 {196 return 0;197 }198 199 static void pcf_epp_inc_use(struct i2c_adapter *adap)200 {201 #ifdef MODULE202 MOD_INC_USE_COUNT;203 #endif204 }205 206 static void pcf_epp_dec_use(struct i2c_adapter *adap)207 {208 #ifdef MODULE209 MOD_DEC_USE_COUNT;210 #endif211 }212 213 214 177 /* ------------------------------------------------------------------------ 215 178 * Encapsulate the above functions in the correct operations structure. … … 217 180 */ 218 181 static struct i2c_algo_pcf_data pcf_epp_data = { 219 NULL, 220 pcf_epp_setbyte, 221 pcf_epp_getbyte, 222 pcf_epp_getown, 223 pcf_epp_getclock, 224 pcf_epp_waitforpin, 225 80, 80, 100, /* waits, timeout */ 182 .setpcf = pcf_epp_setbyte, 183 .getpcf = pcf_epp_getbyte, 184 .getown = pcf_epp_getown, 185 .getclock = pcf_epp_getclock, 186 .waitforpin = pcf_epp_waitforpin, 187 .udelay = 80, 188 .mdelay = 80, 189 .timeout = HZ, 226 190 }; 227 191 228 192 static struct i2c_adapter pcf_epp_ops = { 229 "PCF8584 EPP adapter", 230 I2C_HW_P_LP, 231 NULL, 232 &pcf_epp_data, 233 pcf_epp_inc_use, 234 pcf_epp_dec_use, 235 pcf_epp_reg, 236 pcf_epp_unreg, 193 .owner = THIS_MODULE, 194 .name = "PCF8584 EPP adapter", 195 .id = I2C_HW_P_LP, 196 .algo_data = &pcf_epp_data, 237 197 }; 238 198 239 int __init i2c_pcfepp_init(void)199 static int __init i2c_pcfepp_init(void) 240 200 { 241 201 struct i2c_pcf_epp *pepp = &gpe; … … 282 242 } 283 243 284 285 EXPORT_NO_SYMBOLS; 286 287 #ifdef MODULE 244 static void __exit pcf_epp_exit(void) 245 { 246 i2c_pcf_del_bus(&pcf_epp_ops); 247 if (gpe.pe_irq > 0) { 248 disable_irq(gpe.pe_irq); 249 free_irq(gpe.pe_irq, 0); 250 } 251 release_region(gpe.pe_base , 5); 252 } 253 288 254 MODULE_AUTHOR("Hans Berglund <hb@spacetec.no> \n modified by Ryosuke Tajima <rosk@jsk.t.u-tokyo.ac.jp>"); 289 255 MODULE_DESCRIPTION("I2C-Bus adapter routines for PCF8584 EPP parallel port adapter"); … … 295 261 MODULE_PARM(i2c_debug, "i"); 296 262 297 int init_module(void) 298 { 299 return i2c_pcfepp_init(); 300 } 301 302 void cleanup_module(void) 303 { 304 i2c_pcf_del_bus(&pcf_epp_ops); 305 pcf_epp_exit(); 306 } 307 308 #endif 309 310 263 module_init(i2c_pcfepp_init); 264 module_exit(pcf_epp_exit); -
i2c/branches/lk2-4/kernel/i2c-philips-par.c
r3753 r3763 130 130 } 131 131 132 static int bit_lp_reg(struct i2c_client *client)133 {134 return 0;135 }136 137 static int bit_lp_unreg(struct i2c_client *client)138 {139 return 0;140 }141 142 static void bit_lp_inc_use(struct i2c_adapter *adap)143 {144 MOD_INC_USE_COUNT;145 }146 147 static void bit_lp_dec_use(struct i2c_adapter *adap)148 {149 MOD_DEC_USE_COUNT;150 }151 152 132 /* ------------------------------------------------------------------------ 153 133 * Encapsulate the above functions in the correct operations structure. … … 156 136 157 137 static struct i2c_algo_bit_data bit_lp_data = { 158 NULL, 159 bit_lp_setsda, 160 bit_lp_setscl, 161 bit_lp_getsda, 162 bit_lp_getscl, 163 80, 80, HZ, /* waits, timeout */ 138 .setsda = bit_lp_setsda, 139 .setscl = bit_lp_setscl, 140 .getsda = bit_lp_getsda, 141 .getscl = bit_lp_getscl, 142 .udelay = 80, 143 .mdelay = 80, 144 .timeout = HZ 164 145 }; 165 146 166 147 static struct i2c_algo_bit_data bit_lp_data2 = { 167 NULL,168 bit_lp_setsda2,169 bit_lp_setscl2,170 bit_lp_getsda2,171 NULL,172 80, 80, HZ, /* waits, timeout */148 .setsda = bit_lp_setsda2, 149 .setscl = bit_lp_setscl2, 150 .getsda = bit_lp_getsda2, 151 .udelay = 80, 152 .mdelay = 80, 153 .timeout = HZ 173 154 }; 174 155 175 156 static struct i2c_adapter bit_lp_ops = { 176 "Philips Parallel port adapter", 177 I2C_HW_B_LP, 178 NULL, 179 NULL, 180 bit_lp_inc_use, 181 bit_lp_dec_use, 182 bit_lp_reg, 183 184 bit_lp_unreg, 157 .owner = THIS_MODULE, 158 .name = "Philips Parallel port adapter", 159 .id = I2C_HW_B_LP, 185 160 }; 186 161 … … 284 259 MODULE_PARM(type, "i"); 285 260 286 #ifdef MODULE 287 int init_module(void) 288 { 289 return i2c_bitlp_init(); 290 } 291 292 void cleanup_module(void) 293 { 294 i2c_bitlp_exit(); 295 } 296 #endif 261 module_init(i2c_bitlp_init); 262 module_exit(i2c_bitlp_exit); -
i2c/branches/lk2-4/kernel/i2c-pport.c
r3753 r3763 142 142 } 143 143 144 static int bit_pport_reg(struct i2c_client *client)145 {146 return 0;147 }148 149 static int bit_pport_unreg(struct i2c_client *client)150 {151 release_region((base+2),1);152 return 0;153 }154 155 static void bit_pport_inc_use(struct i2c_adapter *adap)156 {157 #ifdef MODULE158 MOD_INC_USE_COUNT;159 #endif160 }161 162 static void bit_pport_dec_use(struct i2c_adapter *adap)163 {164 #ifdef MODULE165 MOD_DEC_USE_COUNT;166 #endif167 }168 144 169 145 /* ------------------------------------------------------------------------ … … 172 148 */ 173 149 static struct i2c_algo_bit_data bit_pport_data = { 174 NULL,175 bit_pport_setsda,176 bit_pport_setscl,177 bit_pport_getsda,178 bit_pport_getscl,179 //NULL,180 40, 80, HZ, /* waits, timeout */150 .setsda = bit_pport_setsda, 151 .setscl = bit_pport_setscl, 152 .getsda = bit_pport_getsda, 153 .getscl = bit_pport_getscl, 154 .udelay = 40, 155 .mdelay = 80, 156 .timeout = HZ 181 157 }; 182 158 183 159 static struct i2c_adapter bit_pport_ops = { 184 "Primitive Parallel port adaptor", 185 I2C_HW_B_PPORT, 186 NULL, 187 &bit_pport_data, 188 bit_pport_inc_use, 189 bit_pport_dec_use, 190 bit_pport_reg, 191 bit_pport_unreg, 160 .owner = THIS_MODULE, 161 .name = "Primitive Parallel port adaptor", 162 .id = I2C_HW_B_PPORT, 163 .algo_data = &bit_pport_data, 192 164 }; 193 165 … … 228 200 229 201 MODULE_AUTHOR("Daniel Smolik <marvin@sitour.cz>"); 230 MODULE_DESCRIPTION("I2C-Bus adapter routines for Primitive parallel port adapter") 231 ; 202 MODULE_DESCRIPTION("I2C-Bus adapter routines for Primitive parallel port adapter"); 232 203 MODULE_PARM(base, "i"); 233 204 -
i2c/branches/lk2-4/kernel/i2c-proc.c
r3753 r3763 24 24 */ 25 25 26 #include <linux/version.h>27 26 #include <linux/module.h> 28 27 #include <linux/kernel.h> … … 32 31 #include <linux/proc_fs.h> 33 32 #include <linux/ioport.h> 34 #include <asm/uaccess.h>35 33 #include "i2c.h" 36 34 #include "i2c-proc.h" 37 35 #include <linux/init.h> 38 39 #ifndef THIS_MODULE 40 #define THIS_MODULE NULL 41 #endif 36 #include <asm/uaccess.h> 42 37 43 38 static int i2c_create_name(char **name, const char *prefix, … … 59 54 60 55 static struct i2c_client *i2c_clients[SENSORS_ENTRY_MAX]; 61 static unsigned short i2c_inodes[SENSORS_ENTRY_MAX];62 56 63 57 static ctl_table sysctl_table[] = { … … 89 83 90 84 static struct ctl_table_header *i2c_proc_header; 91 static int i2c_initialized;92 85 93 86 /* This returns a nice name for a new directory; for example lm78-isa-0310 … … 199 192 } 200 193 #endif /* DEBUG */ 201 i2c_inodes[id - 256] =202 new_header->ctl_table->child->child->de->low_ino;203 194 new_header->ctl_table->child->child->de->owner = controlling_mod; 204 195 … … 221 212 i2c_clients[id] = NULL; 222 213 } 223 }224 225 /* Monitor access for /proc/sys/dev/sensors; make unloading i2c-proc.o226 impossible if some process still uses it or some file in it */227 void i2c_fill_inode(struct inode *inode, int fill)228 {229 if (fill)230 MOD_INC_USE_COUNT;231 else232 MOD_DEC_USE_COUNT;233 }234 235 /* Monitor access for /proc/sys/dev/sensors/ directories; make unloading236 the corresponding module impossible if some process still uses it or237 some file in it */238 void i2c_dir_fill_inode(struct inode *inode, int fill)239 {240 int i;241 struct i2c_client *client;242 243 #ifdef DEBUG244 if (!inode) {245 printk(KERN_ERR "i2c-proc.o: Warning: inode NULL in fill_inode()\n");246 return;247 }248 #endif /* def DEBUG */249 250 for (i = 0; i < SENSORS_ENTRY_MAX; i++)251 if (i2c_clients[i]252 && (i2c_inodes[i] == inode->i_ino)) break;253 #ifdef DEBUG254 if (i == SENSORS_ENTRY_MAX) {255 printk256 (KERN_ERR "i2c-proc.o: Warning: inode (%ld) not found in fill_inode()\n",257 inode->i_ino);258 return;259 }260 #endif /* def DEBUG */261 client = i2c_clients[i];262 if (fill)263 client->driver->inc_use(client);264 else265 client->driver->dec_use(client);266 214 } 267 215 … … 656 604 657 605 for (addr = 0x00; addr <= (is_isa ? 0xffff : 0x7f); addr++) { 606 /* XXX: WTF is going on here??? */ 658 607 if ((is_isa && check_region(addr, 1)) || 659 608 (!is_isa && i2c_check_addr(adapter, addr))) … … 856 805 } 857 806 858 int __init sensors_init(void)807 static int __init i2c_proc_init(void) 859 808 { 860 809 printk(KERN_INFO "i2c-proc.o version %s (%s)\n", I2C_VERSION, I2C_DATE); 861 i2c_initialized = 0;862 810 if (! 863 811 (i2c_proc_header = … … 867 815 } 868 816 i2c_proc_header->ctl_table->child->de->owner = THIS_MODULE; 869 i2c_initialized++;870 817 return 0; 871 818 } 872 819 873 static void __exit i2c_cleanup(void) 874 { 875 if (i2c_initialized >= 1) { 876 unregister_sysctl_table(i2c_proc_header); 877 i2c_initialized--; 878 } 820 static void __exit i2c_proc_exit(void) 821 { 822 unregister_sysctl_table(i2c_proc_header); 879 823 } 880 824 … … 889 833 MODULE_LICENSE("GPL"); 890 834 891 module_init( sensors_init);892 module_exit(i2c_ cleanup);835 module_init(i2c_proc_init); 836 module_exit(i2c_proc_exit); -
i2c/branches/lk2-4/kernel/i2c-rpx.c
r3727 r3763 22 22 #include <asm/commproc.h> 23 23 24 #include <linux/i2c.h>25 #include <linux/i2c-algo-8xx.h>24 #include "i2c.h" 25 #include "i2c-algo-8xx.h" 26 26 27 27 static void … … 67 67 } 68 68 69 static int rpx_reg(struct i2c_client *client)70 {71 return 0;72 }73 74 static int rpx_unreg(struct i2c_client *client)75 {76 return 0;77 }78 79 static void rpx_inc_use(struct i2c_adapter *adap)80 {81 #ifdef MODULE82 MOD_INC_USE_COUNT;83 #endif84 }85 86 static void rpx_dec_use(struct i2c_adapter *adap)87 {88 #ifdef MODULE89 MOD_DEC_USE_COUNT;90 #endif91 }92 93 69 static struct i2c_algo_8xx_data rpx_data = { 94 70 .setisr = rpx_install_isr 95 71 }; 96 72 97 98 73 static struct i2c_adapter rpx_ops = { 99 "m8xx", 100 I2C_HW_MPC8XX_EPON, 101 NULL, 102 &rpx_data, 103 rpx_inc_use, 104 rpx_dec_use, 105 rpx_reg, 106 rpx_unreg, 74 .owner = THIS_MODULE, 75 .name = "m8xx", 76 .id = I2C_HW_MPC8XX_EPON, 77 .algo_data = &rpx_data, 107 78 }; 108 79 … … 127 98 } 128 99 129 #ifdef MODULE130 100 MODULE_AUTHOR("Dan Malek <dmalek@jlc.net>"); 131 101 MODULE_DESCRIPTION("I2C-Bus adapter routines for MPC8xx boards"); … … 133 103 module_init(i2c_rpx_init); 134 104 module_exit(i2c_rpx_exit); 135 #endif136 -
i2c/branches/lk2-4/kernel/i2c-velleman.c
r3753 r3763 91 91 static int bit_velle_init(void) 92 92 { 93 if (check_region(base,(base == 0x3bc)? 3 : 8) < 0 ) { 94 DEBE(printk(KERN_DEBUG "i2c-velleman.o: Port %#x already in use.\n", 95 base)); 93 if (!request_region(base, (base == 0x3bc) ? 3 : 8, 94 "i2c (Vellemann adapter)")) 96 95 return -ENODEV; 97 } else { 98 request_region(base, (base == 0x3bc)? 3 : 8, 99 "i2c (Vellemann adapter)"); 100 bit_velle_setsda((void*)base,1); 101 bit_velle_setscl((void*)base,1); 102 } 96 97 bit_velle_setsda((void*)base,1); 98 bit_velle_setscl((void*)base,1); 103 99 return 0; 104 }105 106 static void __exit bit_velle_exit(void)107 {108 release_region( base , (base == 0x3bc)? 3 : 8 );109 }110 111 112 static int bit_velle_reg(struct i2c_client *client)113 {114 return 0;115 }116 117 static int bit_velle_unreg(struct i2c_client *client)118 {119 return 0;120 }121 122 static void bit_velle_inc_use(struct i2c_adapter *adap)123 {124 #ifdef MODULE125 MOD_INC_USE_COUNT;126 #endif127 }128 129 static void bit_velle_dec_use(struct i2c_adapter *adap)130 {131 #ifdef MODULE132 MOD_DEC_USE_COUNT;133 #endif134 100 } 135 101 … … 140 106 141 107 static struct i2c_algo_bit_data bit_velle_data = { 142 NULL, 143 bit_velle_setsda, 144 bit_velle_setscl, 145 bit_velle_getsda, 146 bit_velle_getscl, 147 10, 10, HZ, /* waits, timeout */ 108 .setsda = bit_velle_setsda, 109 .setscl = bit_velle_setscl, 110 .getsda = bit_velle_getsda, 111 .getscl = bit_velle_getscl, 112 .udelay = 10, 113 .mdelay = 10, 114 .timeout = HZ 148 115 }; 149 116 150 117 static struct i2c_adapter bit_velle_ops = { 151 "Velleman K8000", 152 I2C_HW_B_VELLE, 153 NULL, 154 &bit_velle_data, 155 bit_velle_inc_use, 156 bit_velle_dec_use, 157 bit_velle_reg, 158 bit_velle_unreg, 118 .owner = THIS_MODULE, 119 .name = "Velleman K8000", 120 .id = I2C_HW_B_VELLE, 121 .algo_data = &bit_velle_data, 159 122 }; 160 123 161 int __initi2c_bitvelle_init(void)124 static int __init i2c_bitvelle_init(void) 162 125 { 163 126 printk(KERN_INFO "i2c-velleman.o: i2c Velleman K8000 adapter module version %s (%s)\n", I2C_VERSION, I2C_DATE); … … 185 148 } 186 149 187 EXPORT_NO_SYMBOLS; 150 static void __exit i2c_bitvelle_exit(void) 151 { 152 i2c_bit_del_bus(&bit_velle_ops); 153 release_region(base, (base == 0x3bc) ? 3 : 8); 154 } 188 155 189 #ifdef MODULE190 156 MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>"); 191 157 MODULE_DESCRIPTION("I2C-Bus adapter routines for Velleman K8000 adapter"); … … 194 160 MODULE_PARM(base, "i"); 195 161 196 int init_module(void) 197 { 198 return i2c_bitvelle_init(); 199 } 200 201 void cleanup_module(void) 202 { 203 i2c_bit_del_bus(&bit_velle_ops); 204 bit_velle_exit(); 205 } 206 207 #endif 162 module_init(i2c_bitvelle_init); 163 module_exit(i2c_bitvelle_exit); -
i2c/branches/lk2-4/kernel/i2c.h
r3753 r3763 26 26 /* $Id$ */ 27 27 28 #ifndef I2C_H29 #define I2C_H28 #ifndef _LINUX_I2C_H 29 #define _LINUX_I2C_H 30 30 31 31 #define I2C_DATE "20021208" … … 41 41 #ifdef __KERNEL__ 42 42 43 /* --- Includes and compatibility declarations ------------------------ */44 45 43 #include <linux/version.h> 46 47 #include <asm/page.h> /* for 2.2.xx */ 44 #include <linux/config.h> 48 45 #include <asm/semaphore.h> 49 #include <linux/config.h> 46 47 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,10) 48 #define MODULE_LICENSE(x) 49 #endif 50 50 51 51 /* --- General options ------------------------------------------------ */ … … 131 131 132 132 struct i2c_driver { 133 struct module *owner; 133 134 char name[32]; 134 135 int id; … … 154 155 */ 155 156 int (*command)(struct i2c_client *client,unsigned int cmd, void *arg); 156 157 /* These two are mainly used for bookkeeping & dynamic unloading of158 * kernel modules. inc_use tells the driver that a client is being159 * used by another module & that it should increase its ref. counter.160 * dec_use is the inverse operation.161 * NB: Make sure you have no circular dependencies, or else you get a162 * deadlock when trying to unload the modules.163 * You should use the i2c_{inc,dec}_use_client functions instead of164 * calling this function directly.165 */166 void (*inc_use)(struct i2c_client *client);167 void (*dec_use)(struct i2c_client *client);168 157 }; 169 158 … … 228 217 */ 229 218 struct i2c_adapter { 219 struct module *owner; 230 220 char name[32]; /* some useful name to identify the adapter */ 231 221 unsigned int id;/* == is algo->id | hwdep.struct->id, */ … … 233 223 struct i2c_algorithm *algo;/* the algorithm to access the bus */ 234 224 void *algo_data; 235 236 /* --- These may be NULL, but should increase the module use count */237 void (*inc_use)(struct i2c_adapter *);238 void (*dec_use)(struct i2c_adapter *);239 225 240 226 /* --- administration stuff. */ … … 311 297 extern int i2c_attach_client(struct i2c_client *); 312 298 extern int i2c_detach_client(struct i2c_client *); 313 314 /* Only call these if you grab a resource that makes unloading the315 client and the adapter it is on completely impossible. Like when a316 /proc directory is entered. */317 extern void i2c_inc_use_client(struct i2c_client *);318 extern void i2c_dec_use_client(struct i2c_client *);319 299 320 300 /* New function: This is to get an i2c_client-struct for controlling the … … 593 573 594 574 #endif /* def __KERNEL__ */ 595 #endif /* I2C_H */575 #endif /* _LINUX_I2C_H */
