| 130 | | #ifdef MODULE |
| 131 | | static |
| 132 | | #else |
| 133 | | extern |
| 134 | | #endif |
| 135 | | int __init i2c_i801_init(void); |
| 136 | | static int __init i801_cleanup(void); |
| 137 | | static int i801_setup(void); |
| 138 | | static s32 i801_access(struct i2c_adapter *adap, u16 addr, |
| 139 | | unsigned short flags, char read_write, |
| 140 | | u8 command, int size, union i2c_smbus_data *data); |
| | 128 | |
| | 129 | |
| | 130 | |
| | 131 | |
| 145 | | static void i801_inc(struct i2c_adapter *adapter); |
| 146 | | static void i801_dec(struct i2c_adapter *adapter); |
| 147 | | static u32 i801_func(struct i2c_adapter *adapter); |
| 148 | | |
| 149 | | #ifdef MODULE |
| 150 | | extern int init_module(void); |
| 151 | | extern int cleanup_module(void); |
| 152 | | #endif /* MODULE */ |
| 153 | | |
| 154 | | static struct i2c_algorithm smbus_algorithm = { |
| 155 | | /* name */ "Non-I2C SMBus adapter", |
| 156 | | /* id */ I2C_ALGO_SMBUS, |
| 157 | | /* master_xfer */ NULL, |
| 158 | | /* smbus_xfer */ i801_access, |
| 159 | | /* slave_send */ NULL, |
| 160 | | /* slave_rcv */ NULL, |
| 161 | | /* algo_control */ NULL, |
| 162 | | /* functionality */ i801_func, |
| 163 | | }; |
| 164 | | |
| 165 | | static struct i2c_adapter i801_adapter = { |
| 166 | | "unset", |
| 167 | | I2C_ALGO_SMBUS | I2C_HW_SMBUS_I801, |
| 168 | | &smbus_algorithm, |
| 169 | | NULL, |
| 170 | | i801_inc, |
| 171 | | i801_dec, |
| 172 | | NULL, |
| 173 | | NULL, |
| 174 | | }; |
| 175 | | |
| 176 | | static int __initdata i801_initialized; |
| | 136 | |
| | 137 | |
| | 138 | |
| | 139 | |
| 696 | | int __init i2c_i801_init(void) |
| 697 | | { |
| 698 | | int res; |
| 699 | | printk(KERN_INFO "i2c-i801.o version %s (%s)\n", LM_VERSION, LM_DATE); |
| 700 | | #ifdef DEBUG |
| 701 | | /* PE- It might be good to make this a permanent part of the code! */ |
| 702 | | if (i801_initialized) { |
| 703 | | printk |
| 704 | | (KERN_DEBUG "i2c-i801.o: Oops, i801_init called a second time!\n"); |
| 705 | | return -EBUSY; |
| 706 | | } |
| 707 | | #endif |
| 708 | | i801_initialized = 0; |
| 709 | | if ((res = i801_setup())) { |
| | 650 | static struct i2c_algorithm smbus_algorithm = { |
| | 651 | .name = "Non-I2C SMBus adapter", |
| | 652 | .id = I2C_ALGO_SMBUS, |
| | 653 | .smbus_xfer = i801_access, |
| | 654 | .functionality = i801_func, |
| | 655 | }; |
| | 656 | |
| | 657 | static struct i2c_adapter i801_adapter = { |
| | 658 | .owner = THIS_MODULE, |
| | 659 | .name = "unset", |
| | 660 | .id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_I801, |
| | 661 | .algo = &smbus_algorithm, |
| | 662 | }; |
| | 663 | |
| | 664 | |
| | 665 | |
| | 666 | static struct pci_device_id i801_ids[] __devinitdata = { |
| | 667 | { 0, } |
| | 668 | }; |
| | 669 | |
| | 670 | static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id *id) |
| | 671 | { |
| | 672 | |
| | 673 | if (i801_setup()) { |
| 718 | | if ((res = i2c_add_adapter(&i801_adapter))) { |
| 719 | | printk |
| 720 | | (KERN_ERR "i2c-i801.o: Adapter registration failed, module not inserted.\n"); |
| 721 | | i801_cleanup(); |
| 722 | | return res; |
| 723 | | } |
| 724 | | i801_initialized++; |
| 725 | | printk(KERN_INFO "i2c-i801.o: I801 bus detected and initialized\n"); |
| 726 | | return 0; |
| 727 | | } |
| 728 | | |
| 729 | | int __init i801_cleanup(void) |
| 730 | | { |
| 731 | | int res; |
| 732 | | if (i801_initialized >= 2) { |
| 733 | | if ((res = i2c_del_adapter(&i801_adapter))) { |
| 734 | | printk |
| 735 | | (KERN_ERR "i2c-i801.o: i2c_del_adapter failed, module not removed\n"); |
| 736 | | return res; |
| 737 | | } else |
| 738 | | i801_initialized--; |
| 739 | | } |
| 740 | | if (i801_initialized >= 1) { |
| 741 | | release_region(i801_smba, (isich4 ? 16 : 8)); |
| 742 | | i801_initialized--; |
| 743 | | } |
| 744 | | return 0; |
| 745 | | } |
| 746 | | |
| 747 | | EXPORT_NO_SYMBOLS; |
| 748 | | |
| 749 | | #ifdef MODULE |
| | 681 | i2c_add_adapter(&i801_adapter); |
| | 682 | } |
| | 683 | |
| | 684 | static void __devexit i801_remove(struct pci_dev *dev) |
| | 685 | { |
| | 686 | i2c_del_adapter(&i801_adapter); |
| | 687 | } |
| | 688 | |
| | 689 | static struct pci_driver i801_driver = { |
| | 690 | .name = "i801 smbus", |
| | 691 | .id_table = i801_ids, |
| | 692 | .probe = i801_probe, |
| | 693 | .remove = __devexit_p(i801_remove), |
| | 694 | }; |
| | 695 | |
| | 696 | static int __init i2c_i801_init(void) |
| | 697 | { |
| | 698 | printk(KERN_INFO "i2c-i801.o version %s (%s)\n", LM_VERSION, LM_DATE); |
| | 699 | return pci_module_init(&i801_driver); |
| | 700 | } |
| | 701 | |
| | 702 | |
| | 703 | static void __exit i2c_i801_exit(void) |
| | 704 | { |
| | 705 | pci_unregister_driver(&i801_driver); |
| | 706 | release_region(i801_smba, (isich4 ? 16 : 8)); |
| | 707 | } |
| | 708 | |
| | 709 | |