* [lm-sensors] [PATCH v3] hwmon: Add submitting-patches checklist to
@ 2011-04-06 17:17 Guenter Roeck
2011-04-07 8:12 ` [lm-sensors] [PATCH v3] hwmon: Add submitting-patches checklist Jean Delvare
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Guenter Roeck @ 2011-04-06 17:17 UTC (permalink / raw)
To: lm-sensors
When writing hardware monitoring drivers, there are some common pitfalls which
keep coming up in code reviews. This patch provides a document describing all
those pitfalls and how to avoid them.
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
---
v3: Added header describing what the document is about.
Added details on testing requirements.
Added a bullet item describing when and when not to provide a detect function.
Added a bullet item describing wich attributes should be supported.
Added a bullet item asking driver authors to check if a driver already
exists.
v2: Renamed and reorganized document. Added more items and clarifications
from review feedback.
Documentation/hwmon/submitting-patches | 110 ++++++++++++++++++++++++++++++++
1 files changed, 110 insertions(+), 0 deletions(-)
create mode 100644 Documentation/hwmon/submitting-patches
diff --git a/Documentation/hwmon/submitting-patches b/Documentation/hwmon/submitting-patches
new file mode 100644
index 0000000..3c0073f
--- /dev/null
+++ b/Documentation/hwmon/submitting-patches
@@ -0,0 +1,110 @@
+ How to Get Your Patch Accepted Into the Hwmon Subsystem
+ -------------------------------------------------------
+
+This text is is a collection of suggestions for people writing patches or
+drivers for the hwmon subsystem. Following these suggestions will greatly
+increase the chances of your change being accepted.
+
+
+1. General
+----------
+
+* It should be unnecessary to mention, but please read and follow
+ Documentation/SubmitChecklist
+ Documentation/SubmittingDrivers
+ Documentation/SubmittingPatches
+ Documentation/CodingStyle
+
+* If your patch generates checkpatch warnings, please refrain from explanations
+ such as "I don't like that coding style". Keep in mind that each unnecessary
+ warning helps hiding a real problem. If you don't like the kernel coding
+ style, don't write kernel drivers.
+
+* Please test your patch thoroughly. We are not your test group.
+ Sometimes a patch can not or not completely be tested because of missing
+ hardware. In such cases, you should test-build the code on at least one
+ architecture. If run-time testing was not achieved, it should be written
+ explicitly below the patch header.
+
+* If your patch (or the driver) is affected by configuration options such as
+ CONFIG_SMP or CONFIG_HOTPLUG, make sure it compiles for all configuration
+ variants.
+
+
+2. Adding functionality to existing drivers
+-------------------------------------------
+
+* Make sure the documentation in Documentation/hwmon/<driver_name> is up to
+ date.
+
+* Make sure the information in Kconfig is up to date.
+
+* If the added functionality requires some cleanup or structural changes, split
+ your patch into a cleanup part and the actual addition. This makes it easier
+ to review your changes, and to bisect any resulting problems.
+
+* Never mix bug fixes, cleanup, and functional enhancements in a single patch.
+
+
+3. New drivers
+--------------
+
+* Running your patch or driver file(s) through checkpatch does not mean its
+ formatting is clean. If unsure about formatting in your new driver, run it
+ through Lindent. Lindent is not perfect, and you may have to do some minor
+ cleanup, but it is a good start.
+
+* Consider adding yourself to MAINTAINERS.
+
+* Document the driver in Documentation/hwmon/<driver_name>.
+
+* Add the driver to Kconfig and Makefile in alphabetical order.
+
+* Make sure that all dependencies are listed in Kconfig. For new drivers, it
+ is most likely prudent to add a dependency on EXPERIMENTAL.
+
+* Avoid forward declarations if you can. Rearrange the code if necessary.
+
+* Avoid calculations in macros and macro-generated functions. While such macros
+ may save a line or so in the source, it obfuscates the code and makes code
+ review more difficult. It may also result in code which is more complicated
+ than necessary. Use inline functions or just regular functions instead.
+
+* If the driver has a detect function, make sure it is silent. Debug messages
+ and messages printed after a successful detection are acceptable, but it
+ must not print messages such as "Chip XXX not found/supported".
+
+ Keep in mind that the detect function will run for all drivers supporting an
+ address if a chip is detected on that address. Unnecessary messages will just
+ pollute the kernel log and not provide any value.
+
+* Provide a detect function only if a chip can be detected reliably. On the
+ other side, if the chip can be detected reliably, provide a detect function.
+
+* Avoid writing to chip registers in the detect function. If you have to write,
+ only do it after you have already gathered enough data to be certain that the
+ detection is going to be successful.
+
+ Keep in mind that the chip might not be what your driver believes it is, and
+ writing to it might cause a bad misconfiguration.
+
+* Make sure there are no race conditions in the probe function. Specifically,
+ completely initialize your chip first, then create sysfs entries and register
+ with the hwmon subsystem.
+
+* Do not provide support for deprecated sysfs attributes.
+
+* Do not create non-standard attributes unless really needed. If you have to use
+ non-standard attributes, or you believe you do, discuss it on the mailing list
+ first. Either case, provide a detailed explanation why you need the
+ non-standard attribute(s).
+ Standard attributes are specified in Documentation/hwmon/sysfs-interface.
+
+* When deciding which sysfs attributes to support, look at the chip's
+ capabilities. While we do not expect your driver to support everything the
+ chip may offer, it should at least support all limits and alarms.
+
+* Last but not least, please check if a driver for your chip already exists
+ before starting to write a new driver. Especially for temperature sensors,
+ new chips are often variants of previously released chips. In some cases,
+ a presumably new chip may simply have been relabeled.
--
1.7.3.1
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [lm-sensors] [PATCH v3] hwmon: Add submitting-patches checklist
2011-04-06 17:17 [lm-sensors] [PATCH v3] hwmon: Add submitting-patches checklist to Guenter Roeck
@ 2011-04-07 8:12 ` Jean Delvare
2011-04-07 14:05 ` Guenter Roeck
2011-04-07 16:04 ` Guenter Roeck
2 siblings, 0 replies; 4+ messages in thread
From: Jean Delvare @ 2011-04-07 8:12 UTC (permalink / raw)
To: lm-sensors
On Wed, 6 Apr 2011 10:17:53 -0700, Guenter Roeck wrote:
> When writing hardware monitoring drivers, there are some common pitfalls which
> keep coming up in code reviews. This patch provides a document describing all
> those pitfalls and how to avoid them.
>
> Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Acked-by: Jean Delvare <khali@linux-fr.org>
Minor suggestion below - but no need to resend.
> +* Provide a detect function only if a chip can be detected reliably. On the
> + other side, if the chip can be detected reliably, provide a detect function.
Could be expressed in a more compact way as:
* Provide a detect function if and only if a chip can be detected reliably.
(But maybe this is the mathematician in me speaking!)
--
Jean Delvare
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [lm-sensors] [PATCH v3] hwmon: Add submitting-patches checklist
2011-04-06 17:17 [lm-sensors] [PATCH v3] hwmon: Add submitting-patches checklist to Guenter Roeck
2011-04-07 8:12 ` [lm-sensors] [PATCH v3] hwmon: Add submitting-patches checklist Jean Delvare
@ 2011-04-07 14:05 ` Guenter Roeck
2011-04-07 16:04 ` Guenter Roeck
2 siblings, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2011-04-07 14:05 UTC (permalink / raw)
To: lm-sensors
On Thu, Apr 07, 2011 at 04:12:23AM -0400, Jean Delvare wrote:
> On Wed, 6 Apr 2011 10:17:53 -0700, Guenter Roeck wrote:
> > When writing hardware monitoring drivers, there are some common pitfalls which
> > keep coming up in code reviews. This patch provides a document describing all
> > those pitfalls and how to avoid them.
> >
> > Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
>
> Acked-by: Jean Delvare <khali@linux-fr.org>
>
> Minor suggestion below - but no need to resend.
>
> > +* Provide a detect function only if a chip can be detected reliably. On the
> > + other side, if the chip can be detected reliably, provide a detect function.
>
> Could be expressed in a more compact way as:
>
> * Provide a detect function if and only if a chip can be detected reliably.
>
Mathematically correct, but would people understand it ?
> (But maybe this is the mathematician in me speaking!)
>
Mathematician myself, I prefer your wording as well. I'll go with it.
Thanks,
Guenter
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [lm-sensors] [PATCH v3] hwmon: Add submitting-patches checklist
2011-04-06 17:17 [lm-sensors] [PATCH v3] hwmon: Add submitting-patches checklist to Guenter Roeck
2011-04-07 8:12 ` [lm-sensors] [PATCH v3] hwmon: Add submitting-patches checklist Jean Delvare
2011-04-07 14:05 ` Guenter Roeck
@ 2011-04-07 16:04 ` Guenter Roeck
2 siblings, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2011-04-07 16:04 UTC (permalink / raw)
To: lm-sensors
On Thu, Apr 07, 2011 at 04:12:23AM -0400, Jean Delvare wrote:
> On Wed, 6 Apr 2011 10:17:53 -0700, Guenter Roeck wrote:
> > When writing hardware monitoring drivers, there are some common pitfalls which
> > keep coming up in code reviews. This patch provides a document describing all
> > those pitfalls and how to avoid them.
> >
> > Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
>
> Acked-by: Jean Delvare <khali@linux-fr.org>
>
Applied, thanks.
Guenter
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-04-07 16:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-06 17:17 [lm-sensors] [PATCH v3] hwmon: Add submitting-patches checklist to Guenter Roeck
2011-04-07 8:12 ` [lm-sensors] [PATCH v3] hwmon: Add submitting-patches checklist Jean Delvare
2011-04-07 14:05 ` Guenter Roeck
2011-04-07 16:04 ` Guenter Roeck
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.