Changeset 3828
- Timestamp:
- 07/25/03 09:56:42 (10 years ago)
- Location:
- i2c/trunk
- Files:
-
- 2 added
- 23 modified
-
CHANGES (modified) (1 diff)
-
INSTALL (modified) (5 diffs)
-
Makefile (modified) (6 diffs)
-
QUICKSTART (modified) (1 diff)
-
README (modified) (2 diffs)
-
TODO (modified) (1 diff)
-
doc/writing-clients (modified) (2 diffs)
-
etc (added)
-
etc/config.c (added)
-
kernel/Module.mk (modified) (3 diffs)
-
kernel/i2c-algo-bit.c (modified) (3 diffs)
-
kernel/i2c-algo-biths.c (modified) (1 diff)
-
kernel/i2c-algo-pcf.c (modified) (1 diff)
-
kernel/i2c-core.c (modified) (5 diffs)
-
kernel/i2c-dev.c (modified) (11 diffs)
-
kernel/i2c-dev.h (modified) (3 diffs)
-
kernel/i2c-id.h (modified) (1 diff)
-
kernel/i2c-pcf-epp.c (modified) (2 diffs)
-
kernel/i2c-proc.c (modified) (7 diffs)
-
kernel/i2c-velleman.c (modified) (1 diff)
-
kernel/i2c.h (modified) (3 diffs)
-
mkpatch/Config.in (modified) (1 diff)
-
mkpatch/FILES (modified) (2 diffs)
-
mkpatch/INCLUDES (modified) (1 diff)
-
mkpatch/mkpatch.pl (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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 int i2c_register_entry(struct i2c_client *client, const char *prefix, 130 ctl_table * ctl_template) 131 { 132 int i, res, len, id; 133 ctl_table *new_table, *client_tbl, *tbl; 134 char *name; 135 struct ctl_table_header *new_header; 136 137 if ((res = i2c_create_name(&name, prefix, client->adapter, 138 client->addr))) return res; 139 140 for (id = 0; id < SENSORS_ENTRY_MAX; id++) 141 if (!i2c_entries[id]) { 142 break; 143 } 144 if (id == SENSORS_ENTRY_MAX) { 145 kfree(name); 146 return -ENOMEM; 147 } 148 149 id += 256; 150 151 len = 0; 123 struct ctl_table *ctl_template) 124 { 125 struct { struct ctl_table root[2], dev[2], sensors[2]; } *tbl; 126 struct ctl_table_header *hdr; 127 struct ctl_table *tmp, *leaf; 128 const char *name; 129 int id, len = 0; 130 131 name = generate_name(client, prefix); 132 if (IS_ERR(name)) 133 return PTR_ERR(name); 134 135 for (id = 0; id < SENSORS_ENTRY_MAX; id++) { 136 if (!i2c_entries[id]) 137 goto free_slot; 138 } 139 140 goto out_free_name; 141 142 free_slot: 152 143 while (ctl_template[len].procname) 153 144 len++; 154 if (!(new_table = kmalloc(sizeof(sysctl_table) + sizeof(ctl_table) * (len + 1), 155 GFP_KERNEL))) { 156 kfree(name); 157 return -ENOMEM; 158 } 159 160 memcpy(new_table, sysctl_table, sizeof(sysctl_table)); 161 tbl = new_table; /* sys/ */ 162 tbl = tbl->child = tbl + 2; /* dev/ */ 163 tbl = tbl->child = tbl + 2; /* sensors/ */ 164 client_tbl = tbl->child = tbl + 2; /* XX-chip-YY-ZZ/ */ 165 166 client_tbl->procname = name; 167 client_tbl->ctl_name = id; 168 client_tbl->child = client_tbl + 2; 169 170 /* Next the client sysctls. --km */ 171 tbl = client_tbl->child; 172 memcpy(tbl, ctl_template, sizeof(ctl_table) * (len+1)); 173 for (i = 0; i < len; i++) 174 tbl[i].extra2 = client; 175 176 if (!(new_header = register_sysctl_table(new_table, 0))) { 177 printk(KERN_ERR "i2c-proc.o: error: sysctl interface not supported by kernel!\n"); 178 kfree(new_table); 179 kfree(name); 180 return -EPERM; 181 } 182 183 i2c_entries[id - 256] = new_header; 184 185 i2c_clients[id - 256] = client; 186 187 #ifdef DEBUG 188 if (!new_header || !new_header->ctl_table || 189 !new_header->ctl_table->child || 190 !new_header->ctl_table->child->child || 191 !new_header->ctl_table->child->child->de ) { 192 printk 193 (KERN_ERR "i2c-proc.o: NULL pointer when trying to install fill_inode fix!\n"); 194 return id; 195 } 196 #endif /* DEBUG */ 197 client_tbl->de->owner = client->driver->owner; 198 return id; 145 tbl = kmalloc(sizeof(*tbl) + sizeof(ctl_table) * (len + 1), 146 GFP_KERNEL); 147 if (!tbl) 148 goto out_free_name; 149 memset(tbl, 0, sizeof(*tbl)); 150 151 /* The client sysctls */ 152 leaf = (struct ctl_table *) (tbl + 1); 153 memcpy(leaf, ctl_template, sizeof(ctl_table) * (len+1)); 154 for (tmp = leaf; tmp->ctl_name; tmp++) 155 tmp->extra2 = client; 156 157 tbl->sensors->ctl_name = id+256; 158 tbl->sensors->procname = name; 159 tbl->sensors->mode = 0555; 160 tbl->sensors->child = leaf; 161 162 tbl->dev->ctl_name = DEV_SENSORS; 163 tbl->dev->procname = "sensors"; 164 tbl->dev->mode = 0555; 165 tbl->dev->child = tbl->sensors; 166 167 tbl->root->ctl_name = CTL_DEV; 168 tbl->root->procname = "dev"; 169 tbl->root->mode = 0555; 170 tbl->root->child = tbl->dev; 171 172 hdr = register_sysctl_table(tbl->root, 0); 173 if (!hdr) 174 goto out_free_tbl; 175 176 i2c_entries[id] = hdr; 177 i2c_clients[id] = client; 178 179 return (id + 256); /* XXX(hch) why?? */ 180 181 out_free_tbl: 182 kfree(tbl); 183 out_free_name: 184 kfree(name); 185 return -ENOMEM; 199 186 } 200 187 201 188 void i2c_deregister_entry(int id) 202 189 { 203 ctl_table *table; 204 char *temp; 205 206 id -= 256; 190 id -= 256; 191 207 192 if (i2c_entries[id]) { 208 table = i2c_entries[id]->ctl_table; 209 unregister_sysctl_table(i2c_entries[id]); 210 /* 2-step kfree needed to keep gcc happy about const points */ 211 (const char *) temp = table[4].procname; 212 kfree(temp); 213 kfree(table); 214 i2c_entries[id] = NULL; 215 i2c_clients[id] = NULL; 216 } 193 struct ctl_table_header *hdr = i2c_entries[id]; 194 struct ctl_table *tbl = hdr->ctl_table; 195 196 unregister_sysctl_table(hdr); 197 kfree(tbl->child->child->procname); 198 kfree(tbl); /* actually the whole anonymous struct */ 199 } 200 201 i2c_entries[id] = NULL; 202 i2c_clients[id] = NULL; 217 203 } 218 204 … … 518 504 } 519 505 520 static int i2c_write_reals(int nrels, void *buffer, int *bufsize,506 static int i2c_write_reals(int nrels, void *buffer, size_t *bufsize, 521 507 long *results, int magnitude) 522 508 { -
i2c/trunk/kernel/i2c-velleman.c
r3765 r3828 25 25 #include <linux/module.h> 26 26 #include <linux/init.h> 27 #include <linux/errno.h> 27 28 #include <linux/delay.h> 28 29 #include "i2c.h" -
i2c/trunk/kernel/i2c.h
r3765 r3828 29 29 #define _LINUX_I2C_H 30 30 31 #define I2C_DATE "200 21208"32 #define I2C_VERSION "2. 7.0"31 #define I2C_DATE "20030714" 32 #define I2C_VERSION "2.8.0" 33 33 34 34 #include <linux/module.h> 35 35 #include <linux/types.h> 36 #include <linux/errno.h> 37 #include <asm/semaphore.h> 36 38 #include "i2c-id.h" 37 #include <asm/semaphore.h> 39 40 #include <linux/version.h> 41 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,10) 42 #define MODULE_LICENSE(x) 43 #endif 38 44 39 45 /* --- General options ------------------------------------------------ */ … … 350 356 struct i2c_msg { 351 357 __u16 addr; /* slave address */ 352 unsigned shortflags;358 __u16 flags; 353 359 #define I2C_M_TEN 0x10 /* we have a ten bit chip address */ 354 360 #define I2C_M_RD 0x01 … … 357 363 #define I2C_M_IGNORE_NAK 0x1000 358 364 #define I2C_M_NO_RD_ACK 0x0800 359 shortlen; /* msg length */360 char*buf; /* pointer to msg data */365 __u16 len; /* msg length */ 366 __u8 *buf; /* pointer to msg data */ 361 367 int err; 362 368 short done; -
i2c/trunk/mkpatch/Config.in
r3765 r3828 45 45 fi 46 46 47 # This is needed for automatic patch generation: sensors code starts here 48 # This is needed for automatic patch generation: sensors code ends here 49 47 50 dep_tristate 'I2C device interface' CONFIG_I2C_CHARDEV $CONFIG_I2C 48 51 dep_tristate 'I2C /proc interface (required for hardware sensors)' CONFIG_I2C_PROC $CONFIG_I2C $CONFIG_SYSCTL -
i2c/trunk/mkpatch/FILES
r3765 r3828 1 kernel/i2c-adap-ibm_ocp.c drivers/i2c/i2c-adap-ibm_ocp.c 2 kernel/i2c-algo-8xx.c drivers/i2c/i2c-algo-8xx.c 3 kernel/i2c-algo-bit.c drivers/i2c/i2c-algo-bit.c 4 kernel/i2c-algo-ibm_ocp.c drivers/i2c/i2c-algo-ibm_ocp.c 5 kernel/i2c-algo-pcf.c drivers/i2c/i2c-algo-pcf.c 1 6 kernel/i2c-core.c drivers/i2c/i2c-core.c 2 7 kernel/i2c-dev.c drivers/i2c/i2c-dev.c 3 kernel/i2c-proc.c drivers/i2c/i2c-proc.c4 kernel/i2c-algo-8xx.c drivers/i2c/i2c-algo-8xx.c5 kernel/i2c-algo-bit.c drivers/i2c/i2c-algo-bit.c6 kernel/i2c-algo-biths.c drivers/i2c/i2c-algo-biths.c7 kernel/i2c-algo-ibm_ocp.c drivers/i2c/i2c-algo-ibm_ocp.c8 kernel/i2c-algo-pcf.c drivers/i2c/i2c-algo-pcf.c9 8 kernel/i2c-elektor.c drivers/i2c/i2c-elektor.c 10 9 kernel/i2c-elv.c drivers/i2c/i2c-elv.c … … 13 12 kernel/i2c-philips-par.c drivers/i2c/i2c-philips-par.c 14 13 kernel/i2c-pport.c drivers/i2c/i2c-pport.c 14 kernel/i2c-proc.c drivers/i2c/i2c-proc.c 15 15 kernel/i2c-rpx.c drivers/i2c/i2c-rpx.c 16 16 kernel/i2c-velleman.c drivers/i2c/i2c-velleman.c 17 17 kernel/i2c.h include/linux/i2c.h 18 kernel/i2c-id.h include/linux/i2c-id.h19 18 kernel/i2c-dev.h include/linux/i2c-dev.h 20 kernel/i2c-proc.h include/linux/i2c-proc.h21 19 kernel/i2c-algo-8xx.h include/linux/i2c-algo-8xx.h 22 20 kernel/i2c-algo-bit.h include/linux/i2c-algo-bit.h 23 kernel/i2c-algo-biths.h include/linux/i2c-algo-biths.h24 21 kernel/i2c-algo-ibm_ocp.h include/linux/i2c-algo-ibm_ocp.h 25 22 kernel/i2c-algo-pcf.h include/linux/i2c-algo-pcf.h 23 kernel/i2c-elektor.h include/linux/i2c-elektor.h 24 kernel/i2c-id.h include/linux/i2c-id.h 26 25 kernel/i2c-pcf8584.h include/linux/i2c-pcf8584.h 26 kernel/i2c-proc.h include/linux/i2c-proc.h 27 27 doc/dev-interface Documentation/i2c/dev-interface 28 28 doc/functionality Documentation/i2c/functionality 29 doc/i2c-old-porting Documentation/i2c/i2c-old-porting30 29 doc/i2c-pport Documentation/i2c/i2c-pport 31 30 doc/i2c-protocol Documentation/i2c/i2c-protocol -
i2c/trunk/mkpatch/INCLUDES
r3765 r3828 1 1 "i2c.h" <linux/i2c.h> 2 "i2c-id.h" <linux/i2c-id.h>3 2 "i2c-dev.h" <linux/i2c-dev.h> 4 "i2c-proc.h" <linux/i2c-proc.h>5 3 "i2c-algo-bit.h" <linux/i2c-algo-bit.h> 6 "i2c-algo-biths.h" <linux/i2c-algo-biths.h>7 4 "i2c-algo-pcf.h" <linux/i2c-algo-pcf.h> 8 5 "i2c-pcf8584.h" <linux/i2c-pcf8584.h> 6 "i2c-id.h" <linux/i2c-id.h> 7 "i2c-proc.h" <linux/i2c-proc.h> 9 8 "i2c-algo-8xx.h" <linux/i2c-algo-8xx.h> 10 9 "i2c-algo-ibm_ocp.h" <linux/i2c-algo-ibm_ocp.h> -
i2c/trunk/mkpatch/mkpatch.pl
r3765 r3828 1 #!/usr/bin/perl 1 #!/usr/bin/perl -w 2 2 3 3 # mkpatch - Create patches against the Linux kernel … … 38 38 my ($diff_command,$dummy); 39 39 40 $diff_command = "diff -u"; 41 $diff_command .= " $kernel_root/$kernel_file "; 42 $diff_command .= " $package_root/$package_file "; 40 $diff_command = "diff -u2"; 41 if ( -e "$kernel_root/$kernel_file") { 42 $diff_command .= " $kernel_root/$kernel_file "; 43 } else { 44 $diff_command .= " /dev/null "; 45 } 46 if ( -e "$package_root/$package_file") { 47 $diff_command .= " $package_root/$package_file "; 48 } else { 49 $diff_command .= " /dev/null"; 50 } 43 51 open INPUT, "$diff_command|" or die "Can't call `$diff_command'"; 44 if (<INPUT>) { 45 print "--- linux-old/$kernel_file\t".`date`; 46 } 47 if (<INPUT>) { 48 print "+++ linux/$kernel_file\t".`date`; 49 } 52 $dummy = <INPUT>; 53 $dummy = <INPUT>; 54 print "--- linux-old/$kernel_file\t".`date`; 55 print "+++ linux/$kernel_file\t".`date`; 56 50 57 while (<INPUT>) { 51 58 print; … … 54 61 } 55 62 63 # Find all the lm_sensors code in a file 64 # $_[0]: Linux kernel tree (like /usr/src/linux) 65 # $_[1]: Name of the kernel file 66 # Returns a list of strings with the sensors codes 67 sub find_sensors_code 68 { 69 my ($kernel_root,$kernel_file) = @_; 70 my @res; 71 open INPUT, "$kernel_root/$kernel_file" 72 or return @res; 73 while (<INPUT>) { 74 if (m@sensors code starts here@) { 75 push @res,""; 76 while (<INPUT>) { 77 last if m@sensors code ends here@; 78 $res[$#res] .= $_; 79 } 80 } 81 } 82 return @res; 83 } 84 85 # Here we generate diffs for all kernel files mentioned in OLDI2C 86 # which change the invocation # `#include <linux/i2c.h>' to 87 # `#include <linux/i2c-old.h>'. But first, we generate diffs to copy 88 # file <linux/i2c.h> to <linux/i2c-old.h>, if the kernel does not have 89 # this file yet. 90 # $_[0]: sensors package root (like /tmp/sensors) 91 # $_[1]: Linux kernel tree (like /usr/src/linux) 92 sub patch_old_i2c 93 { 94 my ($package_root,$kernel_root) = @_; 95 my (@files,$file,$f); 96 # If i2c.c does not exist, either we renamed it earlier, or there is no 97 # i2c support in this kernel at all. 98 return if not -e "$kernel_root/drivers/char/i2c.c"; 99 100 print_diff $kernel_root,$kernel_root,"include/linux/i2c-old.h", 101 "include/linux/i2c.h"; 102 103 104 open INPUT, "$package_root/mkpatch/OLDI2C" 105 or die "Can't open `$package_root/mkpatch/OLDI2C'"; 106 @files = <INPUT>; 107 close INPUT; 108 109 foreach $f (@files,"drivers/char/i2c-old.c") { 110 $file = $f; # Ugly, but seemingly needed to run on Perl 5.6. 111 chomp $file; 112 if ($file eq "drivers/char/i2c-old.c") { 113 open INPUT, "$kernel_root/drivers/char/i2c.c" 114 or next; 115 } else { 116 open INPUT, "$kernel_root/$file" 117 or next; 118 } 119 open OUTPUT, ">$package_root/$temp" 120 or die "Can't open `$package_root/$temp'"; 121 while (<INPUT>) { 122 s@(\s*#\s*include\s*)<linux/i2c.h>@$1<linux/i2c-old.h>@; 123 print OUTPUT; 124 } 125 close INPUT; 126 close OUTPUT; 127 print_diff $package_root,$kernel_root,$file,$temp; 128 } 129 print_diff "/dev",$kernel_root,"drivers/char/i2c.c","null"; 130 gen_drivers_char_Makefile $package_root, $kernel_root; 131 } 56 132 57 133 # This generates diffs for kernel file Documentation/Configure.help. This … … 274 350 } 275 351 352 # This generates diffs for the main Linux Makefile. 353 # Three lines which add drivers/i2c/i2.a to the DRIVERS list are put just 354 # before the place where the architecture Makefile is included. 355 # Of course, care is taken old lines are removed. 356 # $_[0]: i2c package root (like /tmp/i2c) 357 # $_[1]: Linux kernel tree (like /usr/src/linux) 358 sub gen_Makefile 359 { 360 my ($package_root,$kernel_root) = @_; 361 my $kernel_file = "Makefile"; 362 my $package_file = $temp; 363 my $printed = 0; 364 my $new_style = 0; 365 366 open INPUT,"$kernel_root/$kernel_file" 367 or die "Can't open `$kernel_root/$kernel_file'"; 368 open OUTPUT,">$package_root/$package_file" 369 or die "Can't open $package_root/$package_file"; 370 MAIN: while(<INPUT>) { 371 if (m@^DRIVERS :=@) { 372 $new_style = 1; 373 } 374 if (m@DRIVERS-\$\(CONFIG_I2C\)@) { 375 $_ = <INPUT>; 376 redo MAIN; 377 } elsif (m@CONFIG_I2C@) { 378 $_ = <INPUT> while not m@endif@; 379 $_ = <INPUT>; 380 $_ = <INPUT> if m@^$@; 381 redo MAIN; 382 } 383 if (not $printed and m@DRIVERS-\$\(CONFIG_PHONE\)@) { 384 if ($new_style) { 385 print OUTPUT << 'EOF'; 386 DRIVERS-$(CONFIG_I2C) += drivers/i2c/i2c.a 387 EOF 388 } else { 389 print OUTPUT << 'EOF'; 390 DRIVERS-$(CONFIG_I2C) += drivers/i2c/i2c.o 391 EOF 392 } 393 $printed = 1; 394 } elsif (not $printed and 395 (m@include arch/\$\(ARCH\)/Makefile@ or m@CONFIG_SENSORS@ or 396 m@CONFIG_PHONE@ )) { 397 print OUTPUT <<'EOF'; 398 ifeq ($(CONFIG_I2C),y) 399 DRIVERS := $(DRIVERS) drivers/i2c/i2c.a 400 endif 401 402 EOF 403 $printed = 1; 404 } 405 print OUTPUT; 406 } 407 close INPUT; 408 close OUTPUT; 409 die "Automatic patch generation for main `Makefile' failed.\n". 410 "See our home page http://www.lm-sensors.nu for assistance!" if $printed == 0; 411 print_diff $package_root,$kernel_root,$kernel_file,$package_file; 412 } 413 276 414 # This generates diffs for drivers/Makefile 415 # First, `i2c' is added to the ALL_SUB_DIRS list. Next, a couple of lines 416 # to add i2c to the SUB_DIRS and/or MOD_SUB_DIRS lists is put right before 417 # Rules.make is included. 418 # Of course, care is taken old lines are removed. 277 419 # $_[0]: i2c package root (like /tmp/i2c) 278 420 # $_[1]: Linux kernel tree (like /usr/src/linux) … … 285 427 my $printed = 0; 286 428 my $added = 0; 429 my $new_style = 0; 287 430 288 431 open INPUT,"$kernel_root/$kernel_file" … … 291 434 or die "Can't open $package_root/$package_file"; 292 435 MAIN: while(<INPUT>) { 436 if (m@^mod-subdirs\s*:=@) { 437 $new_style = 1; 438 } 439 if ((! $new_style and m@^ALL_SUB_DIRS\s*:=@) or m@^mod-subdirs\s*:=@ ) { 440 $added = 1; 441 $i2c_present = 0; 442 while (m@\\$@) { 443 $i2c_present = 1 if m@i2c@; 444 print OUTPUT; 445 $_ = <INPUT>; 446 } 447 $i2c_present = 1 if m@i2c@; 448 s@$@ i2c@ if (not $i2c_present); 449 print OUTPUT; 450 $_ = <INPUT>; 451 redo MAIN; 452 } 293 453 if (m@^ifeq.*CONFIG_I2C@) { 294 454 $_ = <INPUT> while not m@^endif@; … … 301 461 redo MAIN; 302 462 } 463 # 2.5 kernels 464 # if (m@^obj.*CONFIG_I2C@) { 465 # } 303 466 if (not $printed and 304 (m@^ifeq \(\$\(CONFIG_ACPI\),y\)$@ or 467 (m@^include \$\(TOPDIR\)/Rules.make$@ or 468 m@^ifeq \(\$\(CONFIG_ACPI\),y\)$@ or 305 469 m@^ifeq \(\$\(CONFIG_SENSORS\),y\)@) or 306 470 m@^subdir-\$\(CONFIG_ACPI\)@) { 471 if ($new_style) { 307 472 print OUTPUT <<'EOF'; 308 473 subdir-$(CONFIG_I2C) += i2c 309 474 EOF 310 $printed = 1; 475 } else { 476 print OUTPUT <<'EOF'; 477 ifeq ($(CONFIG_I2C),y) 478 SUB_DIRS += i2c 479 MOD_SUB_DIRS += i2c 480 else 481 ifeq ($(CONFIG_I2C),m) 482 MOD_SUB_DIRS += i2c 483 endif 484 endif 485 486 EOF 487 } 488 $printed = 1; 311 489 } 312 490 print OUTPUT; … … 319 497 } 320 498 499 # This generates diffs for drivers/char/Makefile 500 # It changes all occurences of `i2c.o' to `i2c-old.o'. 501 # $_[0]: i2c package root (like /tmp/i2c) 502 # $_[1]: Linux kernel tree (like /usr/src/linux) 503 sub gen_drivers_char_Makefile 504 { 505 my ($package_root,$kernel_root) = @_; 506 my $kernel_file = "drivers/char/Makefile"; 507 my $package_file = $temp; 508 open INPUT,"$kernel_root/$kernel_file" 509 or die "Can't open `$kernel_root/$kernel_file'"; 510 open OUTPUT,">$package_root/$package_file" 511 or die "Can't open $package_root/$package_file"; 512 while(<INPUT>) { 513 s@i2c\.o@i2c-old\.o@; 514 print OUTPUT; 515 } 516 close INPUT; 517 close OUTPUT; 518 print_diff $package_root,$kernel_root,$kernel_file,$package_file; 519 } 321 520 322 521 # This generates diffs for drivers/i2c/Makefile 522 # for either 'old style' or 'new style'. 523 # Don't bother putting in 'old style' support for new architectures 524 # like 8xx, IBM405, or StrongARM since they aren't supported 525 # in old kernels anyway. 323 526 sub gen_drivers_i2c_Makefile 324 527 { … … 327 530 my $package_file = $temp; 328 531 my $use_new_format = 0; 532 if (-e "$kernel_root/$kernel_file") { 533 `grep -q -s 'i2c\.o' "$kernel_root/$kernel_file"`; 534 $use_new_format = ! $?; 535 } 329 536 330 537 open OUTPUT,">$package_root/$package_file" 331 538 or die "Can't open $package_root/$package_file"; 332 print OUTPUT <<'EOF'; 539 if ($use_new_format) { 540 print OUTPUT <<'EOF'; 333 541 # 334 542 # Makefile for the kernel i2c bus driver. … … 357 565 obj-$(CONFIG_I2C_FRODO) += i2c-frodo.o 358 566 359 EOF 360 567 # This is needed for automatic patch generation: sensors code starts here 568 # This is needed for automatic patch generation: sensors code ends here 569 570 include $(TOPDIR)/Rules.make 571 572 EOF 573 } else { 574 print OUTPUT <<'EOF'; 575 # 576 # Makefile for the kernel i2c bus driver. 577 # 578 579 SUB_DIRS := 580 MOD_SUB_DIRS := $(SUB_DIRS) 581 ALL_SUB_DIRS := $(SUB_DIRS) 582 MOD_LIST_NAME := I2C_MODULES 583 584 L_TARGET := i2c.a 585 MX_OBJS := 586 M_OBJS := 587 LX_OBJS := 588 L_OBJS := 589 590 # ----- 591 # i2c core components 592 # ----- 593 594 ifeq ($(CONFIG_I2C),y) 595 LX_OBJS += i2c-core.o 596 else 597 ifeq ($(CONFIG_I2C),m) 598 MX_OBJS += i2c-core.o 599 endif 600 endif 601 602 ifeq ($(CONFIG_I2C_CHARDEV),y) 603 L_OBJS += i2c-dev.o 604 else 605 ifeq ($(CONFIG_I2C_CHARDEV),m) 606 M_OBJS += i2c-dev.o 607 endif 608 endif 609 610 ifeq ($(CONFIG_I2C_PROC),y) 611 LX_OBJS += i2c-proc.o 612 else 613 ifeq ($(CONFIG_I2C_PROC),m) 614 MX_OBJS += i2c-proc.o 615 endif 616 endif 617 618 # ----- 619 # Bit banging adapters... 620 # ----- 621 622 ifeq ($(CONFIG_I2C_ALGOBIT),y) 623 LX_OBJS += i2c-algo-bit.o 624 else 625 ifeq ($(CONFIG_I2C_ALGOBIT),m) 626 MX_OBJS += i2c-algo-bit.o 627 endif 628 endif 629 630 ifeq ($(CONFIG_I2C_PHILIPSPAR),y) 631 L_OBJS += i2c-philips-par.o 632 else 633 ifeq ($(CONFIG_I2C_PHILIPSPAR),m) 634 M_OBJS += i2c-philips-par.o 635 endif 636 endif 637 638 ifeq ($(CONFIG_I2C_ELV),y) 639 L_OBJS += i2c-elv.o 640 else 641 ifeq ($(CONFIG_I2C_ELV),m) 642 M_OBJS += i2c-elv.o 643 endif 644 endif 645 646 ifeq ($(CONFIG_I2C_VELLEMAN),y) 647 L_OBJS += i2c-velleman.o 648 else 649 ifeq ($(CONFIG_I2C_VELLEMAN),m) 650 M_OBJS += i2c-velleman.o 651 endif 652 endif 653 654 655 656 # ----- 657 # PCF components 658 # ----- 659 660 ifeq ($(CONFIG_I2C_ALGOPCF),y) 661 LX_OBJS += i2c-algo-pcf.o 662 else 663 ifeq ($(CONFIG_I2C_ALGOPCF),m) 664 MX_OBJS += i2c-algo-pcf.o 665 endif 666 endif 667 668 ifeq ($(CONFIG_I2C_ELEKTOR),y) 669 L_OBJS += i2c-elektor.o 670 else 671 ifeq ($(CONFIG_I2C_ELEKTOR),m) 672 M_OBJS += i2c-elektor.o 673 endif 674 endif 675 676 # This is needed for automatic patch generation: sensors code starts here 677 # This is needed for automatic patch generation: sensors code ends here 678 679 include $(TOPDIR)/Rules.make 680 681 EOF 682 } 361 683 close OUTPUT; 362 684 print_diff $package_root,$kernel_root,$kernel_file,$package_file; 363 685 } 364 686 687 # This generates diffs for drivers/char/Config.in 688 # It adds a line just before CONFIG_APM or main_menu_option lines to include 689 # the I2C Config.in. 690 # Of course, care is taken old lines are removed. 691 # $_[0]: i2c package root (like /tmp/i2c) 692 # $_[1]: Linux kernel tree (like /usr/src/linux) 693 sub gen_drivers_char_Config_in 694 { 695 my ($package_root,$kernel_root) = @_; 696 my $kernel_file = "drivers/char/Config.in"; 697 my $package_file = $temp; 698 my $ready = 0; 699 my $printed = 0; 700 701 open INPUT,"$kernel_root/$kernel_file" 702 or die "Can't open `$kernel_root/$kernel_file'"; 703 open OUTPUT,">$package_root/$package_file" 704 or die "Can't open $package_root/$package_file"; 705 MAIN: while(<INPUT>) { 706 if (m@i2c@) { 707 $_ = <INPUT>; 708 $_ = <INPUT> if (m@^$@); 709 redo MAIN; 710 } 711 if ($ready and not $printed and 712 (m@^mainmenu_option@ or m@CONFIG_APM@ or m@CONFIG_ALPHA_BOOK1@ or 713 m@source drivers/sensors/Config.in@)) { 714 $printed = 1; 715 print OUTPUT <<'EOF'; 716 source drivers/i2c/Config.in 717 718 EOF 719 } 720 $ready = 1 if (m@^mainmenu_option@); 721 print OUTPUT; 722 } 723 close INPUT; 724 close OUTPUT; 725 die "Automatic patch generation for `drivers/char/Config.in' failed.\n". 726 "See our home page http://www.lm-sensors.nu for assistance!" if $printed == 0; 727 print_diff $package_root,$kernel_root,$kernel_file,$package_file; 728 } 365 729 366 730 # Generate the diffs for the list of MAINTAINERS … … 418 782 unless -d "$package_root/mkpatch"; 419 783 $kernel_root = $ARGV[1]; 784 die "Kernel root `$kernel_root' is not found\n" 785 unless -f "$kernel_root/Rules.make"; 786 787 patch_old_i2c $package_root, $kernel_root; 788 420 789 421 790 # --> Read FILES … … 434 803 ($data0,$data1) = /(\S+)\s+(\S+)/; 435 804 $includes{$data0} = $data1; 436 $sedscript .= 's,(#\s*include\s*)'.$data0.'(\s*), \1'."$data1".'\2, ; ';805 $sedscript .= 's,(#\s*include\s*)'.$data0.'(\s*),$1'."$data1".'$2, ; '; 437 806 } 438 807 close INPUT; … … 441 810 foreach $package_file (sort keys %files) { 442 811 $kernel_file = $files{$package_file}; 812 @sensors_subs = find_sensors_code "$kernel_root","$kernel_file"; 443 813 open INPUT, "$package_root/$package_file" 814 or open INPUT, "/dev/null" 444 815 or die "Can't open `$package_root/$package_file'"; 445 816 open OUTPUT, ">$package_root/$temp" … … 447 818 while (<INPUT>) { 448 819 eval $sedscript; 820 if (m@sensors code starts here@) { 821 print OUTPUT; 822 while (<INPUT>) { 823 last if m@sensors code ends here@; 824 } 825 print OUTPUT $sensors_subs[0]; 826 shift @sensors_subs 827 } 449 828 print OUTPUT; 450 829 } … … 457 836 # gen_drivers_Makefile $package_root, $kernel_root; 458 837 # gen_drivers_i2c_Makefile $package_root, $kernel_root; 459 # gen_Documentation_Configure_help $package_root, $kernel_root; 838 # gen_drivers_char_Config_in $package_root, $kernel_root; 839 gen_Documentation_Configure_help $package_root, $kernel_root; 840 # gen_MAINTAINERS $package_root, $kernel_root; 460 841 } 461 842
