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

i2c: Drop probe, ignore and force module parameters

The legacy probe and force module parameters are obsolete now, the
same can be achieved using the new_device sysfs interface, which is
both more flexible and cheaper (it is implemented by i2c-core rather
than replicated in every driver module.)

The legacy ignore module parameters can be dropped as well. Ignoring
can be done by instantiating a "dummy" device at the problematic
address.

This is the first step of a huge cleanup to i2c-core's i2c_detect
function, i2c.h's I2C_CLIENT_INSMOD* macros, and all drivers that made
use of them.

Signed-off-by: Jean Delvare <khali@linux-fr.org>

+46 -154
+44
Documentation/i2c/old-module-parameters
··· 1 + I2C device driver binding control from user-space 2 + ================================================= 3 + 4 + Up to kernel 2.6.32, many i2c drivers used helper macros provided by 5 + <linux/i2c.h> which created standard module parameters to let the user 6 + control how the driver would probe i2c buses and attach to devices. These 7 + parameters were known as "probe" (to let the driver probe for an extra 8 + address), "force" (to forcibly attach the driver to a given device) and 9 + "ignore" (to prevent a driver from probing a given address). 10 + 11 + With the conversion of the i2c subsystem to the standard device driver 12 + binding model, it became clear that these per-module parameters were no 13 + longer needed, and that a centralized implementation was possible. The new, 14 + sysfs-based interface is described in the documentation file 15 + "instantiating-devices", section "Method 4: Instantiate from user-space". 16 + 17 + Below is a mapping from the old module parameters to the new interface. 18 + 19 + Attaching a driver to an I2C device 20 + ----------------------------------- 21 + 22 + Old method (module parameters): 23 + # modprobe <driver> probe=1,0x2d 24 + # modprobe <driver> force=1,0x2d 25 + # modprobe <driver> force_<device>=1,0x2d 26 + 27 + New method (sysfs interface): 28 + # echo <device> 0x2d > /sys/bus/i2c/devices/i2c-1/new_device 29 + 30 + Preventing a driver from attaching to an I2C device 31 + --------------------------------------------------- 32 + 33 + Old method (module parameters): 34 + # modprobe <driver> ignore=1,0x2f 35 + 36 + New method (sysfs interface): 37 + # echo dummy 0x2f > /sys/bus/i2c/devices/i2c-1/new_device 38 + # modprobe <driver> 39 + 40 + Of course, it is important to instantiate the "dummy" device before loading 41 + the driver. The dummy device will be handled by i2c-core itself, preventing 42 + other drivers from binding to it later on. If there is a real device at the 43 + problematic address, and you want another driver to bind to it, then simply 44 + pass the name of the device in question instead of "dummy".
+1 -64
drivers/i2c/i2c-core.c
··· 1259 1259 return -ENOMEM; 1260 1260 temp_client->adapter = adapter; 1261 1261 1262 - /* Force entries are done first, and are not affected by ignore 1263 - entries */ 1264 - if (address_data->forces) { 1265 - const unsigned short * const *forces = address_data->forces; 1266 - int kind; 1267 - 1268 - for (kind = 0; forces[kind]; kind++) { 1269 - for (i = 0; forces[kind][i] != I2C_CLIENT_END; 1270 - i += 2) { 1271 - if (forces[kind][i] == adap_id 1272 - || forces[kind][i] == ANY_I2C_BUS) { 1273 - dev_dbg(&adapter->dev, "found force " 1274 - "parameter for adapter %d, " 1275 - "addr 0x%02x, kind %d\n", 1276 - adap_id, forces[kind][i + 1], 1277 - kind); 1278 - temp_client->addr = forces[kind][i + 1]; 1279 - err = i2c_detect_address(temp_client, 1280 - kind, driver); 1281 - if (err) 1282 - goto exit_free; 1283 - } 1284 - } 1285 - } 1286 - } 1287 - 1288 1262 /* Stop here if the classes do not match */ 1289 1263 if (!(adapter->class & driver->class)) 1290 1264 goto exit_free; 1291 1265 1292 1266 /* Stop here if we can't use SMBUS_QUICK */ 1293 1267 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_QUICK)) { 1294 - if (address_data->probe[0] == I2C_CLIENT_END 1295 - && address_data->normal_i2c[0] == I2C_CLIENT_END) 1268 + if (address_data->normal_i2c[0] == I2C_CLIENT_END) 1296 1269 goto exit_free; 1297 1270 1298 1271 dev_warn(&adapter->dev, "SMBus Quick command not supported, " ··· 1274 1301 goto exit_free; 1275 1302 } 1276 1303 1277 - /* Probe entries are done second, and are not affected by ignore 1278 - entries either */ 1279 - for (i = 0; address_data->probe[i] != I2C_CLIENT_END; i += 2) { 1280 - if (address_data->probe[i] == adap_id 1281 - || address_data->probe[i] == ANY_I2C_BUS) { 1282 - dev_dbg(&adapter->dev, "found probe parameter for " 1283 - "adapter %d, addr 0x%02x\n", adap_id, 1284 - address_data->probe[i + 1]); 1285 - temp_client->addr = address_data->probe[i + 1]; 1286 - err = i2c_detect_address(temp_client, -1, driver); 1287 - if (err) 1288 - goto exit_free; 1289 - } 1290 - } 1291 - 1292 - /* Normal entries are done last, unless shadowed by an ignore entry */ 1293 1304 for (i = 0; address_data->normal_i2c[i] != I2C_CLIENT_END; i += 1) { 1294 - int j, ignore; 1295 - 1296 - ignore = 0; 1297 - for (j = 0; address_data->ignore[j] != I2C_CLIENT_END; 1298 - j += 2) { 1299 - if ((address_data->ignore[j] == adap_id || 1300 - address_data->ignore[j] == ANY_I2C_BUS) 1301 - && address_data->ignore[j + 1] 1302 - == address_data->normal_i2c[i]) { 1303 - dev_dbg(&adapter->dev, "found ignore " 1304 - "parameter for adapter %d, " 1305 - "addr 0x%02x\n", adap_id, 1306 - address_data->ignore[j + 1]); 1307 - ignore = 1; 1308 - break; 1309 - } 1310 - } 1311 - if (ignore) 1312 - continue; 1313 - 1314 1305 dev_dbg(&adapter->dev, "found normal entry for adapter %d, " 1315 1306 "addr 0x%02x\n", adap_id, 1316 1307 address_data->normal_i2c[i]);
+1 -90
include/linux/i2c.h
··· 110 110 * @driver: Device driver model driver 111 111 * @id_table: List of I2C devices supported by this driver 112 112 * @detect: Callback for device detection 113 - * @address_data: The I2C addresses to probe, ignore or force (for detect) 113 + * @address_data: The I2C addresses to probe (for detect) 114 114 * @clients: List of detected clients we created (for i2c-core use only) 115 115 * 116 116 * The driver.owner field should be set to the module owner of this driver. ··· 397 397 */ 398 398 struct i2c_client_address_data { 399 399 const unsigned short *normal_i2c; 400 - const unsigned short *probe; 401 - const unsigned short *ignore; 402 - const unsigned short * const *forces; 403 400 }; 404 401 405 402 /* Internal numbers to terminate lists */ ··· 610 613 module_param_array(var, short, &var##_num, 0); \ 611 614 MODULE_PARM_DESC(var, desc) 612 615 613 - #define I2C_CLIENT_MODULE_PARM_FORCE(name) \ 614 - I2C_CLIENT_MODULE_PARM(force_##name, \ 615 - "List of adapter,address pairs which are " \ 616 - "unquestionably assumed to contain a `" \ 617 - # name "' chip") 618 - 619 - 620 616 #define I2C_CLIENT_INSMOD_COMMON \ 621 - I2C_CLIENT_MODULE_PARM(probe, "List of adapter,address pairs to scan " \ 622 - "additionally"); \ 623 - I2C_CLIENT_MODULE_PARM(ignore, "List of adapter,address pairs not to " \ 624 - "scan"); \ 625 617 static const struct i2c_client_address_data addr_data = { \ 626 618 .normal_i2c = normal_i2c, \ 627 - .probe = probe, \ 628 - .ignore = ignore, \ 629 - .forces = forces, \ 630 619 } 631 - 632 - #define I2C_CLIENT_FORCE_TEXT \ 633 - "List of adapter,address pairs to boldly assume to be present" 634 620 635 621 /* These are the ones you want to use in your own drivers. Pick the one 636 622 which matches the number of devices the driver differenciates between. */ 637 623 #define I2C_CLIENT_INSMOD \ 638 - I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \ 639 - static const unsigned short * const forces[] = { force, NULL }; \ 640 624 I2C_CLIENT_INSMOD_COMMON 641 625 642 626 #define I2C_CLIENT_INSMOD_1(chip1) \ 643 627 enum chips { any_chip, chip1 }; \ 644 - I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \ 645 - I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ 646 - static const unsigned short * const forces[] = { force, \ 647 - force_##chip1, NULL }; \ 648 628 I2C_CLIENT_INSMOD_COMMON 649 629 650 630 #define I2C_CLIENT_INSMOD_2(chip1, chip2) \ 651 631 enum chips { any_chip, chip1, chip2 }; \ 652 - I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \ 653 - I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ 654 - I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ 655 - static const unsigned short * const forces[] = { force, \ 656 - force_##chip1, force_##chip2, NULL }; \ 657 632 I2C_CLIENT_INSMOD_COMMON 658 633 659 634 #define I2C_CLIENT_INSMOD_3(chip1, chip2, chip3) \ 660 635 enum chips { any_chip, chip1, chip2, chip3 }; \ 661 - I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \ 662 - I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ 663 - I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ 664 - I2C_CLIENT_MODULE_PARM_FORCE(chip3); \ 665 - static const unsigned short * const forces[] = { force, \ 666 - force_##chip1, force_##chip2, force_##chip3, NULL }; \ 667 636 I2C_CLIENT_INSMOD_COMMON 668 637 669 638 #define I2C_CLIENT_INSMOD_4(chip1, chip2, chip3, chip4) \ 670 639 enum chips { any_chip, chip1, chip2, chip3, chip4 }; \ 671 - I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \ 672 - I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ 673 - I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ 674 - I2C_CLIENT_MODULE_PARM_FORCE(chip3); \ 675 - I2C_CLIENT_MODULE_PARM_FORCE(chip4); \ 676 - static const unsigned short * const forces[] = { force, \ 677 - force_##chip1, force_##chip2, force_##chip3, \ 678 - force_##chip4, NULL}; \ 679 640 I2C_CLIENT_INSMOD_COMMON 680 641 681 642 #define I2C_CLIENT_INSMOD_5(chip1, chip2, chip3, chip4, chip5) \ 682 643 enum chips { any_chip, chip1, chip2, chip3, chip4, chip5 }; \ 683 - I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \ 684 - I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ 685 - I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ 686 - I2C_CLIENT_MODULE_PARM_FORCE(chip3); \ 687 - I2C_CLIENT_MODULE_PARM_FORCE(chip4); \ 688 - I2C_CLIENT_MODULE_PARM_FORCE(chip5); \ 689 - static const unsigned short * const forces[] = { force, \ 690 - force_##chip1, force_##chip2, force_##chip3, \ 691 - force_##chip4, force_##chip5, NULL }; \ 692 644 I2C_CLIENT_INSMOD_COMMON 693 645 694 646 #define I2C_CLIENT_INSMOD_6(chip1, chip2, chip3, chip4, chip5, chip6) \ 695 647 enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6 }; \ 696 - I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \ 697 - I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ 698 - I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ 699 - I2C_CLIENT_MODULE_PARM_FORCE(chip3); \ 700 - I2C_CLIENT_MODULE_PARM_FORCE(chip4); \ 701 - I2C_CLIENT_MODULE_PARM_FORCE(chip5); \ 702 - I2C_CLIENT_MODULE_PARM_FORCE(chip6); \ 703 - static const unsigned short * const forces[] = { force, \ 704 - force_##chip1, force_##chip2, force_##chip3, \ 705 - force_##chip4, force_##chip5, force_##chip6, NULL }; \ 706 648 I2C_CLIENT_INSMOD_COMMON 707 649 708 650 #define I2C_CLIENT_INSMOD_7(chip1, chip2, chip3, chip4, chip5, chip6, chip7) \ 709 651 enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, \ 710 652 chip7 }; \ 711 - I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \ 712 - I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ 713 - I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ 714 - I2C_CLIENT_MODULE_PARM_FORCE(chip3); \ 715 - I2C_CLIENT_MODULE_PARM_FORCE(chip4); \ 716 - I2C_CLIENT_MODULE_PARM_FORCE(chip5); \ 717 - I2C_CLIENT_MODULE_PARM_FORCE(chip6); \ 718 - I2C_CLIENT_MODULE_PARM_FORCE(chip7); \ 719 - static const unsigned short * const forces[] = { force, \ 720 - force_##chip1, force_##chip2, force_##chip3, \ 721 - force_##chip4, force_##chip5, force_##chip6, \ 722 - force_##chip7, NULL }; \ 723 653 I2C_CLIENT_INSMOD_COMMON 724 654 725 655 #define I2C_CLIENT_INSMOD_8(chip1, chip2, chip3, chip4, chip5, chip6, chip7, chip8) \ 726 656 enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, \ 727 657 chip7, chip8 }; \ 728 - I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \ 729 - I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ 730 - I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ 731 - I2C_CLIENT_MODULE_PARM_FORCE(chip3); \ 732 - I2C_CLIENT_MODULE_PARM_FORCE(chip4); \ 733 - I2C_CLIENT_MODULE_PARM_FORCE(chip5); \ 734 - I2C_CLIENT_MODULE_PARM_FORCE(chip6); \ 735 - I2C_CLIENT_MODULE_PARM_FORCE(chip7); \ 736 - I2C_CLIENT_MODULE_PARM_FORCE(chip8); \ 737 - static const unsigned short * const forces[] = { force, \ 738 - force_##chip1, force_##chip2, force_##chip3, \ 739 - force_##chip4, force_##chip5, force_##chip6, \ 740 - force_##chip7, force_##chip8, NULL }; \ 741 658 I2C_CLIENT_INSMOD_COMMON 742 659 #endif /* __KERNEL__ */ 743 660 #endif /* _LINUX_I2C_H */