old-module-parameters.rst 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. ================================================================
  2. I2C device driver binding control from user-space in old kernels
  3. ================================================================
  4. .. NOTE::
  5. Note: this section is only relevant if you are handling some old code
  6. found in kernel 2.6. If you work with more recent kernels, you can
  7. safely skip this section.
  8. Up to kernel 2.6.32, many I2C drivers used helper macros provided by
  9. <linux/i2c.h> which created standard module parameters to let the user
  10. control how the driver would probe I2C buses and attach to devices. These
  11. parameters were known as ``probe`` (to let the driver probe for an extra
  12. address), ``force`` (to forcibly attach the driver to a given device) and
  13. ``ignore`` (to prevent a driver from probing a given address).
  14. With the conversion of the I2C subsystem to the standard device driver
  15. binding model, it became clear that these per-module parameters were no
  16. longer needed, and that a centralized implementation was possible. The new,
  17. sysfs-based interface is described in
  18. Documentation/i2c/instantiating-devices.rst, section
  19. "Method 4: Instantiate from user-space".
  20. Below is a mapping from the old module parameters to the new interface.
  21. Attaching a driver to an I2C device
  22. -----------------------------------
  23. Old method (module parameters)::
  24. # modprobe <driver> probe=1,0x2d
  25. # modprobe <driver> force=1,0x2d
  26. # modprobe <driver> force_<device>=1,0x2d
  27. New method (sysfs interface)::
  28. # echo <device> 0x2d > /sys/bus/i2c/devices/i2c-1/new_device
  29. Preventing a driver from attaching to an I2C device
  30. ---------------------------------------------------
  31. Old method (module parameters)::
  32. # modprobe <driver> ignore=1,0x2f
  33. New method (sysfs interface)::
  34. # echo dummy 0x2f > /sys/bus/i2c/devices/i2c-1/new_device
  35. # modprobe <driver>
  36. Of course, it is important to instantiate the ``dummy`` device before loading
  37. the driver. The dummy device will be handled by i2c-core itself, preventing
  38. other drivers from binding to it later on. If there is a real device at the
  39. problematic address, and you want another driver to bind to it, then simply
  40. pass the name of the device in question instead of ``dummy``.