docs: printk-formats: add ptrdiff_t type to printk-formats
authorMiles Chen <miles.chen@mediatek.com>
Tue, 1 Oct 2019 10:04:49 +0000 (18:04 +0800)
committerJonathan Corbet <corbet@lwn.net>
Thu, 7 Nov 2019 20:17:26 +0000 (13:17 -0700)
When print the difference between two pointers, we should use
the ptrdiff_t modifier %t.

Signed-off-by: Miles Chen <miles.chen@mediatek.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Documentation/core-api/printk-formats.rst

index ecbebf4ca8e7e74641ce6d0bf247a0e9aaade724..8a0f49cd158b95b64af85dc186b88c2ac5d84bc4 100644 (file)
@@ -135,6 +135,20 @@ equivalent to %lx (or %lu). %px is preferred because it is more uniquely
 grep'able. If in the future we need to modify the way the kernel handles
 printing pointers we will be better equipped to find the call sites.
 
+Pointer Differences
+-------------------
+
+::
+
+       %td     2560
+       %tx     a00
+
+For printing the pointer differences, use the %t modifier for ptrdiff_t.
+
+Example::
+
+       printk("test: difference between pointers: %td\n", ptr2 - ptr1);
+
 Struct Resources
 ----------------