Changeset 3828
- Timestamp:
- 07/25/03 09:56:42 (5 years ago)
- Files:
-
- i2c/trunk/CHANGES (modified) (1 diff)
- i2c/trunk/INSTALL (modified) (5 diffs)
- i2c/trunk/Makefile (modified) (6 diffs)
- i2c/trunk/QUICKSTART (modified) (1 diff)
- i2c/trunk/README (modified) (2 diffs)
- i2c/trunk/TODO (modified) (1 diff)
- i2c/trunk/doc/writing-clients (modified) (2 diffs)
- i2c/trunk/etc (added)
- i2c/trunk/etc/config.c (added)
- i2c/trunk/kernel/Module.mk (modified) (3 diffs)
- i2c/trunk/kernel/i2c-algo-bit.c (modified) (3 diffs)
- i2c/trunk/kernel/i2c-algo-biths.c (modified) (1 diff)
- i2c/trunk/kernel/i2c-algo-pcf.c (modified) (1 diff)
- i2c/trunk/kernel/i2c-core.c (modified) (5 diffs)
- i2c/trunk/kernel/i2c-dev.c (modified) (11 diffs)
- i2c/trunk/kernel/i2c-dev.h (modified) (3 diffs)
- i2c/trunk/kernel/i2c-id.h (modified) (1 diff)
- i2c/trunk/kernel/i2c-pcf-epp.c (modified) (2 diffs)
- i2c/trunk/kernel/i2c-proc.c (modified) (7 diffs)
- i2c/trunk/kernel/i2c-velleman.c (modified) (1 diff)
- i2c/trunk/kernel/i2c.h (modified) (3 diffs)
- i2c/trunk/mkpatch/Config.in (modified) (1 diff)
- i2c/trunk/mkpatch/FILES (modified) (2 diffs)
- i2c/trunk/mkpatch/INCLUDES (modified) (1 diff)
- i2c/trunk/mkpatch/mkpatch.pl (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
i2c/trunk/CHANGES
r3789 r3828 18 18 ----------------------------------------------------------------------------- 19 19 20 2.8.0 (2003????) 20 2.8.0 (20030714) 21 Interface changes: 22 - File i2c-dev.h: remove all userspace code, moved to 23 i2c-dev.h in lm_sensors2 package 24 - Struct i2c_adapter: remove inc_use() and dec_use(), add owner, 25 remove client_count, replace semaphore lock 26 with semaphores bus and list. 27 - Struct i2c_algorithm: add owner 28 - Struct i2c_driver: remove inc_use() and dec_use() 29 - Struct i2c_msg: type changes; add err and done 30 - Struct i2c_smbus_ioctl_data, i2c_rdwr_ioctl_data: type changes 31 - Remove controlling_mod argument in i2c_register_entry() 32 - Remove i2c_inc_use_client() and i2c_dec_use_client() 33 - Add i2c_client_command() 34 Makefiles: Handle multiple UTS_RELEASE definitions in linux/version.h; 35 Remove old gzipped modules; remove old misc directory if empty; 36 Don't use /usr/include headers for modules; 37 Remove pre-2.4 installation method; 38 Run depmod after module installation 39 Modules (all): Cleanups including 40 - C99 initializers 41 - Remove #ifdef MODULE 42 - Remove #ifndef THIS_MODULE 43 - Remove #ifndef MODULE_LICENSE 44 - Remove init_MUTEX #define 45 - Remove EXPORT_NO_SYMBOLS 46 - Remove dummy xxx_command() definitions 47 - Use module_init() and module_exit() 21 48 drivers (several): make spinlock_t's static 22 i2c-algo-biths.[ch]: Rewrite of i2c-algo-bit with improved bus timing and 23 error handling. This is not a drop-in replacement for i2c-algo-bit. 24 Interface subject to change. 49 i2c-algo-biths.[ch]: (new) Rewrite of i2c-algo-bit with improved 50 bus timing and error handling. 51 This is not a drop-in replacement for i2c-algo-bit. 52 Interface subject to change. 53 i2c-core.c: Rewrite locking; 54 Remove initialization of other modules in i2c_init_all() 55 i2c-dev.c: Fixes from kernel 2.4.21-rc7 25 56 i2c-id.h: add IDs for i2c-algo-biths, W83627HF, LM85, nForce2, OMAHA, GUIDE, 26 57 MPC107, IXP2000, IXP425, IOP3XX, UDA1342, S3VIA 27 58 i2c-proc.c: Fix ignore and probe tests 28 i2c.h: Add fields for detailed delivery report in i2c_msg.59 mkpatch: Remove patching of drivers/char/mem.c 29 60 30 61 2.7.0 (20021208) i2c/trunk/INSTALL
r3723 r3828 1 1 These are the installation instructions for the i2c package. 2 3 There are three ways in which you can compile and install this package. Each 4 has its own strong points. They are: 2 This package is ONLY for 2.4 kernels 2.4.9 or later !!! 3 4 There are three ways in which you can compile and install this package. 5 Option 1 is much easier and is recommended. 5 6 6 7 1. Complete separate from kernel compilation 8 (only for 2.4 kernels 2.4.9 or later) 7 9 This will generate a set of modules which can be inserted and removed 8 as needed; nothing will be written into the kernel tree ;10 as needed; nothing will be written into the kernel tree. 9 11 10 12 2. Semi-integrated into the kernel 13 (only for 2.4 kernels 2.4.9 or later) 11 14 This will add some files to your kernel tree, but has the advantage 12 15 that module symbols are supported; the end result is functionally very … … 14 17 15 18 3. Patching of the kernel 19 (only for 2.4 kernels 2.4.13 or later) 16 20 This will patch your kernel source tree. You must recompile your kernel 17 21 to take advantage of this. But it makes it possible to compile drivers … … 22 26 method 2 is less well maintained. 23 27 24 NOTE: SUPPORT FOR 2.0 AND 2.1 KERNELS HAS BEEN DROPPED! 25 NOTE: METHOD 3 ONLY WORKS FOR 2.2 KERNELS AND 2.4 KERNELS (2.4.0 OR LATER) 28 NOTE: SUPPORT FOR KERNELS 2.0.0 - 2.4.8 HAS BEEN DROPPED! 29 2.4.9 OR LATER REQUIRED! 30 31 FOR 2.5 KERNELS, Do not attempt to compile this package. 32 Use the drivers already in the 2.5 kernel development tree. 26 33 27 34 … … 119 126 BUILD_SYSTEM (both) (default: lm_sensors) 120 127 The build system which is used. lm_sensors corresponds with compilation 121 option 1; i2c with compilati n option 2.128 option 1; i2c with compilation option 2. 122 129 SHELL (both) (default: /bin/sh) 123 130 You may have to specify the full path to Bash here, if /bin/sh is some … … 168 175 169 176 There is a special script which should be able to generate diffs against 170 any 2. 2 and 2.4 kernel (2.4.0 and later). Note that 2.3kernels are no177 any 2.4 kernel (2.4.13 and later). Note that older kernels are no 171 178 longer supported. 172 179 Please report any problems to our mailinglist. Note that it may fail, i2c/trunk/Makefile
r3753 r3828 60 60 # /lib/modules/2.2.15-ac9/misc 61 61 #MODDIR := /lib/modules/`grep UTS_RELEASE $(LINUX_HEADERS)/linux/version.h|cut -f 2 -d'"'`/misc 62 MODPREF := /lib/modules/`grep UTS_RELEASE $(LINUX_HEADERS)/linux/version.h|cut -f 2 -d'"'`62 #MODPREF := /lib/modules/`grep UTS_RELEASE $(LINUX_HEADERS)/linux/version.h|cut -f 2 -d'"'` 63 63 #MODPREF := /lib/modules/$(KERNELVERSION) 64 MODPREF := /lib/modules/$(shell $(CC) -I$(LINUX_HEADERS) -E etc/config.c | grep uts_release |cut -f 2 -d'"') 64 65 65 66 # This is the directory into which the header files will be installed. … … 105 106 # Some often-used commands with default options 106 107 MKDIR := mkdir -p 108 RMDIR := rmdir 107 109 RM := rm -f 108 110 CC := gcc … … 117 119 # MODCFLAGS is to create in-kernel object files (modules) 118 120 119 CFLAGS := -I$(LINUX_HEADERS) -O2 -DLM_SENSORS 121 CPPFLAGS := -I$(LINUX_HEADERS) 122 CFLAGS := -Wall -O2 -DLM_SENSORS 120 123 121 124 ifeq ($(WARN),1) 122 CFLAGS += -W all-Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual \125 CFLAGS += -W -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual \ 123 126 -Wcast-align -Wwrite-strings -Wnested-externs -Winline 124 127 endif … … 139 142 140 143 ifeq ($(SMP),1) 141 MODC FLAGS += -D__SMP__144 MODCPPFLAGS += -D__SMP__ 142 145 endif 143 146 144 147 ifeq ($(MODVER),1) 145 MODCFLAGS += -DMODVERSIONS -include $(LINUX_HEADERS)/linux/modversions.h 146 endif 148 MODCPPFLAGS += -DMODVERSIONS -include $(LINUX_HEADERS)/linux/modversions.h 149 endif 150 151 # This magic is from the kernel Makefile. 152 # Extra cflags for kbuild 2.4. The default is to forbid includes by kernel code 153 # from user space headers. 154 kbuild_2_4_nostdinc := -nostdinc $(shell LC_ALL=C $(CC) -print-search-dirs | sed -ne 's/install: \(.*\)/-I \1include/gp') 155 MODCPPFLAGS += $(CPPFLAGS) $(kbuild_2_4_nostdinc) 147 156 148 157 .PHONY: dep … … 165 174 166 175 all :: 176 ifeq ($(shell if grep -q '^CONFIG_I2C=y' $(LINUX)/.config; then echo 1; fi),1) 177 @echo "*************** WARNING *************************** WARNING ***************" 178 @echo "*** ***" 179 @echo "*** You have I2C support built into your kernel (CONFIG_I2C=y). Unless ***" 180 @echo "*** you know what you are doing, installing our version of i2c will not ***" 181 @echo "*** work. Newly built i2c modules probably won't load. Other modules ***" 182 @echo "*** that rely on the i2c layer, such as lm_sensors, will fail to ***" 183 @echo "*** compile. Please consider compiling your kernel again with I2C ***" 184 @echo "*** support enabled as modules or disabled. ***" 185 @echo "*** ***" 186 @echo "*************** WARNING *************************** WARNING ***************" 187 endif 167 188 168 189 install :: all 190 @echo "*** The depmod command below may generate errors. We are aware of the" 191 @echo "*** problem and are working on a solution. You should ignore them for now." 192 ifeq ($(DESTDIR),) 193 -/sbin/depmod -a 194 else 195 -/sbin/depmod -a -b $(DESTDIR) 196 endif 197 @echo "*** Installation successful!" 198 @echo "*** Important notes:" 199 @echo "*** 1* Due to a change in our i2c structures, i2c-related drivers from" 200 @echo "*** the Linux kernel and from external sources won't work with this" 201 @echo "*** version of i2c. Such drivers include commonly used video drivers" 202 @echo "*** such as bttv and zoran, and less commonly used ones such as" 203 @echo "*** i2c-matroxfb. If you really need these, then you shouldn't use our" 204 @echo "*** i2c package. If you can leave without them, you should make sure" 205 @echo "*** such drivers do not exist on your system anymore. Loading them" 206 @echo "*** now would result in a severe system crash. We are working on the" 207 @echo "*** problem and will soon submit a complete i2c patch for inclusion in" 208 @echo "*** the Linux 2.4 kernel." 209 @echo "*** 2* The i2c-elektor and i2c-pcf-epp modules were not built. If you" 210 @echo "*** need them, you have to use compilation option 3 as described in" 211 @echo "*** the INSTALL file." 169 212 170 213 clean:: … … 180 223 # .o files are used for modules 181 224 %.o: %.c 182 $(CC) $(MODC FLAGS) -c $< -o $@225 $(CC) $(MODCPPFLAGS) $(MODCFLAGS) -c $< -o $@ 183 226 184 227 %.d: %.c 185 $(CC) -M -MG $(MODC FLAGS) $< | \228 $(CC) -M -MG $(MODCPPFLAGS) $(MODCFLAGS) $< | \ 186 229 sed -e 's@^\(.*\)\.o:@$*.d $*.o: Makefile '`dirname $*.d`/Module.mk' @' > $@ 187 230 i2c/trunk/QUICKSTART
r3484 r3828 3 3 system, and may cause problems. 4 4 5 Quickstart: 5 Quickstart for compiling outside the kernel. 6 This is by far the EASIEST METHOD. 7 Other methods are described in INSTALL. 8 ------------------------------------------ 9 10 * Verify you are running a 2.4 kernel, 2.4.9 or later. 11 6 12 * Make sure you have the kernel tree corresponding to your current 7 kernel in /usr/src/linux. Distribution kernels usually won't do, 8 compile your own from a 'vanilla' tree (get one from 9 ftp://ftp.kernel/org/pub/linux/kernel/). 13 kernel in /lib/modules/(uname -r)/build. 14 Even if the source is there, it may not correspond to your running 15 kernel. If so, you will have to recompile your kernel. 16 17 * Do `lsmod'. If there are any old i2c or sensors modules loaded, 18 you MUST remove them (as root) with `rmmod'. 19 20 * Verify that your i2c support in the kernel is configured as 21 modules or is disabled. If it is compiled-in, you obviously 22 cannot replace it with modules in the next step. 23 10 24 * Do a `make' followed by a `make install'. The warnings about .d 11 25 files at the start are harmless. 26 12 27 * Make sure you do a `depmod -a'. 28 13 29 * That's all (but you need client drivers from some other source to do 14 anything interesting) 30 anything interesting - see the lm_sensors page: 31 http://secure.netroedge.com/~lm78/ i2c/trunk/README
r3555 r3828 1 These are the updated i2c drivers, also known as the `Simon Vogl' drivers. 1 These package includes the basic i2c drivers. 2 This package is ONLY for 2.4 kernels 2.4.9 or later !!! 2 3 3 Updated means: more updated than the ones found in the current kernels. 4 ADDITIONALLY, i2c-2.8.0 is not API compatible to earlier i2c 5 releases due to struct changes; therefore you must NOT ENABLE 6 any other i2c drivers (e.g. bttv) in the 2.4 kernel. 7 Do NOT use lm-sensors 2.8.0 or i2c-2.8.0 if you require bttv. 4 8 5 If you have used this package before, please read IMPORTANT_CHANGES! 9 FOR 2.5 KERNELS, Do not attempt to compile this package. 10 Use the drivers already in the 2.5 kernel development tree. 11 12 ============================================================================= 6 13 7 14 There are basically two kinds of i2c drivers: drivers for busses and drivers … … 21 28 22 29 You can reach the developers of this package at their mailing list, at 23 linux-i2c@pelican.tk.uni-linz.ac.at.30 sensors@stimpy.netroedge.com. i2c/trunk/TODO
r3663 r3828 3 3 ------------------------------------------------ 4 4 5 * Send 2. 6.3patch to Marcelo (2.6.1 in kernel 2.4.13)5 * Send 2.8.0 patch to Marcelo (2.6.1 in kernel 2.4.13) 6 6 7 * Send 2.6.4 patch to Linus (2.6.3 in kernel 2.5.24) 8 9 * SMBus 2.0 7 * SMBus 2.0 Completion 10 8 SMBus 2.0 adds PEC, ARP, and a block process call message. 11 All is complete in release 2.6.4 except :9 All is complete in release 2.6.4 except for: 12 10 - SW PEC for Word Data and Process Call. No place to put PEC 13 11 in the current i2c_smbus_data structure. 12 For a summary of SMBus protocol support, see 13 http://www2.lm-sensors.nu/~lm78/protocol.html 14 14 15 15 * Timing considerations in SMBus emulation with i2c-algo-bit (D.E.): 16 (Note that some of these changes are implemented in i2c-algo-biths) 16 17 The Smbus defines a minimum frequency of 10 KHZ for driving the bus, while 17 18 the I2C does not define any minimum frequency. i2c/trunk/doc/writing-clients
r3704 r3828 25 25 address. 26 26 27 struct i2c_driver foo_driver 28 { 29 /* name */ "Foo version 2.3 and later driver", 30 /* id */ I2C_DRIVERID_FOO, 31 /* flags */ I2C_DF_NOTIFY, 32 /* attach_adapter */ &foo_attach_adapter, 33 /* detach_client */ &foo_detach_client, 34 /* command */ &foo_command, /* May be NULL */ 35 /* inc_use */ &foo_inc_use, /* May be NULL */ 36 /* dec_use */ &foo_dec_use /* May be NULL */ 27 static struct i2c_driver foo_driver = { 28 .owner = THIS_MODULE, 29 .name = "Foo version 2.3 driver", 30 .id = I2C_DRIVERID_FOO, /* usually from i2c-id.h */ 31 .flags = I2C_DF_NOTIFY, 32 .attach_adapter = &foo_attach_adapter, 33 .detach_client = &foo_detach_client, 34 .command = &foo_command /* may be NULL */ 37 35 } 38 36 … … 51 49 below. 52 50 53 54 Module usage count 55 ================== 56 57 If your driver can also be compiled as a module, there are moments at 58 which the module can not be removed from memory. For example, when you 59 are doing a lengthy transaction, or when you create a /proc directory, 60 and some process has entered that directory (this last case is the 61 main reason why these call-backs were introduced). 62 63 To increase or decrease the module usage count, you can use the 64 MOD_{INC,DEC}_USE_COUNT macros. They must be called from the module 65 which needs to get its usage count changed; that is why each driver 66 module has to implement its own callback. 67 68 void foo_inc_use (struct i2c_client *client) 69 { 70 #ifdef MODULE 71 MOD_INC_USE_COUNT; 72 #endif 73 } 74 75 void foo_dec_use (struct i2c_client *client) 76 { 77 #ifdef MODULE 78 MOD_DEC_USE_COUNT; 79 #endif 80 } 81 82 Do not call these call-back functions directly; instead, use one of the 83 following functions defined in i2c.h: 84 void i2c_inc_use_client(struct i2c_client *); 85 void i2c_dec_use_client(struct i2c_client *); 86 87 You should *not* increase the module count just because a device is 88 detected and a client created. This would make it impossible to remove 89 an adapter driver! 51 There use to be two additional fields in this structure, inc_use et dec_use, 52 for module usage count, but these fields were obsoleted and removed. 90 53 91 54 i2c/trunk/kernel/Module.mk
r3788 r3828 71 71 KERNELTARGETS += $(MODULE_DIR)/i2c-pport.o 72 72 endif 73 ifeq ($(shell if grep -q '^CONFIG_I2C_IOP3XX=y' $(LINUX)/.config; then echo 1; fi),1)74 KERNELTARGETS += $(MODULE_DIR)/i2c-iop3xx.o75 endif73 #ifeq ($(shell if grep -q '^CONFIG_I2C_IOP3XX=y' $(LINUX)/.config; then echo 1; fi),1) 74 #KERNELTARGETS += $(MODULE_DIR)/i2c-iop3xx.o 75 #endif 76 76 # 77 77 # No CONFIG option for this yet (not in mkpatch) … … 95 95 all-kernel: $(KERNELTARGETS) 96 96 all :: all-kernel 97 echo KERNELTARGETS $(KERNELTARGETS)98 97 99 98 # … … 104 103 install-kernel: all-kernel 105 104 if [ -n "$(KERNELTARGETS)" ] ; then \ 106 if [ -d "$(DESTDIR)$(MODPREF)/kernel" ] ; then \ 107 $(MKDIR) $(DESTDIR)$(MODPREF)/kernel/drivers/i2c ; \ 108 $(INSTALL) -o root -g root -m 644 $(KERNELTARGETS) $(DESTDIR)$(MODPREF)/kernel/drivers/i2c ; \ 109 for i in $(KERNELTARGETS) ; do \ 110 $(RM) $(DESTDIR)$(MODPREF)/misc/`basename $$i` ; \ 111 done \ 112 else \ 113 $(MKDIR) $(DESTDIR)$(MODPREF)/misc ; \ 114 $(INSTALL) -o root -g root -m 644 $(KERNELTARGETS) $(DESTDIR)$(MODPREF)/misc ; \ 115 fi \ 105 $(MKDIR) $(DESTDIR)$(MODPREF)/kernel/drivers/i2c ; \ 106 $(INSTALL) -o root -g root -m 644 $(KERNELTARGETS) $(DESTDIR)$(MODPREF)/kernel/drivers/i2c ; \ 107 for i in $(KERNELTARGETS) ; do \ 108 $(RM) $(DESTDIR)$(MODPREF)/misc/`basename $$i` $(DESTDIR)$(MODPREF)/misc/`basename $$i`.gz $(DESTDIR)$(MODPREF)/kernel/drivers/i2c/`basename $$i`.gz ; \ 109 done ; \ 110 for i in i2c-elektor.o i2c-pcf-epp.o ; do \ 111 $(RM) $(DESTDIR)$(MODPREF)/misc/`basename $$i` $(DESTDIR)$(MODPREF)/misc/`basename $$i`.gz $(DESTDIR)$(MODPREF)/kernel/drivers/i2c/`basename $$i` $(DESTDIR)$(MODPREF)/kernel/drivers/i2c/`basename $$i`.gz ; \ 112 done ; \ 113 $(RMDIR) $(DESTDIR)$(MODPREF)/misc 2> /dev/null || true ; \ 116 114 fi 117 115 if [ -n "$(KERNELINCLUDES)" ] ; then \ 118 116 $(MKDIR) $(DESTDIR)$(LINUX_INCLUDE_DIR) ; \ 119 $(INSTALL) -o root -g root -m 644 $(KERNELINCLUDES) $(DESTDIR)$(LINUX_INCLUDE_DIR) ; \117 $(INSTALL) -o root -g root -m 644 $(KERNELINCLUDES) $(DESTDIR)$(LINUX_INCLUDE_DIR) ; \ 120 118 fi 121 119 install :: install-kernel i2c/trunk/kernel/i2c-algo-bit.c
r3765 r3828 99 99 return -ETIMEDOUT; 100 100 } 101 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 102 if (current->need_resched) 103 schedule(); 104 #else 101 105 cond_resched(); 106 #endif 102 107 } 103 108 DEBSTAT(printk(KERN_DEBUG "needed %ld jiffies\n", jiffies-start)); … … 504 509 } 505 510 506 static u32 bit_func(struct i2c_adapter * adap)511 static u32 bit_func(struct i2c_adapter *i2c_adap) 507 512 { 508 513 return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR | … … 526 531 int i2c_bit_add_bus(struct i2c_adapter *adap) 527 532 { 528 int i;529 533 struct i2c_algo_bit_data *bit_adap = adap->algo_data; 530 534 i2c/trunk/kernel/i2c-algo-biths.c
r3765 r3828 167 167 return; 168 168 } 169 #ifdef cond_resched 169 170 cond_resched(); 171 #else 172 if (current->need_resched) { 173 set_current_state(TASK_UNINTERRUPTIBLE); 174 schedule_timeout(1); 175 } 176 #endif 170 177 } 171 178 adap->set_timer(adap); i2c/trunk/kernel/i2c-algo-pcf.c
r3765 r3828 443 443 int i2c_pcf_add_bus(struct i2c_adapter *adap) 444 444 { 445 int i , status;445 int i; 446 446 struct i2c_algo_pcf_data *pcf_adap = adap->algo_data; 447 447 i2c/trunk/kernel/i2c-core.c
r3768 r3828 22 22 SMBus 2.0 support by Mark Studebaker <mdsxyz123@yahoo.com> */ 23 23 24 /* $Id$*/24 /* i2c-core.c,v 1.91.2.2 2003/01/21 10:00:19 kmalkki Exp */ 25 25 26 26 #include <linux/module.h> … … 298 298 } 299 299 300 inti2c_check_addr (struct i2c_adapter *adapter, int addr)300 static int __i2c_check_addr (struct i2c_adapter *adapter, int addr) 301 301 { 302 302 int i; 303 down(&adapter->list);304 303 for (i = 0; i < I2C_CLIENT_MAX ; i++) 305 304 if (adapter->clients[i] && (adapter->clients[i]->addr == addr)) 306 305 return -EBUSY; 306 307 return 0; 308 } 309 310 int i2c_check_addr (struct i2c_adapter *adapter, int addr) 311 { 312 int rval; 313 314 down(&adapter->list); 315 rval = __i2c_check_addr(adapter, addr); 307 316 up(&adapter->list); 308 return 0; 317 318 return rval; 309 319 } 310 320 … … 380 390 } 381 391 382 static int i2c_inc_use_client(struct i2c_client *client) 383 { 384 385 if (!try_module_get(client->driver->owner)) 386 return -ENODEV; 387 if (!try_module_get(client->adapter->owner)) { 388 module_put(client->driver->owner); 389 return -ENODEV; 390 } 391 392 return 0; 392 static void i2c_inc_use_client(struct i2c_client *client) 393 { 394 if(client->driver->owner) 395 __MOD_INC_USE_COUNT(client->driver->owner); 396 if(client->adapter->owner) 397 __MOD_INC_USE_COUNT(client->adapter->owner); 393 398 } 394 399 395 400 static void i2c_dec_use_client(struct i2c_client *client) 396 401 { 397 module_put(client->driver->owner); 398 module_put(client->adapter->owner); 402 if(client->driver->owner) 403 __MOD_DEC_USE_COUNT(client->driver->owner); 404 if(client->adapter->owner) 405 __MOD_DEC_USE_COUNT(client->adapter->owner); 399 406 } 400 407 … … 470 477 int i2c_use_client(struct i2c_client *client) 471 478 { 472 if (!i2c_inc_use_client(client))473 return -ENODEV;474 475 479 if (client->flags & I2C_CLIENT_ALLOW_USE) { 476 480 if (client->flags & I2C_CLIENT_ALLOW_MULTIPLE_USE) 477 481 client->usage_count++; 478 482 else if (client->usage_count > 0) 479 goto busy;483 return -EBUSY; 480 484 else 481 485 client->usage_count++; 482 486 } 483 487 488 i2c_inc_use_client(client); 489 484 490 return 0; 485 busy:486 i2c_dec_use_client(client);487 return -EBUSY;488 491 } 489 492 … … 1412 1415 } 1413 1416 1417 /* leave this in for now simply to make patching easier so we don't have 1418 to remove the call in drivers/char/mem.c */ 1419 int __init i2c_init_all(void) 1420 { 1421 return 0; 1422 } 1423 1414 1424 EXPORT_SYMBOL(i2c_add_adapter); 1415 1425 EXPORT_SYMBOL(i2c_del_adapter); i2c/trunk/kernel/i2c-dev.c
r3765 r3828 36 36 #include <linux/slab.h> 37 37 #include <linux/smp_lock.h> 38 #ifdef CONFIG_DEVFS_FS 38 39 #include <linux/devfs_fs_kernel.h> 40 #endif 39 41 #include <linux/init.h> 40 42 #include "i2c.h" … … 76 78 #define I2CDEV_ADAPS_MAX I2C_ADAP_MAX 77 79 static struct i2c_adapter *i2cdev_adaps[I2CDEV_ADAPS_MAX]; 80 #ifdef CONFIG_DEVFS_FS 81 static devfs_handle_t devfs_i2c[I2CDEV_ADAPS_MAX]; 82 static devfs_handle_t devfs_handle = NULL; 83 #endif 78 84 79 85 static struct i2c_driver i2cdev_driver = { … … 207 213 return -EFAULT; 208 214 215 /* Put an arbritrary limit on the number of messages that can 216 * be sent at once */ 217 if (rdwr_arg.nmsgs > 42) 218 return -EINVAL; 219 209 220 rdwr_pa = (struct i2c_msg *) 210 221 kmalloc(rdwr_arg.nmsgs * sizeof(struct i2c_msg), … … 221 232 { 222 233 res = -EFAULT; 234 break; 235 } 236 /* Limit the size of the message to a sane amount */ 237 if (rdwr_pa[i].len > 8192) { 238 res = -EINVAL; 223 239 break; 224 240 } … … 233 249 rdwr_pa[i].len)) 234 250 { 235 kfree(rdwr_pa[i].buf);236 251 res = -EFAULT; 237 252 break; 238 253 } 254 } 255 if (res < 0) { 256 int j; 257 for (j = 0; j < i; ++j) 258 kfree(rdwr_pa[j].buf); 259 kfree(rdwr_pa); 260 return res; 239 261 } 240 262 if (!res) … … 362 384 363 385 /* registered with adapter, passed as client to user */ 364 client->adapter = file->private_data;386 client->adapter = i2cdev_adaps[minor]; 365 387 file->private_data = client; 366 388 367 /* use adapter module, i2c-dev handled with fops */ 368 if (!try_module_get(client->adapter->owner)) { 369 kfree(client); 370 return -ENODEV; 371 } 389 if(client->adapter->owner) 390 __MOD_INC_USE_COUNT(client->adapter->owner); 372 391 373 392 #ifdef DEBUG … … 386 405 client = file->private_data; 387 406 file->private_data = NULL; 388 module_put(client->adapter->owner); 407 if(client->adapter->owner) 408 __MOD_DEC_USE_COUNT(client->adapter->owner); 389 409 kfree(client); 390 410 #ifdef DEBUG … … 397 417 { 398 418 int i; 399 char name[ 12];419 char name[8]; 400 420 401 421 if ((i = i2c_adapter_id(adap)) < 0) { … … 408 428 } 409 429 410 sprintf (name, " i2c/%d", i);430 sprintf (name, "%d", i); 411 431 if (! i2cdev_adaps[i]) { 412 432 i2cdev_adaps[i] = adap; 413 devfs_register (NULL, name, 433 #ifdef CONFIG_DEVFS_FS 434 devfs_i2c[i] = devfs_register (devfs_handle, name, 414 435 DEVFS_FL_DEFAULT, I2C_MAJOR, i, 415 436 S_IFCHR | S_IRUSR | S_IWUSR, 416 437 &i2cdev_fops, adap); 438 #endif 417 439 printk(KERN_DEBUG "i2c-dev.o: Registered '%s' as minor %d\n",adap->name,i); 418 440 } else { 419 441 /* This is actually a detach_adapter call! */ 420 devfs_remove("i2c/%d", i); 442 #ifdef CONFIG_DEVFS_FS 443 devfs_unregister(devfs_i2c[i]); 444 #endif 421 445 i2cdev_adaps[i] = NULL; 422 446 #ifdef DEBUG … … 445 469 printk(KERN_INFO "i2c-dev.o: i2c /dev entries driver module version %s (%s)\n", I2C_VERSION, I2C_DATE); 446 470 471 #ifdef CONFIG_DEVFS_FS 472 if (devfs_register_chrdev(I2C_MAJOR, "i2c", &i2cdev_fops)) { 473 #else 447 474 if (register_chrdev(I2C_MAJOR,"i2c",&i2cdev_fops)) { 475 #endif 448 476 printk(KERN_ERR "i2c-dev.o: unable to get major %d for i2c bus\n", 449 477 I2C_MAJOR); 450 478 return -EIO; 451 479 } 452 devfs_mk_dir(NULL, "i2c", NULL); 480 #ifdef CONFIG_DEVFS_FS 481 devfs_handle = devfs_mk_dir(NULL, "i2c", NULL); 482 #endif 453 483 if ((res = i2c_add_driver(&i2cdev_driver))) { 454 484 printk(KERN_ERR "i2c-dev.o: Driver registration failed, module not inserted.\n"); 455 devfs_remove("i2c"); 485 #ifdef CONFIG_DEVFS_FS 486 devfs_unregister(devfs_handle); 487 #endif 456 488 unregister_chrdev(I2C_MAJOR,"i2c"); 457 489 return res; … … 463 495 { 464 496 i2c_del_driver(&i2cdev_driver); 465 devfs_remove("i2c"); 497 #ifdef CONFIG_DEVFS_FS 498 devfs_unregister(devfs_handle); 499 #endif 466 500 unregister_chrdev(I2C_MAJOR,"i2c"); 467 501 } i2c/trunk/kernel/i2c-dev.h
r3765 r3828 27 27 #include <linux/types.h> 28 28 29 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,18) 30 #define minor(d) MINOR(d) 31 #endif 32 29 33 /* Some IOCTL commands are defined in <linux/i2c.h> */ 30 34 /* Note: 10-bit addresses are NOT supported! */ … … 32 36 /* This is the structure as used in the I2C_SMBUS ioctl call */ 33 37 struct i2c_smbus_ioctl_data { 34 charread_write;38 __u8 read_write; 35 39 __u8 command; 36 intsize;40 __u32 size; 37 41 union i2c_smbus_data *data; 38 42 }; … … 41 45 struct i2c_rdwr_ioctl_data { 42 46 struct i2c_msg *msgs; /* pointers to i2c_msgs */ 43 intnmsgs; /* number of i2c_msgs */47 __u32 nmsgs; /* number of i2c_msgs */ 44 48 }; 45 49 i2c/trunk/kernel/i2c-id.h
r3789 r3828 153 153 #define I2C_DRIVERID_W83627HF 1038 154 154 #define I2C_DRIVERID_LM85 1039 155 #define I2C_DRIVERID_LM83 1040 156 #define I2C_DRIVERID_SAA1064 1041 155 157 156 158 /* i2c/trunk/kernel/i2c-pcf-epp.c
r3765 r3828 2 2 /* i2c-pcf-epp.c i2c-hw access for PCF8584 style EPP parallel port adapters */ 3 3 /* ------------------------------------------------------------------------- */ 4 /* Copyright (C) 1998-99 Hans Berglund 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2 of the License, or 9 (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program; if not, write to the Free Software 18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ 19 /* ------------------------------------------------------------------------- */ 20 21 /* With some changes from Ryosuke Tajima <rosk@jsk.t.u-tokyo.ac.jp> */ 4 22 5 23 #include <linux/kernel.h> … … 252 270 MODULE_AUTHOR("Hans Berglund <hb@spacetec.no> \n modified by Ryosuke Tajima <rosk@jsk.t.u-tokyo.ac.jp>"); 253 271 MODULE_DESCRIPTION("I2C-Bus adapter routines for PCF8584 EPP parallel port adapter"); 272 MODULE_LICENSE("GPL"); 254 273 255 274 MODULE_PARM(base, "i"); i2c/trunk/kernel/i2c-proc.c
r3780 r3828 36 36 #include <asm/uaccess.h> 37 37 38 static int i2c_create_name(char **name, const char *prefix,39 struct i2c_adapter *adapter, int addr);40 38 static int i2c_parse_reals(int *nrels, void *buffer, int bufsize, 41 39 long *results, int magnitude); 42 static int i2c_write_reals(int nrels, void *buffer, int *bufsize,40 static int i2c_write_reals(int nrels, void *buffer, size_t *bufsize, 43 41 long *results, int magnitude); 44 42 static int i2c_proc_chips(ctl_table * ctl, int write, … … 55 53 static struct i2c_client *i2c_clients[SENSORS_ENTRY_MAX]; 56 54 57 static ctl_table sysctl_table[] = {58 {CTL_DEV, "dev", NULL, 0, 0555},59 {0},60 {DEV_SENSORS, "sensors", NULL, 0, 0555},61 {0},62 {0, NULL, NULL, 0, 0555},63 {0}64 };65 66 55 static ctl_table i2c_proc_dev_sensors[] = { 67 56 {SENSORS_CHIPS, "chips", NULL, 0, 0644, NULL, &i2c_proc_chips, … … 71 60 72 61 static ctl_table i2c_proc_dev[] = { 73 {DEV_SENSORS, "sensors", NULL, 0, 0555, i2c_proc_dev_sensors , NULL},62 {DEV_SENSORS, "sensors", NULL, 0, 0555, i2c_proc_dev_sensors}, 74 63 {0}, 75 64 }; … … 77 66 78 67 static ctl_table i2c_proc[] = { 79 {CTL_DEV, "dev", NULL, 0, 0555, i2c_proc_dev , NULL},68 {CTL_DEV, "dev", NULL, 0, 0555, i2c_proc_dev}, 80 69 {0} 81 70 }; … … 88 77 a LM75 chip on the third i2c bus at address 0x4e). 89 78 name is allocated first. */ 90 static int i2c_create_name(char **name, const char *prefix, 91 struct i2c_adapter *adapter, int addr) 92 { 93 char name_buffer[50]; 94 int id, i, end; 95 if (i2c_is_isa_adapter(adapter)) 79 static char *generate_name(struct i2c_client *client, const char *prefix) 80 { 81 struct i2c_adapter *adapter = client->adapter; 82 int addr = client->addr; 83 char name_buffer[50], *name; 84 85 if (i2c_is_isa_adapter(adapter)) { 96 86 sprintf(name_buffer, "%s-isa-%04x", prefix, addr); 97 else if (!adapter->algo->smbus_xfer && !adapter->algo->master_xfer) { 98 /* dummy adapter, generate prefix */ 87 } else if (adapter->algo->smbus_xfer || adapter->algo->master_xfer) { 88 int id = i2c_adapter_id(adapter); 89 if (id < 0) 90 return ERR_PTR(-ENOENT); 91 sprintf(name_buffer, "%s-i2c-%d-%02x", prefix, id, addr); 92 } else { /* dummy adapter, generate prefix */ 93 int end, i; 94 99 95 sprintf(name_buffer, "%s-", prefix); 100 96 end = strlen(name_buffer); 101 for(i = 0; i < 32; i++) { 102 if(adapter->algo->name[i] == ' ') 97 98 for (i = 0; i < 32; i++) { 99 if (adapter->algo->name[i] == ' ') 103 100 break; 104 101 name_buffer[end++] = tolower(adapter->algo->name[i]); 105 102 } 103 106 104 name_buffer[end] = 0; 107 105 sprintf(name_buffer + end, "-%04x", addr); 108 } else { 109 if ((id = i2c_adapter_id(adapter)) < 0) 110 return -ENOENT; 111 sprintf(name_buffer, "%s-i2c-%d-%02x", prefix, id, addr); 112 } 113 *name = kmalloc(strlen(name_buffer) + 1, GFP_KERNEL); 114 if (!*name) { 115 printk (KERN_WARNING "i2c_create_name: not enough memory\n"); 116 return -ENOMEM; 117 } 118 strcpy(*name, name_buffer); 119 return 0; 106 } 107 108 name = kmalloc(strlen(name_buffer) + 1, GFP_KERNEL); 109 if (!name) 110 return ERR_PTR(-ENOMEM); 111 strcpy(name, name_buffer); 112 return name; 120 113 } 121 114 … … 128 121 this function must be updated! */ 129 122
