Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'i2c-for-linus' of git://jdelvare.pck.nerim.net/jdelvare-2.6

* 'i2c-for-linus' of git://jdelvare.pck.nerim.net/jdelvare-2.6:
i2c: Add info->archdata field
i2c: Inform about deprecated chips directory
i2c: Use pci_ioremap_bar()
Schedule removal of the legacy i2c device driver binding model
i2c: Clean up <linux/i2c.h>
i2c: Update and clean up writing-clients document
i2c: Drop 2-byte address block transfer defines
i2c: Delete legacy model documentation
i2c: Constify i2c_get_clientdata's parameter
i2c: Delete outdated client porting guide
i2c: Make clear what the class field of i2c_adapter is good for
i2c-algo-pcf: Fix typo in debugging log message
i2c-algo-pcf: Add adapter hooks around xfer begin and end
i2c-algo-pcf: Pass adapter data into ->waitforpin() method
i2c-i801: Add support for Intel Ibex Peak

+233 -621
+8
Documentation/feature-removal-schedule.txt
··· 359 359 eliminates the need for ide-scsi. The new method is more 360 360 efficient in every way. 361 361 Who: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> 362 + 363 + --------------------------- 364 + 365 + What: i2c_attach_client(), i2c_detach_client(), i2c_driver->detach_client() 366 + When: 2.6.29 (ideally) or 2.6.30 (more likely) 367 + Why: Deprecated by the new (standard) device driver binding model. Use 368 + i2c_driver->probe() and ->remove() instead. 369 + Who: Jean Delvare <khali@linux-fr.org>
+4 -3
Documentation/i2c/busses/i2c-i801
··· 13 13 * Intel 631xESB/632xESB (ESB2) 14 14 * Intel 82801H (ICH8) 15 15 * Intel 82801I (ICH9) 16 - * Intel Tolapai 17 - * Intel ICH10 16 + * Intel EP80579 (Tolapai) 17 + * Intel 82801JI (ICH10) 18 + * Intel PCH 18 19 Datasheets: Publicly available at the Intel website 19 20 20 21 Authors: ··· 33 32 ----------- 34 33 35 34 The ICH (properly known as the 82801AA), ICH0 (82801AB), ICH2 (82801BA), 36 - ICH3 (82801CA/CAM) and later devices are Intel chips that are a part of 35 + ICH3 (82801CA/CAM) and later devices (PCH) are Intel chips that are a part of 37 36 Intel's '810' chipset for Celeron-based PCs, '810E' chipset for 38 37 Pentium-based PCs, '815E' chipset, and others. 39 38
-160
Documentation/i2c/porting-clients
··· 1 - Revision 7, 2007-04-19 2 - Jean Delvare <khali@linux-fr.org> 3 - Greg KH <greg@kroah.com> 4 - 5 - This is a guide on how to convert I2C chip drivers from Linux 2.4 to 6 - Linux 2.6. I have been using existing drivers (lm75, lm78) as examples. 7 - Then I converted a driver myself (lm83) and updated this document. 8 - Note that this guide is strongly oriented towards hardware monitoring 9 - drivers. Many points are still valid for other type of drivers, but 10 - others may be irrelevant. 11 - 12 - There are two sets of points below. The first set concerns technical 13 - changes. The second set concerns coding policy. Both are mandatory. 14 - 15 - Although reading this guide will help you porting drivers, I suggest 16 - you keep an eye on an already ported driver while porting your own 17 - driver. This will help you a lot understanding what this guide 18 - exactly means. Choose the chip driver that is the more similar to 19 - yours for best results. 20 - 21 - Technical changes: 22 - 23 - * [Driver type] Any driver that was relying on i2c-isa has to be 24 - converted to a proper isa, platform or pci driver. This is not 25 - covered by this guide. 26 - 27 - * [Includes] Get rid of "version.h" and <linux/i2c-proc.h>. 28 - Includes typically look like that: 29 - #include <linux/module.h> 30 - #include <linux/init.h> 31 - #include <linux/slab.h> 32 - #include <linux/jiffies.h> 33 - #include <linux/i2c.h> 34 - #include <linux/hwmon.h> /* for hardware monitoring drivers */ 35 - #include <linux/hwmon-sysfs.h> 36 - #include <linux/hwmon-vid.h> /* if you need VRM support */ 37 - #include <linux/err.h> /* for class registration */ 38 - Please respect this inclusion order. Some extra headers may be 39 - required for a given driver (e.g. "lm75.h"). 40 - 41 - * [Addresses] SENSORS_I2C_END becomes I2C_CLIENT_END, ISA addresses 42 - are no more handled by the i2c core. Address ranges are no more 43 - supported either, define each individual address separately. 44 - SENSORS_INSMOD_<n> becomes I2C_CLIENT_INSMOD_<n>. 45 - 46 - * [Client data] Get rid of sysctl_id. Try using standard names for 47 - register values (for example, temp_os becomes temp_max). You're 48 - still relatively free here, but you *have* to follow the standard 49 - names for sysfs files (see the Sysctl section below). 50 - 51 - * [Function prototypes] The detect functions loses its flags 52 - parameter. Sysctl (e.g. lm75_temp) and miscellaneous functions 53 - are off the list of prototypes. This usually leaves five 54 - prototypes: 55 - static int lm75_attach_adapter(struct i2c_adapter *adapter); 56 - static int lm75_detect(struct i2c_adapter *adapter, int address, 57 - int kind); 58 - static void lm75_init_client(struct i2c_client *client); 59 - static int lm75_detach_client(struct i2c_client *client); 60 - static struct lm75_data lm75_update_device(struct device *dev); 61 - 62 - * [Sysctl] All sysctl stuff is of course gone (defines, ctl_table 63 - and functions). Instead, you have to define show and set functions for 64 - each sysfs file. Only define set for writable values. Take a look at an 65 - existing 2.6 driver for details (it87 for example). Don't forget 66 - to define the attributes for each file (this is that step that 67 - links callback functions). Use the file names specified in 68 - Documentation/hwmon/sysfs-interface for the individual files. Also 69 - convert the units these files read and write to the specified ones. 70 - If you need to add a new type of file, please discuss it on the 71 - sensors mailing list <lm-sensors@lm-sensors.org> by providing a 72 - patch to the Documentation/hwmon/sysfs-interface file. 73 - 74 - * [Attach] The attach function should make sure that the adapter's 75 - class has I2C_CLASS_HWMON (or whatever class is suitable for your 76 - driver), using the following construct: 77 - if (!(adapter->class & I2C_CLASS_HWMON)) 78 - return 0; 79 - Call i2c_probe() instead of i2c_detect(). 80 - 81 - * [Detect] As mentioned earlier, the flags parameter is gone. 82 - The type_name and client_name strings are replaced by a single 83 - name string, which will be filled with a lowercase, short string. 84 - The labels used for error paths are reduced to the number needed. 85 - It is advised that the labels are given descriptive names such as 86 - exit and exit_free. Don't forget to properly set err before 87 - jumping to error labels. By the way, labels should be left-aligned. 88 - Use kzalloc instead of kmalloc. 89 - Use i2c_set_clientdata to set the client data (as opposed to 90 - a direct access to client->data). 91 - Use strlcpy instead of strcpy or snprintf to copy the client name. 92 - Replace the sysctl directory registration by calls to 93 - device_create_file. Move the driver initialization before any 94 - sysfs file creation. 95 - Register the client with the hwmon class (using hwmon_device_register) 96 - if applicable. 97 - Drop client->id. 98 - Drop any 24RF08 corruption prevention you find, as this is now done 99 - at the i2c-core level, and doing it twice voids it. 100 - Don't add I2C_CLIENT_ALLOW_USE to client->flags, it's the default now. 101 - 102 - * [Init] Limits must not be set by the driver (can be done later in 103 - user-space). Chip should not be reset default (although a module 104 - parameter may be used to force it), and initialization should be 105 - limited to the strictly necessary steps. 106 - 107 - * [Detach] Remove the call to i2c_deregister_entry. Do not log an 108 - error message if i2c_detach_client fails, as i2c-core will now do 109 - it for you. 110 - Unregister from the hwmon class if applicable. 111 - 112 - * [Update] The function prototype changed, it is now 113 - passed a device structure, which you have to convert to a client 114 - using to_i2c_client(dev). The update function should return a 115 - pointer to the client data. 116 - Don't access client->data directly, use i2c_get_clientdata(client) 117 - instead. 118 - Use time_after() instead of direct jiffies comparison. 119 - 120 - * [Interface] Make sure there is a MODULE_LICENSE() line, at the bottom 121 - of the file (after MODULE_AUTHOR() and MODULE_DESCRIPTION(), in this 122 - order). 123 - 124 - * [Driver] The flags field of the i2c_driver structure is gone. 125 - I2C_DF_NOTIFY is now the default behavior. 126 - The i2c_driver structure has a driver member, which is itself a 127 - structure, those name member should be initialized to a driver name 128 - string. i2c_driver itself has no name member anymore. 129 - 130 - * [Driver model] Instead of shutdown or reboot notifiers, provide a 131 - shutdown() method in your driver. 132 - 133 - * [Power management] Use the driver model suspend() and resume() 134 - callbacks instead of the obsolete pm_register() calls. 135 - 136 - Coding policy: 137 - 138 - * [Copyright] Use (C), not (c), for copyright. 139 - 140 - * [Debug/log] Get rid of #ifdef DEBUG/#endif constructs whenever you 141 - can. Calls to printk for debugging purposes are replaced by calls to 142 - dev_dbg where possible, else to pr_debug. Here is an example of how 143 - to call it (taken from lm75_detect): 144 - dev_dbg(&client->dev, "Starting lm75 update\n"); 145 - Replace other printk calls with the dev_info, dev_err or dev_warn 146 - function, as appropriate. 147 - 148 - * [Constants] Constants defines (registers, conversions) should be 149 - aligned. This greatly improves readability. 150 - Alignments are achieved by the means of tabs, not spaces. Remember 151 - that tabs are set to 8 in the Linux kernel code. 152 - 153 - * [Layout] Avoid extra empty lines between comments and what they 154 - comment. Respect the coding style (see Documentation/CodingStyle), 155 - in particular when it comes to placing curly braces. 156 - 157 - * [Comments] Make sure that no comment refers to a file that isn't 158 - part of the Linux source tree (typically doc/chips/<chip name>), 159 - and that remaining comments still match the code. Merging comment 160 - lines when possible is encouraged.
+108 -367
Documentation/i2c/writing-clients
··· 10 10 =============== 11 11 12 12 Try to keep the kernel namespace as clean as possible. The best way to 13 - do this is to use a unique prefix for all global symbols. This is 13 + do this is to use a unique prefix for all global symbols. This is 14 14 especially important for exported symbols, but it is a good idea to do 15 15 it for non-exported symbols too. We will use the prefix `foo_' in this 16 - tutorial, and `FOO_' for preprocessor variables. 16 + tutorial. 17 17 18 18 19 19 The driver structure 20 20 ==================== 21 21 22 22 Usually, you will implement a single driver structure, and instantiate 23 - all clients from it. Remember, a driver structure contains general access 23 + all clients from it. Remember, a driver structure contains general access 24 24 routines, and should be zero-initialized except for fields with data you 25 25 provide. A client structure holds device-specific information like the 26 26 driver model device node, and its I2C address. 27 - 28 - /* iff driver uses driver model ("new style") binding model: */ 29 27 30 28 static struct i2c_device_id foo_idtable[] = { 31 29 { "foo", my_id_for_foo }, ··· 38 40 .name = "foo", 39 41 }, 40 42 41 - /* iff driver uses driver model ("new style") binding model: */ 42 43 .id_table = foo_ids, 43 44 .probe = foo_probe, 44 45 .remove = foo_remove, ··· 46 49 .detect = foo_detect, 47 50 .address_data = &addr_data, 48 51 49 - /* else, driver uses "legacy" binding model: */ 50 - .attach_adapter = foo_attach_adapter, 51 - .detach_client = foo_detach_client, 52 - 53 - /* these may be used regardless of the driver binding model */ 54 52 .shutdown = foo_shutdown, /* optional */ 55 53 .suspend = foo_suspend, /* optional */ 56 54 .resume = foo_resume, /* optional */ 57 - .command = foo_command, /* optional */ 55 + .command = foo_command, /* optional, deprecated */ 58 56 } 59 - 57 + 60 58 The name field is the driver name, and must not contain spaces. It 61 59 should match the module name (if the driver can be compiled as a module), 62 60 although you can use MODULE_ALIAS (passing "foo" in this example) to add 63 61 another name for the module. If the driver name doesn't match the module 64 62 name, the module won't be automatically loaded (hotplug/coldplug). 65 63 66 - All other fields are for call-back functions which will be explained 64 + All other fields are for call-back functions which will be explained 67 65 below. 68 66 69 67 ··· 66 74 ================= 67 75 68 76 Each client structure has a special `data' field that can point to any 69 - structure at all. You should use this to keep device-specific data, 70 - especially in drivers that handle multiple I2C or SMBUS devices. You 71 - do not always need this, but especially for `sensors' drivers, it can 72 - be very useful. 77 + structure at all. You should use this to keep device-specific data. 73 78 74 79 /* store the value */ 75 80 void i2c_set_clientdata(struct i2c_client *client, void *data); 76 81 77 82 /* retrieve the value */ 78 - void *i2c_get_clientdata(struct i2c_client *client); 79 - 80 - An example structure is below. 81 - 82 - struct foo_data { 83 - struct i2c_client client; 84 - enum chips type; /* To keep the chips type for `sensors' drivers. */ 85 - 86 - /* Because the i2c bus is slow, it is often useful to cache the read 87 - information of a chip for some time (for example, 1 or 2 seconds). 88 - It depends of course on the device whether this is really worthwhile 89 - or even sensible. */ 90 - struct mutex update_lock; /* When we are reading lots of information, 91 - another process should not update the 92 - below information */ 93 - char valid; /* != 0 if the following fields are valid. */ 94 - unsigned long last_updated; /* In jiffies */ 95 - /* Add the read information here too */ 96 - }; 83 + void *i2c_get_clientdata(const struct i2c_client *client); 97 84 98 85 99 86 Accessing the client ··· 80 109 81 110 Let's say we have a valid client structure. At some time, we will need 82 111 to gather information from the client, or write new information to the 83 - client. How we will export this information to user-space is less 84 - important at this moment (perhaps we do not need to do this at all for 85 - some obscure clients). But we need generic reading and writing routines. 112 + client. 86 113 87 - I have found it useful to define foo_read and foo_write function for this. 114 + I have found it useful to define foo_read and foo_write functions for this. 88 115 For some cases, it will be easier to call the i2c functions directly, 89 116 but many chips have some kind of register-value idea that can easily 90 117 be encapsulated. ··· 90 121 The below functions are simple examples, and should not be copied 91 122 literally. 92 123 93 - int foo_read_value(struct i2c_client *client, u8 reg) 94 - { 95 - if (reg < 0x10) /* byte-sized register */ 96 - return i2c_smbus_read_byte_data(client,reg); 97 - else /* word-sized register */ 98 - return i2c_smbus_read_word_data(client,reg); 99 - } 124 + int foo_read_value(struct i2c_client *client, u8 reg) 125 + { 126 + if (reg < 0x10) /* byte-sized register */ 127 + return i2c_smbus_read_byte_data(client, reg); 128 + else /* word-sized register */ 129 + return i2c_smbus_read_word_data(client, reg); 130 + } 100 131 101 - int foo_write_value(struct i2c_client *client, u8 reg, u16 value) 102 - { 103 - if (reg == 0x10) /* Impossible to write - driver error! */ { 104 - return -1; 105 - else if (reg < 0x10) /* byte-sized register */ 106 - return i2c_smbus_write_byte_data(client,reg,value); 107 - else /* word-sized register */ 108 - return i2c_smbus_write_word_data(client,reg,value); 109 - } 132 + int foo_write_value(struct i2c_client *client, u8 reg, u16 value) 133 + { 134 + if (reg == 0x10) /* Impossible to write - driver error! */ 135 + return -EINVAL; 136 + else if (reg < 0x10) /* byte-sized register */ 137 + return i2c_smbus_write_byte_data(client, reg, value); 138 + else /* word-sized register */ 139 + return i2c_smbus_write_word_data(client, reg, value); 140 + } 110 141 111 142 112 143 Probing and attaching 113 144 ===================== 114 145 115 146 The Linux I2C stack was originally written to support access to hardware 116 - monitoring chips on PC motherboards, and thus it embeds some assumptions 117 - that are more appropriate to SMBus (and PCs) than to I2C. One of these 118 - assumptions is that most adapters and devices drivers support the SMBUS_QUICK 119 - protocol to probe device presence. Another is that devices and their drivers 147 + monitoring chips on PC motherboards, and thus used to embed some assumptions 148 + that were more appropriate to SMBus (and PCs) than to I2C. One of these 149 + assumptions was that most adapters and devices drivers support the SMBUS_QUICK 150 + protocol to probe device presence. Another was that devices and their drivers 120 151 can be sufficiently configured using only such probe primitives. 121 152 122 153 As Linux and its I2C stack became more widely used in embedded systems ··· 132 163 since the "legacy" model requires drivers to create "i2c_client" device 133 164 objects after SMBus style probing, while the Linux driver model expects 134 165 drivers to be given such device objects in their probe() routines. 166 + 167 + The legacy model is deprecated now and will soon be removed, so we no 168 + longer document it here. 135 169 136 170 137 171 Standard Driver Model Binding ("New Style") ··· 165 193 the driver knows which one in the table matched. 166 194 167 195 168 - Device Creation (Standard driver model) 169 - --------------------------------------- 196 + Device Creation 197 + --------------- 170 198 171 199 If you know for a fact that an I2C device is connected to a given I2C bus, 172 200 you can instantiate that device by simply filling an i2c_board_info ··· 193 221 reference for later use. 194 222 195 223 196 - Device Detection (Standard driver model) 197 - ---------------------------------------- 224 + Device Detection 225 + ---------------- 198 226 199 227 Sometimes you do not know in advance which I2C devices are connected to 200 228 a given I2C bus. This is for example the case of hardware monitoring ··· 218 246 quickly. 219 247 220 248 221 - Device Deletion (Standard driver model) 222 - --------------------------------------- 249 + Device Deletion 250 + --------------- 223 251 224 252 Each I2C device which has been created using i2c_new_device() or 225 253 i2c_new_probed_device() can be unregistered by calling ··· 228 256 device can't survive its parent in the device driver model. 229 257 230 258 231 - Legacy Driver Binding Model 232 - --------------------------- 259 + Initializing the driver 260 + ======================= 233 261 234 - Most i2c devices can be present on several i2c addresses; for some this 235 - is determined in hardware (by soldering some chip pins to Vcc or Ground), 236 - for others this can be changed in software (by writing to specific client 237 - registers). Some devices are usually on a specific address, but not always; 238 - and some are even more tricky. So you will probably need to scan several 239 - i2c addresses for your clients, and do some sort of detection to see 240 - whether it is actually a device supported by your driver. 262 + When the kernel is booted, or when your foo driver module is inserted, 263 + you have to do some initializing. Fortunately, just registering the 264 + driver module is usually enough. 241 265 242 - To give the user a maximum of possibilities, some default module parameters 243 - are defined to help determine what addresses are scanned. Several macros 244 - are defined in i2c.h to help you support them, as well as a generic 245 - detection algorithm. 266 + static int __init foo_init(void) 267 + { 268 + return i2c_add_driver(&foo_driver); 269 + } 246 270 247 - You do not have to use this parameter interface; but don't try to use 248 - function i2c_probe() if you don't. 271 + static void __exit foo_cleanup(void) 272 + { 273 + i2c_del_driver(&foo_driver); 274 + } 249 275 276 + /* Substitute your own name and email address */ 277 + MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>" 278 + MODULE_DESCRIPTION("Driver for Barf Inc. Foo I2C devices"); 250 279 251 - Probing classes (Legacy model) 252 - ------------------------------ 280 + /* a few non-GPL license types are also allowed */ 281 + MODULE_LICENSE("GPL"); 253 282 254 - All parameters are given as lists of unsigned 16-bit integers. Lists are 255 - terminated by I2C_CLIENT_END. 256 - The following lists are used internally: 283 + module_init(foo_init); 284 + module_exit(foo_cleanup); 257 285 258 - normal_i2c: filled in by the module writer. 259 - A list of I2C addresses which should normally be examined. 260 - probe: insmod parameter. 261 - A list of pairs. The first value is a bus number (-1 for any I2C bus), 262 - the second is the address. These addresses are also probed, as if they 263 - were in the 'normal' list. 264 - ignore: insmod parameter. 265 - A list of pairs. The first value is a bus number (-1 for any I2C bus), 266 - the second is the I2C address. These addresses are never probed. 267 - This parameter overrules the 'normal_i2c' list only. 268 - force: insmod parameter. 269 - A list of pairs. The first value is a bus number (-1 for any I2C bus), 270 - the second is the I2C address. A device is blindly assumed to be on 271 - the given address, no probing is done. 272 - 273 - Additionally, kind-specific force lists may optionally be defined if 274 - the driver supports several chip kinds. They are grouped in a 275 - NULL-terminated list of pointers named forces, those first element if the 276 - generic force list mentioned above. Each additional list correspond to an 277 - insmod parameter of the form force_<kind>. 278 - 279 - Fortunately, as a module writer, you just have to define the `normal_i2c' 280 - parameter. The complete declaration could look like this: 281 - 282 - /* Scan 0x4c to 0x4f */ 283 - static const unsigned short normal_i2c[] = { 0x4c, 0x4d, 0x4e, 0x4f, 284 - I2C_CLIENT_END }; 285 - 286 - /* Magic definition of all other variables and things */ 287 - I2C_CLIENT_INSMOD; 288 - /* Or, if your driver supports, say, 2 kind of devices: */ 289 - I2C_CLIENT_INSMOD_2(foo, bar); 290 - 291 - If you use the multi-kind form, an enum will be defined for you: 292 - enum chips { any_chip, foo, bar, ... } 293 - You can then (and certainly should) use it in the driver code. 294 - 295 - Note that you *have* to call the defined variable `normal_i2c', 296 - without any prefix! 297 - 298 - 299 - Attaching to an adapter (Legacy model) 300 - -------------------------------------- 301 - 302 - Whenever a new adapter is inserted, or for all adapters if the driver is 303 - being registered, the callback attach_adapter() is called. Now is the 304 - time to determine what devices are present on the adapter, and to register 305 - a client for each of them. 306 - 307 - The attach_adapter callback is really easy: we just call the generic 308 - detection function. This function will scan the bus for us, using the 309 - information as defined in the lists explained above. If a device is 310 - detected at a specific address, another callback is called. 311 - 312 - int foo_attach_adapter(struct i2c_adapter *adapter) 313 - { 314 - return i2c_probe(adapter,&addr_data,&foo_detect_client); 315 - } 316 - 317 - Remember, structure `addr_data' is defined by the macros explained above, 318 - so you do not have to define it yourself. 319 - 320 - The i2c_probe function will call the foo_detect_client 321 - function only for those i2c addresses that actually have a device on 322 - them (unless a `force' parameter was used). In addition, addresses that 323 - are already in use (by some other registered client) are skipped. 324 - 325 - 326 - The detect client function (Legacy model) 327 - ----------------------------------------- 328 - 329 - The detect client function is called by i2c_probe. The `kind' parameter 330 - contains -1 for a probed detection, 0 for a forced detection, or a positive 331 - number for a forced detection with a chip type forced. 332 - 333 - Returning an error different from -ENODEV in a detect function will cause 334 - the detection to stop: other addresses and adapters won't be scanned. 335 - This should only be done on fatal or internal errors, such as a memory 336 - shortage or i2c_attach_client failing. 337 - 338 - For now, you can ignore the `flags' parameter. It is there for future use. 339 - 340 - int foo_detect_client(struct i2c_adapter *adapter, int address, 341 - int kind) 342 - { 343 - int err = 0; 344 - int i; 345 - struct i2c_client *client; 346 - struct foo_data *data; 347 - const char *name = ""; 348 - 349 - /* Let's see whether this adapter can support what we need. 350 - Please substitute the things you need here! */ 351 - if (!i2c_check_functionality(adapter,I2C_FUNC_SMBUS_WORD_DATA | 352 - I2C_FUNC_SMBUS_WRITE_BYTE)) 353 - goto ERROR0; 354 - 355 - /* OK. For now, we presume we have a valid client. We now create the 356 - client structure, even though we cannot fill it completely yet. 357 - But it allows us to access several i2c functions safely */ 358 - 359 - if (!(data = kzalloc(sizeof(struct foo_data), GFP_KERNEL))) { 360 - err = -ENOMEM; 361 - goto ERROR0; 362 - } 363 - 364 - client = &data->client; 365 - i2c_set_clientdata(client, data); 366 - 367 - client->addr = address; 368 - client->adapter = adapter; 369 - client->driver = &foo_driver; 370 - 371 - /* Now, we do the remaining detection. If no `force' parameter is used. */ 372 - 373 - /* First, the generic detection (if any), that is skipped if any force 374 - parameter was used. */ 375 - if (kind < 0) { 376 - /* The below is of course bogus */ 377 - if (foo_read(client, FOO_REG_GENERIC) != FOO_GENERIC_VALUE) 378 - goto ERROR1; 379 - } 380 - 381 - /* Next, specific detection. This is especially important for `sensors' 382 - devices. */ 383 - 384 - /* Determine the chip type. Not needed if a `force_CHIPTYPE' parameter 385 - was used. */ 386 - if (kind <= 0) { 387 - i = foo_read(client, FOO_REG_CHIPTYPE); 388 - if (i == FOO_TYPE_1) 389 - kind = chip1; /* As defined in the enum */ 390 - else if (i == FOO_TYPE_2) 391 - kind = chip2; 392 - else { 393 - printk("foo: Ignoring 'force' parameter for unknown chip at " 394 - "adapter %d, address 0x%02x\n",i2c_adapter_id(adapter),address); 395 - goto ERROR1; 396 - } 397 - } 398 - 399 - /* Now set the type and chip names */ 400 - if (kind == chip1) { 401 - name = "chip1"; 402 - } else if (kind == chip2) { 403 - name = "chip2"; 404 - } 405 - 406 - /* Fill in the remaining client fields. */ 407 - strlcpy(client->name, name, I2C_NAME_SIZE); 408 - data->type = kind; 409 - mutex_init(&data->update_lock); /* Only if you use this field */ 410 - 411 - /* Any other initializations in data must be done here too. */ 412 - 413 - /* This function can write default values to the client registers, if 414 - needed. */ 415 - foo_init_client(client); 416 - 417 - /* Tell the i2c layer a new client has arrived */ 418 - if ((err = i2c_attach_client(client))) 419 - goto ERROR1; 420 - 421 - return 0; 422 - 423 - /* OK, this is not exactly good programming practice, usually. But it is 424 - very code-efficient in this case. */ 425 - 426 - ERROR1: 427 - kfree(data); 428 - ERROR0: 429 - return err; 430 - } 431 - 432 - 433 - Removing the client (Legacy model) 434 - ================================== 435 - 436 - The detach_client call back function is called when a client should be 437 - removed. It may actually fail, but only when panicking. This code is 438 - much simpler than the attachment code, fortunately! 439 - 440 - int foo_detach_client(struct i2c_client *client) 441 - { 442 - int err; 443 - 444 - /* Try to detach the client from i2c space */ 445 - if ((err = i2c_detach_client(client))) 446 - return err; 447 - 448 - kfree(i2c_get_clientdata(client)); 449 - return 0; 450 - } 451 - 452 - 453 - Initializing the module or kernel 454 - ================================= 455 - 456 - When the kernel is booted, or when your foo driver module is inserted, 457 - you have to do some initializing. Fortunately, just attaching (registering) 458 - the driver module is usually enough. 459 - 460 - static int __init foo_init(void) 461 - { 462 - int res; 463 - 464 - if ((res = i2c_add_driver(&foo_driver))) { 465 - printk("foo: Driver registration failed, module not inserted.\n"); 466 - return res; 467 - } 468 - return 0; 469 - } 470 - 471 - static void __exit foo_cleanup(void) 472 - { 473 - i2c_del_driver(&foo_driver); 474 - } 475 - 476 - /* Substitute your own name and email address */ 477 - MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>" 478 - MODULE_DESCRIPTION("Driver for Barf Inc. Foo I2C devices"); 479 - 480 - /* a few non-GPL license types are also allowed */ 481 - MODULE_LICENSE("GPL"); 482 - 483 - module_init(foo_init); 484 - module_exit(foo_cleanup); 485 - 486 - Note that some functions are marked by `__init', and some data structures 487 - by `__initdata'. These functions and structures can be removed after 488 - kernel booting (or module loading) is completed. 286 + Note that some functions are marked by `__init'. These functions can 287 + be removed after kernel booting (or module loading) is completed. 288 + Likewise, functions marked by `__exit' are dropped by the compiler when 289 + the code is built into the kernel, as they would never be called. 489 290 490 291 491 292 Power Management ··· 293 548 294 549 A generic ioctl-like function call back is supported. You will seldom 295 550 need this, and its use is deprecated anyway, so newer design should not 296 - use it. Set it to NULL. 551 + use it. 297 552 298 553 299 554 Sending and receiving 300 555 ===================== 301 556 302 557 If you want to communicate with your device, there are several functions 303 - to do this. You can find all of them in i2c.h. 558 + to do this. You can find all of them in <linux/i2c.h>. 304 559 305 - If you can choose between plain i2c communication and SMBus level 306 - communication, please use the last. All adapters understand SMBus level 307 - commands, but only some of them understand plain i2c! 560 + If you can choose between plain I2C communication and SMBus level 561 + communication, please use the latter. All adapters understand SMBus level 562 + commands, but only some of them understand plain I2C! 308 563 309 564 310 - Plain i2c communication 565 + Plain I2C communication 311 566 ----------------------- 312 567 313 - extern int i2c_master_send(struct i2c_client *,const char* ,int); 314 - extern int i2c_master_recv(struct i2c_client *,char* ,int); 568 + int i2c_master_send(struct i2c_client *client, const char *buf, 569 + int count); 570 + int i2c_master_recv(struct i2c_client *client, char *buf, int count); 315 571 316 572 These routines read and write some bytes from/to a client. The client 317 573 contains the i2c address, so you do not have to include it. The second 318 - parameter contains the bytes the read/write, the third the length of the 319 - buffer. Returned is the actual number of bytes read/written. 320 - 321 - extern int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msg, 322 - int num); 574 + parameter contains the bytes to read/write, the third the number of bytes 575 + to read/write (must be less than the length of the buffer.) Returned is 576 + the actual number of bytes read/written. 577 + 578 + int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msg, 579 + int num); 323 580 324 581 This sends a series of messages. Each message can be a read or write, 325 582 and they can be mixed in any way. The transactions are combined: no ··· 330 583 and the message data itself. 331 584 332 585 You can read the file `i2c-protocol' for more information about the 333 - actual i2c protocol. 586 + actual I2C protocol. 334 587 335 588 336 589 SMBus communication 337 590 ------------------- 338 591 339 - extern s32 i2c_smbus_xfer (struct i2c_adapter * adapter, u16 addr, 340 - unsigned short flags, 341 - char read_write, u8 command, int size, 342 - union i2c_smbus_data * data); 592 + s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, 593 + unsigned short flags, char read_write, u8 command, 594 + int size, union i2c_smbus_data *data); 343 595 344 - This is the generic SMBus function. All functions below are implemented 345 - in terms of it. Never use this function directly! 596 + This is the generic SMBus function. All functions below are implemented 597 + in terms of it. Never use this function directly! 346 598 347 - 348 - extern s32 i2c_smbus_read_byte(struct i2c_client * client); 349 - extern s32 i2c_smbus_write_byte(struct i2c_client * client, u8 value); 350 - extern s32 i2c_smbus_read_byte_data(struct i2c_client * client, u8 command); 351 - extern s32 i2c_smbus_write_byte_data(struct i2c_client * client, 352 - u8 command, u8 value); 353 - extern s32 i2c_smbus_read_word_data(struct i2c_client * client, u8 command); 354 - extern s32 i2c_smbus_write_word_data(struct i2c_client * client, 355 - u8 command, u16 value); 356 - extern s32 i2c_smbus_process_call(struct i2c_client *client, 357 - u8 command, u16 value); 358 - extern s32 i2c_smbus_read_block_data(struct i2c_client * client, 359 - u8 command, u8 *values); 360 - extern s32 i2c_smbus_write_block_data(struct i2c_client * client, 361 - u8 command, u8 length, 362 - u8 *values); 363 - extern s32 i2c_smbus_read_i2c_block_data(struct i2c_client * client, 364 - u8 command, u8 length, u8 *values); 365 - extern s32 i2c_smbus_write_i2c_block_data(struct i2c_client * client, 366 - u8 command, u8 length, 367 - u8 *values); 599 + s32 i2c_smbus_read_byte(struct i2c_client *client); 600 + s32 i2c_smbus_write_byte(struct i2c_client *client, u8 value); 601 + s32 i2c_smbus_read_byte_data(struct i2c_client *client, u8 command); 602 + s32 i2c_smbus_write_byte_data(struct i2c_client *client, 603 + u8 command, u8 value); 604 + s32 i2c_smbus_read_word_data(struct i2c_client *client, u8 command); 605 + s32 i2c_smbus_write_word_data(struct i2c_client *client, 606 + u8 command, u16 value); 607 + s32 i2c_smbus_process_call(struct i2c_client *client, 608 + u8 command, u16 value); 609 + s32 i2c_smbus_read_block_data(struct i2c_client *client, 610 + u8 command, u8 *values); 611 + s32 i2c_smbus_write_block_data(struct i2c_client *client, 612 + u8 command, u8 length, const u8 *values); 613 + s32 i2c_smbus_read_i2c_block_data(struct i2c_client *client, 614 + u8 command, u8 length, u8 *values); 615 + s32 i2c_smbus_write_i2c_block_data(struct i2c_client *client, 616 + u8 command, u8 length, 617 + const u8 *values); 368 618 369 619 These ones were removed from i2c-core because they had no users, but could 370 620 be added back later if needed: 371 621 372 - extern s32 i2c_smbus_write_quick(struct i2c_client * client, u8 value); 373 - extern s32 i2c_smbus_block_process_call(struct i2c_client *client, 374 - u8 command, u8 length, 375 - u8 *values) 622 + s32 i2c_smbus_write_quick(struct i2c_client *client, u8 value); 623 + s32 i2c_smbus_block_process_call(struct i2c_client *client, 624 + u8 command, u8 length, u8 *values); 376 625 377 626 All these transactions return a negative errno value on failure. The 'write' 378 627 transactions return 0 on success; the 'read' transactions return the read ··· 385 642 Below all general purpose routines are listed, that were not mentioned 386 643 before. 387 644 388 - /* This call returns a unique low identifier for each registered adapter. 389 - */ 390 - extern int i2c_adapter_id(struct i2c_adapter *adap); 391 - 645 + /* Return the adapter number for a specific adapter */ 646 + int i2c_adapter_id(struct i2c_adapter *adap);
+15 -6
drivers/i2c/algos/i2c-algo-pcf.c
··· 135 135 *status = get_pcf(adap, 1); 136 136 #ifndef STUB_I2C 137 137 while (timeout-- && (*status & I2C_PCF_PIN)) { 138 - adap->waitforpin(); 138 + adap->waitforpin(adap->data); 139 139 *status = get_pcf(adap, 1); 140 140 } 141 141 if (*status & I2C_PCF_LAB) { ··· 208 208 return -ENXIO; 209 209 } 210 210 211 - printk(KERN_DEBUG "i2c-algo-pcf.o: deteted and initialized PCF8584.\n"); 211 + printk(KERN_DEBUG "i2c-algo-pcf.o: detected and initialized PCF8584.\n"); 212 212 213 213 return 0; 214 214 } ··· 331 331 int i; 332 332 int ret=0, timeout, status; 333 333 334 + if (adap->xfer_begin) 335 + adap->xfer_begin(adap->data); 334 336 335 337 /* Check for bus busy */ 336 338 timeout = wait_for_bb(adap); 337 339 if (timeout) { 338 340 DEB2(printk(KERN_ERR "i2c-algo-pcf.o: " 339 341 "Timeout waiting for BB in pcf_xfer\n");) 340 - return -EIO; 342 + i = -EIO; 343 + goto out; 341 344 } 342 345 343 346 for (i = 0;ret >= 0 && i < num; i++) { ··· 362 359 if (timeout) { 363 360 if (timeout == -EINTR) { 364 361 /* arbitration lost */ 365 - return (-EINTR); 362 + i = -EINTR; 363 + goto out; 366 364 } 367 365 i2c_stop(adap); 368 366 DEB2(printk(KERN_ERR "i2c-algo-pcf.o: Timeout waiting " 369 367 "for PIN(1) in pcf_xfer\n");) 370 - return (-EREMOTEIO); 368 + i = -EREMOTEIO; 369 + goto out; 371 370 } 372 371 373 372 #ifndef STUB_I2C ··· 377 372 if (status & I2C_PCF_LRB) { 378 373 i2c_stop(adap); 379 374 DEB2(printk(KERN_ERR "i2c-algo-pcf.o: No LRB(1) in pcf_xfer\n");) 380 - return (-EREMOTEIO); 375 + i = -EREMOTEIO; 376 + goto out; 381 377 } 382 378 #endif 383 379 ··· 410 404 } 411 405 } 412 406 407 + out: 408 + if (adap->xfer_end) 409 + adap->xfer_end(adap->data); 413 410 return (i); 414 411 } 415 412
+1
drivers/i2c/busses/Kconfig
··· 97 97 ICH9 98 98 Tolapai 99 99 ICH10 100 + PCH 100 101 101 102 This driver can also be built as a module. If so, the module 102 103 will be called i2c-i801.
+2 -1
drivers/i2c/busses/i2c-elektor.c
··· 104 104 return (clock); 105 105 } 106 106 107 - static void pcf_isa_waitforpin(void) { 107 + static void pcf_isa_waitforpin(void *data) 108 + { 108 109 DEFINE_WAIT(wait); 109 110 int timeout = 2; 110 111 unsigned long flags;
+1 -1
drivers/i2c/busses/i2c-hydra.c
··· 123 123 hydra_adap.name)) 124 124 return -EBUSY; 125 125 126 - hydra_bit_data.data = ioremap(base, pci_resource_len(dev, 0)); 126 + hydra_bit_data.data = pci_ioremap_bar(dev, 0); 127 127 if (hydra_bit_data.data == NULL) { 128 128 release_mem_region(base+offsetof(struct Hydra, CachePD), 4); 129 129 return -ENODEV;
+3
drivers/i2c/busses/i2c-i801.c
··· 41 41 Tolapai 0x5032 32 hard yes yes yes 42 42 ICH10 0x3a30 32 hard yes yes yes 43 43 ICH10 0x3a60 32 hard yes yes yes 44 + PCH 0x3b30 32 hard yes yes yes 44 45 45 46 Features supported by this driver: 46 47 Software PEC no ··· 577 576 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_TOLAPAI_1) }, 578 577 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH10_4) }, 579 578 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH10_5) }, 579 + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PCH_SMBUS) }, 580 580 { 0, } 581 581 }; 582 582 ··· 601 599 case PCI_DEVICE_ID_INTEL_TOLAPAI_1: 602 600 case PCI_DEVICE_ID_INTEL_ICH10_4: 603 601 case PCI_DEVICE_ID_INTEL_ICH10_5: 602 + case PCI_DEVICE_ID_INTEL_PCH_SMBUS: 604 603 i801_features |= FEATURE_I2C_BLOCK_READ; 605 604 /* fall through */ 606 605 case PCI_DEVICE_ID_INTEL_82801DB_3:
+2
drivers/i2c/chips/Kconfig
··· 1 1 # 2 2 # Miscellaneous I2C chip drivers configuration 3 3 # 4 + # *** DEPRECATED! Do not add new entries! See Makefile *** 5 + # 4 6 5 7 menu "Miscellaneous I2C Chip support" 6 8
+2 -1
drivers/i2c/chips/Makefile
··· 1 1 # 2 2 # Makefile for miscellaneous I2C chip drivers. 3 3 # 4 - # Think twice before you add a new driver to this directory. 4 + # Do not add new drivers to this directory! It is DEPRECATED. 5 + # 5 6 # Device drivers are better grouped according to the functionality they 6 7 # implement rather than to the bus they are connected to. In particular: 7 8 # * Hardware monitoring chip drivers go to drivers/hwmon
+3
drivers/i2c/i2c-core.c
··· 266 266 267 267 client->dev.platform_data = info->platform_data; 268 268 269 + if (info->archdata) 270 + client->dev.archdata = *info->archdata; 271 + 269 272 client->flags = info->flags; 270 273 client->addr = info->addr; 271 274 client->irq = info->irq;
+1 -1
include/linux/device.h
··· 450 450 } 451 451 #endif 452 452 453 - static inline void *dev_get_drvdata(struct device *dev) 453 + static inline void *dev_get_drvdata(const struct device *dev) 454 454 { 455 455 return dev->driver_data; 456 456 }
+4 -1
include/linux/i2c-algo-pcf.h
··· 31 31 int (*getpcf) (void *data, int ctl); 32 32 int (*getown) (void *data); 33 33 int (*getclock) (void *data); 34 - void (*waitforpin) (void); 34 + void (*waitforpin) (void *data); 35 + 36 + void (*xfer_begin) (void *data); 37 + void (*xfer_end) (void *data); 35 38 36 39 /* Multi-master lost arbitration back-off delay (msecs) 37 40 * This should be set by the bus adapter or knowledgable client
+79 -80
include/linux/i2c.h
··· 53 53 * transmit one message at a time, a more complex version can be used to 54 54 * transmit an arbitrary number of messages without interruption. 55 55 */ 56 - extern int i2c_master_send(struct i2c_client *,const char* ,int); 57 - extern int i2c_master_recv(struct i2c_client *,char* ,int); 56 + extern int i2c_master_send(struct i2c_client *client, const char *buf, 57 + int count); 58 + extern int i2c_master_recv(struct i2c_client *client, char *buf, int count); 58 59 59 60 /* Transfer num messages. 60 61 */ 61 - extern int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num); 62 - 62 + extern int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, 63 + int num); 63 64 64 65 /* This is the very generalized SMBus access routine. You probably do not 65 66 want to use this, though; one of the functions below may be much easier, 66 67 and probably just as fast. 67 68 Note that we use i2c_adapter here, because you do not need a specific 68 69 smbus adapter to call this function. */ 69 - extern s32 i2c_smbus_xfer (struct i2c_adapter * adapter, u16 addr, 70 - unsigned short flags, 71 - char read_write, u8 command, int size, 72 - union i2c_smbus_data * data); 70 + extern s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, 71 + unsigned short flags, char read_write, u8 command, 72 + int size, union i2c_smbus_data *data); 73 73 74 74 /* Now follow the 'nice' access routines. These also document the calling 75 75 conventions of i2c_smbus_xfer. */ 76 76 77 - extern s32 i2c_smbus_read_byte(struct i2c_client * client); 78 - extern s32 i2c_smbus_write_byte(struct i2c_client * client, u8 value); 79 - extern s32 i2c_smbus_read_byte_data(struct i2c_client * client, u8 command); 80 - extern s32 i2c_smbus_write_byte_data(struct i2c_client * client, 81 - u8 command, u8 value); 82 - extern s32 i2c_smbus_read_word_data(struct i2c_client * client, u8 command); 83 - extern s32 i2c_smbus_write_word_data(struct i2c_client * client, 84 - u8 command, u16 value); 77 + extern s32 i2c_smbus_read_byte(struct i2c_client *client); 78 + extern s32 i2c_smbus_write_byte(struct i2c_client *client, u8 value); 79 + extern s32 i2c_smbus_read_byte_data(struct i2c_client *client, u8 command); 80 + extern s32 i2c_smbus_write_byte_data(struct i2c_client *client, 81 + u8 command, u8 value); 82 + extern s32 i2c_smbus_read_word_data(struct i2c_client *client, u8 command); 83 + extern s32 i2c_smbus_write_word_data(struct i2c_client *client, 84 + u8 command, u16 value); 85 85 /* Returns the number of read bytes */ 86 86 extern s32 i2c_smbus_read_block_data(struct i2c_client *client, 87 87 u8 command, u8 *values); 88 - extern s32 i2c_smbus_write_block_data(struct i2c_client * client, 89 - u8 command, u8 length, 90 - const u8 *values); 88 + extern s32 i2c_smbus_write_block_data(struct i2c_client *client, 89 + u8 command, u8 length, const u8 *values); 91 90 /* Returns the number of read bytes */ 92 - extern s32 i2c_smbus_read_i2c_block_data(struct i2c_client * client, 91 + extern s32 i2c_smbus_read_i2c_block_data(struct i2c_client *client, 93 92 u8 command, u8 length, u8 *values); 94 - extern s32 i2c_smbus_write_i2c_block_data(struct i2c_client * client, 93 + extern s32 i2c_smbus_write_i2c_block_data(struct i2c_client *client, 95 94 u8 command, u8 length, 96 95 const u8 *values); 97 96 ··· 168 169 /* a ioctl like command that can be used to perform specific functions 169 170 * with the device. 170 171 */ 171 - int (*command)(struct i2c_client *client,unsigned int cmd, void *arg); 172 + int (*command)(struct i2c_client *client, unsigned int cmd, void *arg); 172 173 173 174 struct device_driver driver; 174 175 const struct i2c_device_id *id_table; ··· 223 224 return to_i2c_client(dev); 224 225 } 225 226 226 - static inline void *i2c_get_clientdata (struct i2c_client *dev) 227 + static inline void *i2c_get_clientdata(const struct i2c_client *dev) 227 228 { 228 - return dev_get_drvdata (&dev->dev); 229 + return dev_get_drvdata(&dev->dev); 229 230 } 230 231 231 - static inline void i2c_set_clientdata (struct i2c_client *dev, void *data) 232 + static inline void i2c_set_clientdata(struct i2c_client *dev, void *data) 232 233 { 233 - dev_set_drvdata (&dev->dev, data); 234 + dev_set_drvdata(&dev->dev, data); 234 235 } 235 236 236 237 /** ··· 239 240 * @flags: to initialize i2c_client.flags 240 241 * @addr: stored in i2c_client.addr 241 242 * @platform_data: stored in i2c_client.dev.platform_data 243 + * @archdata: copied into i2c_client.dev.archdata 242 244 * @irq: stored in i2c_client.irq 243 245 * 244 246 * I2C doesn't actually support hardware probing, although controllers and ··· 259 259 unsigned short flags; 260 260 unsigned short addr; 261 261 void *platform_data; 262 + struct dev_archdata *archdata; 262 263 int irq; 263 264 }; 264 265 ··· 273 272 * fields (such as associated irq, or device-specific platform_data) 274 273 * are provided using conventional syntax. 275 274 */ 276 - #define I2C_BOARD_INFO(dev_type,dev_addr) \ 275 + #define I2C_BOARD_INFO(dev_type, dev_addr) \ 277 276 .type = (dev_type), .addr = (dev_addr) 278 277 279 278 ··· 307 306 */ 308 307 #ifdef CONFIG_I2C_BOARDINFO 309 308 extern int 310 - i2c_register_board_info(int busnum, struct i2c_board_info const *info, unsigned n); 309 + i2c_register_board_info(int busnum, struct i2c_board_info const *info, 310 + unsigned n); 311 311 #else 312 312 static inline int 313 - i2c_register_board_info(int busnum, struct i2c_board_info const *info, unsigned n) 313 + i2c_register_board_info(int busnum, struct i2c_board_info const *info, 314 + unsigned n) 314 315 { 315 316 return 0; 316 317 } ··· 331 328 using common I2C messages */ 332 329 /* master_xfer should return the number of messages successfully 333 330 processed, or a negative value on error */ 334 - int (*master_xfer)(struct i2c_adapter *adap,struct i2c_msg *msgs, 335 - int num); 331 + int (*master_xfer)(struct i2c_adapter *adap, struct i2c_msg *msgs, 332 + int num); 336 333 int (*smbus_xfer) (struct i2c_adapter *adap, u16 addr, 337 - unsigned short flags, char read_write, 338 - u8 command, int size, union i2c_smbus_data * data); 334 + unsigned short flags, char read_write, 335 + u8 command, int size, union i2c_smbus_data *data); 339 336 340 337 /* To determine what the adapter supports */ 341 338 u32 (*functionality) (struct i2c_adapter *); ··· 348 345 struct i2c_adapter { 349 346 struct module *owner; 350 347 unsigned int id; 351 - unsigned int class; 348 + unsigned int class; /* classes to allow probing for */ 352 349 const struct i2c_algorithm *algo; /* the algorithm to access the bus */ 353 350 void *algo_data; 354 351 ··· 372 369 }; 373 370 #define to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev) 374 371 375 - static inline void *i2c_get_adapdata (struct i2c_adapter *dev) 372 + static inline void *i2c_get_adapdata(const struct i2c_adapter *dev) 376 373 { 377 - return dev_get_drvdata (&dev->dev); 374 + return dev_get_drvdata(&dev->dev); 378 375 } 379 376 380 - static inline void i2c_set_adapdata (struct i2c_adapter *dev, void *data) 377 + static inline void i2c_set_adapdata(struct i2c_adapter *dev, void *data) 381 378 { 382 - dev_set_drvdata (&dev->dev, data); 379 + dev_set_drvdata(&dev->dev, data); 383 380 } 384 381 385 382 /*flags for the client struct: */ ··· 452 449 const struct i2c_client_address_data *address_data, 453 450 int (*found_proc) (struct i2c_adapter *, int, int)); 454 451 455 - extern struct i2c_adapter* i2c_get_adapter(int id); 452 + extern struct i2c_adapter *i2c_get_adapter(int id); 456 453 extern void i2c_put_adapter(struct i2c_adapter *adap); 457 454 458 455 ··· 468 465 return (func & i2c_get_functionality(adap)) == func; 469 466 } 470 467 471 - /* Return id number for a specific adapter */ 468 + /* Return the adapter number for a specific adapter */ 472 469 static inline int i2c_adapter_id(struct i2c_adapter *adap) 473 470 { 474 471 return adap->nr; ··· 529 526 530 527 #define I2C_FUNC_I2C 0x00000001 531 528 #define I2C_FUNC_10BIT_ADDR 0x00000002 532 - #define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_{REV_DIR_ADDR,NOSTART,..} */ 529 + #define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_NOSTART etc. */ 533 530 #define I2C_FUNC_SMBUS_PEC 0x00000008 534 531 #define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 */ 535 532 #define I2C_FUNC_SMBUS_QUICK 0x00010000 ··· 544 541 #define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000 545 542 #define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 /* I2C-like block xfer */ 546 543 #define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* w/ 1-byte reg. addr. */ 547 - #define I2C_FUNC_SMBUS_READ_I2C_BLOCK_2 0x10000000 /* I2C-like block xfer */ 548 - #define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK_2 0x20000000 /* w/ 2-byte reg. addr. */ 549 544 550 - #define I2C_FUNC_SMBUS_BYTE (I2C_FUNC_SMBUS_READ_BYTE | \ 551 - I2C_FUNC_SMBUS_WRITE_BYTE) 552 - #define I2C_FUNC_SMBUS_BYTE_DATA (I2C_FUNC_SMBUS_READ_BYTE_DATA | \ 553 - I2C_FUNC_SMBUS_WRITE_BYTE_DATA) 554 - #define I2C_FUNC_SMBUS_WORD_DATA (I2C_FUNC_SMBUS_READ_WORD_DATA | \ 555 - I2C_FUNC_SMBUS_WRITE_WORD_DATA) 556 - #define I2C_FUNC_SMBUS_BLOCK_DATA (I2C_FUNC_SMBUS_READ_BLOCK_DATA | \ 557 - I2C_FUNC_SMBUS_WRITE_BLOCK_DATA) 558 - #define I2C_FUNC_SMBUS_I2C_BLOCK (I2C_FUNC_SMBUS_READ_I2C_BLOCK | \ 559 - I2C_FUNC_SMBUS_WRITE_I2C_BLOCK) 560 - #define I2C_FUNC_SMBUS_I2C_BLOCK_2 (I2C_FUNC_SMBUS_READ_I2C_BLOCK_2 | \ 561 - I2C_FUNC_SMBUS_WRITE_I2C_BLOCK_2) 545 + #define I2C_FUNC_SMBUS_BYTE (I2C_FUNC_SMBUS_READ_BYTE | \ 546 + I2C_FUNC_SMBUS_WRITE_BYTE) 547 + #define I2C_FUNC_SMBUS_BYTE_DATA (I2C_FUNC_SMBUS_READ_BYTE_DATA | \ 548 + I2C_FUNC_SMBUS_WRITE_BYTE_DATA) 549 + #define I2C_FUNC_SMBUS_WORD_DATA (I2C_FUNC_SMBUS_READ_WORD_DATA | \ 550 + I2C_FUNC_SMBUS_WRITE_WORD_DATA) 551 + #define I2C_FUNC_SMBUS_BLOCK_DATA (I2C_FUNC_SMBUS_READ_BLOCK_DATA | \ 552 + I2C_FUNC_SMBUS_WRITE_BLOCK_DATA) 553 + #define I2C_FUNC_SMBUS_I2C_BLOCK (I2C_FUNC_SMBUS_READ_I2C_BLOCK | \ 554 + I2C_FUNC_SMBUS_WRITE_I2C_BLOCK) 562 555 563 - #define I2C_FUNC_SMBUS_EMUL (I2C_FUNC_SMBUS_QUICK | \ 564 - I2C_FUNC_SMBUS_BYTE | \ 565 - I2C_FUNC_SMBUS_BYTE_DATA | \ 566 - I2C_FUNC_SMBUS_WORD_DATA | \ 567 - I2C_FUNC_SMBUS_PROC_CALL | \ 568 - I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | \ 569 - I2C_FUNC_SMBUS_I2C_BLOCK | \ 570 - I2C_FUNC_SMBUS_PEC) 556 + #define I2C_FUNC_SMBUS_EMUL (I2C_FUNC_SMBUS_QUICK | \ 557 + I2C_FUNC_SMBUS_BYTE | \ 558 + I2C_FUNC_SMBUS_BYTE_DATA | \ 559 + I2C_FUNC_SMBUS_WORD_DATA | \ 560 + I2C_FUNC_SMBUS_PROC_CALL | \ 561 + I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | \ 562 + I2C_FUNC_SMBUS_I2C_BLOCK | \ 563 + I2C_FUNC_SMBUS_PEC) 571 564 572 565 /* 573 566 * Data for SMBus Messages ··· 573 574 __u8 byte; 574 575 __u16 word; 575 576 __u8 block[I2C_SMBUS_BLOCK_MAX + 2]; /* block[0] is used for length */ 576 - /* and one more for user-space compatibility */ 577 + /* and one more for user-space compatibility */ 577 578 }; 578 579 579 580 /* i2c_smbus_xfer read or write markers */ ··· 601 602 602 603 /* Default fill of many variables */ 603 604 #define I2C_CLIENT_DEFAULTS {I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 604 - I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 605 - I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 606 - I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 607 - I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 608 - I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 609 - I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 610 - I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 611 - I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 612 - I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 613 - I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 614 - I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 615 - I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 616 - I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 617 - I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 618 - I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END} 605 + I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 606 + I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 607 + I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 608 + I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 609 + I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 610 + I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 611 + I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 612 + I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 613 + I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 614 + I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 615 + I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 616 + I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 617 + I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 618 + I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 619 + I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END} 619 620 620 621 /* I2C_CLIENT_MODULE_PARM creates a module parameter, and puts it in the 621 622 module header */ ··· 624 625 static unsigned short var[I2C_CLIENT_MAX_OPTS] = I2C_CLIENT_DEFAULTS; \ 625 626 static unsigned int var##_num; \ 626 627 module_param_array(var, short, &var##_num, 0); \ 627 - MODULE_PARM_DESC(var,desc) 628 + MODULE_PARM_DESC(var, desc) 628 629 629 630 #define I2C_CLIENT_MODULE_PARM_FORCE(name) \ 630 631 I2C_CLIENT_MODULE_PARM(force_##name, \