Changeset 3388
- Timestamp:
- 09/27/99 13:33:18 (9 years ago)
- Files:
-
- i2c/trunk/doc/writing-clients (modified) (1 diff)
- i2c/trunk/kernel/i2c-algo-bit.c (modified) (2 diffs)
- i2c/trunk/kernel/i2c-algo-pcf.c (modified) (2 diffs)
- i2c/trunk/kernel/i2c-core.c (modified) (2 diffs)
- i2c/trunk/kernel/i2c.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
i2c/trunk/doc/writing-clients
r3384 r3388 379 379 const char *client_name = ""; /* For non-`sensors' drivers, put the real 380 380 name here! */ 381 382 /* Let's see whether this adapter can support what we need. 383 Please substitute the things you need here! */ 384 if (! i2c_check_functionality(adapter,I2C_FUNC_SMBUS_READ_WORD | 385 I2C_FUNC_SMBUS_WRITE_WORD)) 386 goto ERROR0; 381 387 382 388 /* SENSORS ONLY START */ i2c/trunk/kernel/i2c-algo-bit.c
r3372 r3388 519 519 } 520 520 521 static u32 bit_func(struct i2c_adapter *adap) 522 { 523 return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR; 524 } 525 521 526 522 527 /* -----exported algorithm data: ------------------------------------- */ … … 530 535 NULL, /* slave_recv */ 531 536 algo_control, /* ioctl */ 537 bit_func, /* functionality */ 532 538 }; 533 539 i2c/trunk/kernel/i2c-algo-pcf.c
r3372 r3388 493 493 } 494 494 495 static u32 pcf_func(struct i2c_adapter *adap) 496 { 497 return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR; 498 } 495 499 496 500 /* -----exported algorithm data: ------------------------------------- */ … … 504 508 NULL, /* slave_recv */ 505 509 algo_control, /* ioctl */ 510 pcf_func, /* functionality */ 506 511 }; 507 512 i2c/trunk/kernel/i2c-core.c
r3384 r3388 1187 1187 1188 1188 1189 /* You should always define `functionality'; the 'else' is just for 1190 backward compatibility. */ 1191 u32 i2c_get_functionality (struct i2c_adapter *adap) 1192 { 1193 if (adap->algo->functionality) 1194 return adap->algo->functionality(adap); 1195 else 1196 return 0xffffffff; 1197 } 1198 1199 int i2c_check_functionality (struct i2c_adapter *adap, u32 func) 1200 { 1201 u32 adap_func = i2c_get_functionality (adap); 1202 return (func & adap_func) == func; 1203 } 1204 1205 1189 1206 static int __init i2c_init(void) 1190 1207 { … … 1301 1318 EXPORT_SYMBOL(i2c_smbus_write_block_data); 1302 1319 1320 EXPORT_SYMBOL(i2c_get_functionality); 1321 EXPORT_SYMBOL(i2c_check_functionality); 1322 1303 1323 #ifdef MODULE 1304 1324 MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>"); i2c/trunk/kernel/i2c.h
r3384 r3388 233 233 int (*algo_control)(struct i2c_adapter *, unsigned int, unsigned long); 234 234 235 /* To determine what the adapter supports */ 236 u32 (*functionality) (struct i2c_adapter *); 235 237 }; 236 238 … … 349 351 */ 350 352 extern int i2c_adapter_id(struct i2c_adapter *adap); 353 354 355 /* To determine what functionality is present */ 356 357 #define I2C_FUNC_I2C 0x00000001 358 #define I2C_FUNC_10BIT_ADDR 0x00000002 359 #define I2C_FUNC_SMBUS_QUICK 0x00010000 360 #define I2C_FUNC_SMBUS_READ_BYTE 0x00020000 361 #define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000 362 #define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000 363 #define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000 364 #define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000 365 #define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000 366 #define I2C_FUNC_SMBUS_PROC_CALL 0x00800000 367 #define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000 368 #define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000 369 #define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 /* New I2C-like block */ 370 #define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* transfers */ 371 #define I2C_FUNC_SMBUS_EMUL I2C_FUNC_SMBUS_QUICK | \ 372 I2C_FUNC_SMBUS_READ_BYTE | \ 373 I2C_FUNC_SMBUS_WRITE_BYTE | \ 374 I2C_FUNC_SMBUS_READ_BYTE_DATA | \ 375 I2C_FUNC_SMBUS_WRITE_BYTE_DATA | \ 376 I2C_FUNC_SMBUS_READ_WORD_DATA | \ 377 I2C_FUNC_SMBUS_WRITE_WORD_DATA | \ 378 I2C_FUNC_SMBUS_PROC_CALL | \ 379 I2C_FUNC_SMBUS_READ_BLOCK_DATA 380 381 382 /* Return the functionality mask */ 383 extern u32 i2c_get_functionality (struct i2c_adapter *adap); 384 385 /* Return 1 if adapter supports everything we need, 0 if not. */ 386 extern int i2c_check_functionality (struct i2c_adapter *adap, u32 func); 387 388 /* The mask of functionality any plain i2c adapter has due to SMBus 389 emulation */ 390 extern u32 i2c_smbus_emul_func; 351 391 352 392 #endif /* __KERNEL__ */
