submitting-patches 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. How to Get Your Patch Accepted Into the Hwmon Subsystem
  2. -------------------------------------------------------
  3. This text is a collection of suggestions for people writing patches or
  4. drivers for the hwmon subsystem. Following these suggestions will greatly
  5. increase the chances of your change being accepted.
  6. 1. General
  7. ----------
  8. * It should be unnecessary to mention, but please read and follow
  9. Documentation/SubmitChecklist
  10. Documentation/SubmittingDrivers
  11. Documentation/SubmittingPatches
  12. Documentation/CodingStyle
  13. * If your patch generates checkpatch warnings, please refrain from explanations
  14. such as "I don't like that coding style". Keep in mind that each unnecessary
  15. warning helps hiding a real problem. If you don't like the kernel coding
  16. style, don't write kernel drivers.
  17. * Please test your patch thoroughly. We are not your test group.
  18. Sometimes a patch can not or not completely be tested because of missing
  19. hardware. In such cases, you should test-build the code on at least one
  20. architecture. If run-time testing was not achieved, it should be written
  21. explicitly below the patch header.
  22. * If your patch (or the driver) is affected by configuration options such as
  23. CONFIG_SMP, make sure it compiles for all configuration variants.
  24. 2. Adding functionality to existing drivers
  25. -------------------------------------------
  26. * Make sure the documentation in Documentation/hwmon/<driver_name> is up to
  27. date.
  28. * Make sure the information in Kconfig is up to date.
  29. * If the added functionality requires some cleanup or structural changes, split
  30. your patch into a cleanup part and the actual addition. This makes it easier
  31. to review your changes, and to bisect any resulting problems.
  32. * Never mix bug fixes, cleanup, and functional enhancements in a single patch.
  33. 3. New drivers
  34. --------------
  35. * Running your patch or driver file(s) through checkpatch does not mean its
  36. formatting is clean. If unsure about formatting in your new driver, run it
  37. through Lindent. Lindent is not perfect, and you may have to do some minor
  38. cleanup, but it is a good start.
  39. * Consider adding yourself to MAINTAINERS.
  40. * Document the driver in Documentation/hwmon/<driver_name>.
  41. * Add the driver to Kconfig and Makefile in alphabetical order.
  42. * Make sure that all dependencies are listed in Kconfig.
  43. * Avoid forward declarations if you can. Rearrange the code if necessary.
  44. * Avoid calculations in macros and macro-generated functions. While such macros
  45. may save a line or so in the source, it obfuscates the code and makes code
  46. review more difficult. It may also result in code which is more complicated
  47. than necessary. Use inline functions or just regular functions instead.
  48. * Use devres functions whenever possible to allocate resources. For rationale
  49. and supported functions, please see Documentation/driver-model/devres.txt.
  50. * If the driver has a detect function, make sure it is silent. Debug messages
  51. and messages printed after a successful detection are acceptable, but it
  52. must not print messages such as "Chip XXX not found/supported".
  53. Keep in mind that the detect function will run for all drivers supporting an
  54. address if a chip is detected on that address. Unnecessary messages will just
  55. pollute the kernel log and not provide any value.
  56. * Provide a detect function if and only if a chip can be detected reliably.
  57. * Only the following I2C addresses shall be probed: 0x18-0x1f, 0x28-0x2f,
  58. 0x48-0x4f, 0x58, 0x5c, 0x73 and 0x77. Probing other addresses is strongly
  59. discouraged as it is known to cause trouble with other (non-hwmon) I2C
  60. chips. If your chip lives at an address which can't be probed then the
  61. device will have to be instantiated explicitly (which is always better
  62. anyway.)
  63. * Avoid writing to chip registers in the detect function. If you have to write,
  64. only do it after you have already gathered enough data to be certain that the
  65. detection is going to be successful.
  66. Keep in mind that the chip might not be what your driver believes it is, and
  67. writing to it might cause a bad misconfiguration.
  68. * Make sure there are no race conditions in the probe function. Specifically,
  69. completely initialize your chip first, then create sysfs entries and register
  70. with the hwmon subsystem.
  71. * Do not provide support for deprecated sysfs attributes.
  72. * Do not create non-standard attributes unless really needed. If you have to use
  73. non-standard attributes, or you believe you do, discuss it on the mailing list
  74. first. Either case, provide a detailed explanation why you need the
  75. non-standard attribute(s).
  76. Standard attributes are specified in Documentation/hwmon/sysfs-interface.
  77. * When deciding which sysfs attributes to support, look at the chip's
  78. capabilities. While we do not expect your driver to support everything the
  79. chip may offer, it should at least support all limits and alarms.
  80. * Last but not least, please check if a driver for your chip already exists
  81. before starting to write a new driver. Especially for temperature sensors,
  82. new chips are often variants of previously released chips. In some cases,
  83. a presumably new chip may simply have been relabeled.