Changeset 3828

Show
Ignore:
Timestamp:
07/25/03 09:56:42 (5 years ago)
Author:
khali
Message:

Moved from lk2-4; see that branch for additional history.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • i2c/trunk/CHANGES

    r3789 r3828  
    1818----------------------------------------------------------------------------- 
    1919 
    20 2.8.0 (2003????) 
     202.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() 
    2148  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 
    2556  i2c-id.h: add IDs for i2c-algo-biths, W83627HF, LM85, nForce2, OMAHA, GUIDE, 
    2657            MPC107, IXP2000, IXP425, IOP3XX, UDA1342, S3VIA 
    2758  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 
    2960 
    30612.7.0 (20021208) 
  • i2c/trunk/INSTALL

    r3723 r3828  
    11These 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: 
     2This package is ONLY for 2.4 kernels 2.4.9 or later !!! 
     3 
     4There are three ways in which you can compile and install this package. 
     5Option 1 is much easier and is recommended. 
    56 
    67 1. Complete separate from kernel compilation 
     8    (only for 2.4 kernels 2.4.9 or later) 
    79    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. 
    911 
    1012 2. Semi-integrated into the kernel  
     13    (only for 2.4 kernels 2.4.9 or later) 
    1114    This will add some files to your kernel tree, but has the advantage 
    1215    that module symbols are supported; the end result is functionally very  
     
    1417 
    1518 3. Patching of the kernel 
     19    (only for 2.4 kernels 2.4.13 or later) 
    1620    This will patch your kernel source tree. You must recompile your kernel 
    1721    to take advantage of this. But it makes it possible to compile drivers 
     
    2226method 2 is less well maintained. 
    2327 
    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) 
     28NOTE: SUPPORT FOR KERNELS 2.0.0 - 2.4.8 HAS BEEN DROPPED! 
     29      2.4.9 OR LATER REQUIRED! 
     30 
     31FOR 2.5 KERNELS, Do not attempt to compile this package. 
     32                 Use the drivers already in the 2.5 kernel development tree. 
    2633 
    2734 
     
    119126BUILD_SYSTEM (both) (default: lm_sensors) 
    120127  The build system which is used. lm_sensors corresponds with compilation 
    121   option 1; i2c with compilatin option 2. 
     128  option 1; i2c with compilation option 2. 
    122129SHELL (both) (default: /bin/sh) 
    123130  You may have to specify the full path to Bash here, if /bin/sh is some 
     
    168175 
    169176There 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.3 kernels are no  
     177any 2.4 kernel (2.4.13 and later). Note that older kernels are no  
    171178longer supported. 
    172179Please report any problems to our mailinglist. Note that it may fail,  
  • i2c/trunk/Makefile

    r3753 r3828  
    6060#   /lib/modules/2.2.15-ac9/misc 
    6161#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'"'` 
    6363#MODPREF := /lib/modules/$(KERNELVERSION) 
     64MODPREF := /lib/modules/$(shell $(CC) -I$(LINUX_HEADERS) -E etc/config.c | grep uts_release |cut -f 2 -d'"') 
    6465 
    6566# This is the directory into which the header files will be installed. 
     
    105106# Some often-used commands with default options 
    106107MKDIR := mkdir -p 
     108RMDIR := rmdir 
    107109RM := rm -f 
    108110CC := gcc 
     
    117119# MODCFLAGS is to create in-kernel object files (modules) 
    118120 
    119 CFLAGS := -I$(LINUX_HEADERS) -O2 -DLM_SENSORS 
     121CPPFLAGS := -I$(LINUX_HEADERS) 
     122CFLAGS := -Wall -O2 -DLM_SENSORS 
    120123 
    121124ifeq ($(WARN),1) 
    122 CFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual \ 
     125CFLAGS += -W -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual \ 
    123126          -Wcast-align -Wwrite-strings -Wnested-externs -Winline 
    124127endif 
     
    139142 
    140143ifeq ($(SMP),1) 
    141 MODCFLAGS += -D__SMP__ 
     144MODCPPFLAGS += -D__SMP__ 
    142145endif 
    143146 
    144147ifeq ($(MODVER),1) 
    145 MODCFLAGS += -DMODVERSIONS -include $(LINUX_HEADERS)/linux/modversions.h 
    146 endif 
     148MODCPPFLAGS += -DMODVERSIONS -include $(LINUX_HEADERS)/linux/modversions.h 
     149endif 
     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. 
     154kbuild_2_4_nostdinc := -nostdinc $(shell LC_ALL=C $(CC) -print-search-dirs | sed -ne 's/install: \(.*\)/-I \1include/gp') 
     155MODCPPFLAGS += $(CPPFLAGS) $(kbuild_2_4_nostdinc) 
    147156 
    148157.PHONY: dep 
     
    165174 
    166175all :: 
     176ifeq ($(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 ***************" 
     187endif 
    167188 
    168189install :: 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." 
     192ifeq ($(DESTDIR),) 
     193        -/sbin/depmod -a 
     194else 
     195        -/sbin/depmod -a -b $(DESTDIR) 
     196endif 
     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." 
    169212 
    170213clean:: 
     
    180223# .o files are used for modules 
    181224%.o: %.c 
    182         $(CC) $(MODCFLAGS) -c $< -o $@ 
     225        $(CC) $(MODCPPFLAGS) $(MODCFLAGS) -c $< -o $@ 
    183226 
    184227%.d: %.c 
    185         $(CC) -M -MG $(MODCFLAGS) $< | \ 
     228        $(CC) -M -MG $(MODCPPFLAGS) $(MODCFLAGS) $< | \ 
    186229        sed -e 's@^\(.*\)\.o:@$*.d $*.o: Makefile '`dirname $*.d`/Module.mk' @' > $@ 
    187230 
  • i2c/trunk/QUICKSTART

    r3484 r3828  
    33system, and may cause problems. 
    44 
    5 Quickstart: 
     5Quickstart for compiling outside the kernel. 
     6This is by far the EASIEST METHOD. 
     7Other methods are described in INSTALL. 
     8------------------------------------------ 
     9 
     10  * Verify you are running a 2.4 kernel, 2.4.9 or later. 
     11 
    612  * 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 
    1024  * Do a `make' followed by a `make install'. The warnings about .d 
    1125    files at the start are harmless. 
     26 
    1227  * Make sure you do a `depmod -a'. 
     28 
    1329  * 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. 
     1These package includes the basic i2c drivers. 
     2This package is ONLY for 2.4 kernels 2.4.9 or later !!! 
    23 
    3 Updated means: more updated than the ones found in the current kernels. 
     4ADDITIONALLY, i2c-2.8.0 is not API compatible to earlier i2c 
     5releases due to struct changes; therefore you must NOT ENABLE 
     6any other i2c drivers (e.g. bttv) in the 2.4 kernel. 
     7Do NOT use lm-sensors 2.8.0 or i2c-2.8.0 if you require bttv. 
    48 
    5 If you have used this package before, please read IMPORTANT_CHANGES! 
     9FOR 2.5 KERNELS, Do not attempt to compile this package. 
     10                 Use the drivers already in the 2.5 kernel development tree. 
     11 
     12============================================================================= 
    613 
    714There are basically two kinds of i2c drivers: drivers for busses and drivers 
     
    2128 
    2229You can reach the developers of this package at their mailing list, at 
    23 linux-i2c@pelican.tk.uni-linz.ac.at
     30sensors@stimpy.netroedge.com
  • i2c/trunk/TODO

    r3663 r3828  
    33------------------------------------------------ 
    44 
    5 * Send 2.6.3 patch 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) 
    66 
    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 
    108  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
    1210        - SW PEC for Word Data and Process Call. No place to put PEC 
    1311          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 
    1414 
    1515* Timing considerations in SMBus emulation with i2c-algo-bit (D.E.): 
     16  (Note that some of these changes are implemented in i2c-algo-biths) 
    1617  The Smbus defines a minimum frequency of 10 KHZ for driving the bus, while 
    1718  the I2C does not define any minimum frequency. 
  • i2c/trunk/doc/writing-clients

    r3704 r3828  
    2525address. 
    2626 
    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 */ 
    3735  } 
    3836  
     
    5149below. 
    5250 
    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!  
     51There use to be two additional fields in this structure, inc_use et dec_use, 
     52for module usage count, but these fields were obsoleted and removed. 
    9053 
    9154 
  • i2c/trunk/kernel/Module.mk

    r3788 r3828  
    7171KERNELTARGETS += $(MODULE_DIR)/i2c-pport.o 
    7272endif 
    73 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 
     73#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 
    7676# 
    7777# No CONFIG option for this yet (not in mkpatch) 
     
    9595all-kernel: $(KERNELTARGETS) 
    9696all :: all-kernel 
    97         echo KERNELTARGETS $(KERNELTARGETS) 
    9897 
    9998# 
     
    104103install-kernel: all-kernel 
    105104        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 ; \ 
    116114        fi 
    117115        if [ -n "$(KERNELINCLUDES)" ] ; then \ 
    118116          $(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) ; \ 
    120118        fi 
    121119install :: install-kernel 
  • i2c/trunk/kernel/i2c-algo-bit.c

    r3765 r3828  
    9999                        return -ETIMEDOUT; 
    100100                } 
     101#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 
     102                if (current->need_resched) 
     103                        schedule(); 
     104#else 
    101105                cond_resched(); 
     106#endif 
    102107        } 
    103108        DEBSTAT(printk(KERN_DEBUG "needed %ld jiffies\n", jiffies-start)); 
     
    504509} 
    505510 
    506 static u32 bit_func(struct i2c_adapter *adap) 
     511static u32 bit_func(struct i2c_adapter *i2c_adap) 
    507512{ 
    508513        return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR |  
     
    526531int i2c_bit_add_bus(struct i2c_adapter *adap) 
    527532{ 
    528         int i; 
    529533        struct i2c_algo_bit_data *bit_adap = adap->algo_data; 
    530534 
  • i2c/trunk/kernel/i2c-algo-biths.c

    r3765 r3828  
    167167                                return; 
    168168                        } 
     169#ifdef cond_resched 
    169170                        cond_resched(); 
     171#else 
     172                        if (current->need_resched) { 
     173                                set_current_state(TASK_UNINTERRUPTIBLE); 
     174                                schedule_timeout(1); 
     175                        } 
     176#endif 
    170177                } 
    171178                adap->set_timer(adap); 
  • i2c/trunk/kernel/i2c-algo-pcf.c

    r3765 r3828  
    443443int i2c_pcf_add_bus(struct i2c_adapter *adap) 
    444444{ 
    445         int i, status
     445        int i
    446446        struct i2c_algo_pcf_data *pcf_adap = adap->algo_data; 
    447447 
  • i2c/trunk/kernel/i2c-core.c

    r3768 r3828  
    2222   SMBus 2.0 support by Mark Studebaker <mdsxyz123@yahoo.com>                */ 
    2323 
    24 /* $Id$ */ 
     24/* i2c-core.c,v 1.91.2.2 2003/01/21 10:00:19 kmalkki Exp */ 
    2525 
    2626#include <linux/module.h> 
     
    298298} 
    299299 
    300 int i2c_check_addr (struct i2c_adapter *adapter, int addr) 
     300static int __i2c_check_addr (struct i2c_adapter *adapter, int addr) 
    301301{ 
    302302        int i; 
    303         down(&adapter->list); 
    304303        for (i = 0; i < I2C_CLIENT_MAX ; i++)  
    305304                if (adapter->clients[i] && (adapter->clients[i]->addr == addr)) 
    306305                        return -EBUSY; 
     306 
     307        return 0; 
     308} 
     309 
     310int 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); 
    307316        up(&adapter->list); 
    308         return 0; 
     317 
     318        return rval; 
    309319} 
    310320 
     
    380390} 
    381391 
    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; 
     392static 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); 
    393398} 
    394399 
    395400static void i2c_dec_use_client(struct i2c_client *client) 
    396401{ 
    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); 
    399406} 
    400407 
     
    470477int i2c_use_client(struct i2c_client *client) 
    471478{ 
    472         if (!i2c_inc_use_client(client)) 
    473                 return -ENODEV; 
    474  
    475479        if (client->flags & I2C_CLIENT_ALLOW_USE) { 
    476480                if (client->flags & I2C_CLIENT_ALLOW_MULTIPLE_USE) 
    477481                        client->usage_count++; 
    478482                else if (client->usage_count > 0)  
    479                         goto busy
     483                        return -EBUSY
    480484                else  
    481485                        client->usage_count++; 
    482486        } 
    483487 
     488        i2c_inc_use_client(client); 
     489 
    484490        return 0; 
    485  busy: 
    486         i2c_dec_use_client(client); 
    487         return -EBUSY; 
    488491} 
    489492 
     
    14121415} 
    14131416 
     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 */ 
     1419int __init i2c_init_all(void) 
     1420{ 
     1421        return 0; 
     1422} 
     1423 
    14141424EXPORT_SYMBOL(i2c_add_adapter); 
    14151425EXPORT_SYMBOL(i2c_del_adapter); 
  • i2c/trunk/kernel/i2c-dev.c

    r3765 r3828  
    3636#include <linux/slab.h> 
    3737#include <linux/smp_lock.h> 
     38#ifdef CONFIG_DEVFS_FS 
    3839#include <linux/devfs_fs_kernel.h> 
     40#endif 
    3941#include <linux/init.h> 
    4042#include "i2c.h" 
     
    7678#define I2CDEV_ADAPS_MAX I2C_ADAP_MAX 
    7779static struct i2c_adapter *i2cdev_adaps[I2CDEV_ADAPS_MAX]; 
     80#ifdef CONFIG_DEVFS_FS 
     81static devfs_handle_t devfs_i2c[I2CDEV_ADAPS_MAX]; 
     82static devfs_handle_t devfs_handle = NULL; 
     83#endif 
    7884 
    7985static struct i2c_driver i2cdev_driver = { 
     
    207213                        return -EFAULT; 
    208214 
     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                
    209220                rdwr_pa = (struct i2c_msg *) 
    210221                        kmalloc(rdwr_arg.nmsgs * sizeof(struct i2c_msg),  
     
    221232                        { 
    222233                                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; 
    223239                                break; 
    224240                        } 
     
    233249                                rdwr_pa[i].len)) 
    234250                        { 
    235                                 kfree(rdwr_pa[i].buf); 
    236251                                res = -EFAULT; 
    237252                                break; 
    238253                        } 
     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; 
    239261                } 
    240262                if (!res)  
     
    362384 
    363385        /* registered with adapter, passed as client to user */ 
    364         client->adapter = file->private_data
     386        client->adapter = i2cdev_adaps[minor]
    365387        file->private_data = client; 
    366388 
    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); 
    372391 
    373392#ifdef DEBUG 
     
    386405        client = file->private_data; 
    387406        file->private_data = NULL; 
    388         module_put(client->adapter->owner); 
     407        if(client->adapter->owner) 
     408                __MOD_DEC_USE_COUNT(client->adapter->owner); 
    389409        kfree(client); 
    390410#ifdef DEBUG 
     
    397417{ 
    398418        int i; 
    399         char name[12]; 
     419        char name[8]; 
    400420 
    401421        if ((i = i2c_adapter_id(adap)) < 0) { 
     
    408428        } 
    409429 
    410         sprintf (name, "i2c/%d", i); 
     430        sprintf (name, "%d", i); 
    411431        if (! i2cdev_adaps[i]) { 
    412432                i2cdev_adaps[i] = adap; 
    413                 devfs_register (NULL, name, 
     433#ifdef CONFIG_DEVFS_FS 
     434                devfs_i2c[i] = devfs_register (devfs_handle, name, 
    414435                        DEVFS_FL_DEFAULT, I2C_MAJOR, i, 
    415436                        S_IFCHR | S_IRUSR | S_IWUSR, 
    416437                        &i2cdev_fops, adap); 
     438#endif 
    417439                printk(KERN_DEBUG "i2c-dev.o: Registered '%s' as minor %d\n",adap->name,i); 
    418440        } else { 
    419441                /* 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 
    421445                i2cdev_adaps[i] = NULL; 
    422446#ifdef DEBUG 
     
    445469        printk(KERN_INFO "i2c-dev.o: i2c /dev entries driver module version %s (%s)\n", I2C_VERSION, I2C_DATE); 
    446470 
     471#ifdef CONFIG_DEVFS_FS 
     472        if (devfs_register_chrdev(I2C_MAJOR, "i2c", &i2cdev_fops)) { 
     473#else 
    447474        if (register_chrdev(I2C_MAJOR,"i2c",&i2cdev_fops)) { 
     475#endif 
    448476                printk(KERN_ERR "i2c-dev.o: unable to get major %d for i2c bus\n", 
    449477                       I2C_MAJOR); 
    450478                return -EIO; 
    451479        } 
    452         devfs_mk_dir(NULL, "i2c", NULL); 
     480#ifdef CONFIG_DEVFS_FS 
     481        devfs_handle = devfs_mk_dir(NULL, "i2c", NULL); 
     482#endif 
    453483        if ((res = i2c_add_driver(&i2cdev_driver))) { 
    454484                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 
    456488                unregister_chrdev(I2C_MAJOR,"i2c"); 
    457489                return res; 
     
    463495{ 
    464496        i2c_del_driver(&i2cdev_driver); 
    465         devfs_remove("i2c"); 
     497#ifdef CONFIG_DEVFS_FS 
     498        devfs_unregister(devfs_handle); 
     499#endif 
    466500        unregister_chrdev(I2C_MAJOR,"i2c"); 
    467501} 
  • i2c/trunk/kernel/i2c-dev.h

    r3765 r3828  
    2727#include <linux/types.h> 
    2828 
     29#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,18) 
     30#define minor(d) MINOR(d) 
     31#endif 
     32 
    2933/* Some IOCTL commands are defined in <linux/i2c.h> */ 
    3034/* Note: 10-bit addresses are NOT supported! */ 
     
    3236/* This is the structure as used in the I2C_SMBUS ioctl call */ 
    3337struct i2c_smbus_ioctl_data { 
    34         char read_write; 
     38        __u8 read_write; 
    3539        __u8 command; 
    36         int size; 
     40        __u32 size; 
    3741        union i2c_smbus_data *data; 
    3842}; 
     
    4145struct i2c_rdwr_ioctl_data { 
    4246        struct i2c_msg *msgs;   /* pointers to i2c_msgs */ 
    43         int nmsgs;            /* number of i2c_msgs */ 
     47        __u32 nmsgs;          /* number of i2c_msgs */ 
    4448}; 
    4549 
  • i2c/trunk/kernel/i2c-id.h

    r3789 r3828  
    153153#define I2C_DRIVERID_W83627HF 1038 
    154154#define I2C_DRIVERID_LM85 1039 
     155#define I2C_DRIVERID_LM83 1040 
     156#define I2C_DRIVERID_SAA1064 1041 
    155157 
    156158/* 
  • i2c/trunk/kernel/i2c-pcf-epp.c

    r3765 r3828  
    22/* i2c-pcf-epp.c i2c-hw access for PCF8584 style EPP parallel port adapters  */ 
    33/* ------------------------------------------------------------------------- */ 
     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> */ 
    422 
    523#include <linux/kernel.h> 
     
    252270MODULE_AUTHOR("Hans Berglund <hb@spacetec.no> \n modified by Ryosuke Tajima <rosk@jsk.t.u-tokyo.ac.jp>"); 
    253271MODULE_DESCRIPTION("I2C-Bus adapter routines for PCF8584 EPP parallel port adapter"); 
     272MODULE_LICENSE("GPL"); 
    254273 
    255274MODULE_PARM(base, "i"); 
  • i2c/trunk/kernel/i2c-proc.c

    r3780 r3828  
    3636#include <asm/uaccess.h> 
    3737 
    38 static int i2c_create_name(char **name, const char *prefix, 
    39                                struct i2c_adapter *adapter, int addr); 
    4038static int i2c_parse_reals(int *nrels, void *buffer, int bufsize, 
    4139                               long *results, int magnitude); 
    42 static int i2c_write_reals(int nrels, void *buffer, int *bufsize, 
     40static int i2c_write_reals(int nrels, void *buffer, size_t *bufsize, 
    4341                               long *results, int magnitude); 
    4442static int i2c_proc_chips(ctl_table * ctl, int write, 
     
    5553static struct i2c_client *i2c_clients[SENSORS_ENTRY_MAX]; 
    5654 
    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  
    6655static ctl_table i2c_proc_dev_sensors[] = { 
    6756        {SENSORS_CHIPS, "chips", NULL, 0, 0644, NULL, &i2c_proc_chips, 
     
    7160 
    7261static 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}, 
    7463        {0}, 
    7564}; 
     
    7766 
    7867static 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}, 
    8069        {0} 
    8170}; 
     
    8877   a LM75 chip on the third i2c bus at address 0x4e).   
    8978   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)) 
     79static 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)) { 
    9686                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 
    9995                sprintf(name_buffer, "%s-", prefix); 
    10096                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] == ' ') 
    103100                                break; 
    104101                        name_buffer[end++] = tolower(adapter->algo->name[i]); 
    105102                } 
     103 
    106104                name_buffer[end] = 0; 
    107105                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; 
    120113} 
    121114 
     
    128121   this function must be updated!  */ 
    129122