You've already forked linux-t2-patches
mirror of
https://github.com/t2linux/linux-t2-patches.git
synced 2026-04-30 13:52:11 -07:00
Update vsprintf
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
From 82cefe589ff158b99f33996ad085f0739bff6a4a Mon Sep 17 00:00:00 2001
|
From ffee86d17b463d4e2bcc1070dc1d03dc88870bc4 Mon Sep 17 00:00:00 2001
|
||||||
From: Hector Martin <marcan@marcan.st>
|
From: Hector Martin <marcan@marcan.st>
|
||||||
Date: Tue, 8 Apr 2025 12:17:57 +0530
|
Date: Tue, 8 Apr 2025 12:17:57 +0530
|
||||||
Subject: [PATCH 1/2] lib/vsprintf: Add support for generic FourCCs by
|
Subject: [PATCH 1/2] lib/vsprintf: Add support for generic FourCCs by extending
|
||||||
extending %p4cc
|
%p4cc
|
||||||
|
|
||||||
%p4cc is designed for DRM/V4L2 FourCCs with their specific quirks, but
|
%p4cc is designed for DRM/V4L2 FourCCs with their specific quirks, but
|
||||||
it's useful to be able to print generic 4-character codes formatted as
|
it's useful to be able to print generic 4-character codes formatted as
|
||||||
@@ -29,13 +29,13 @@ Signed-off-by: Hector Martin <marcan@marcan.st>
|
|||||||
Signed-off-by: Aditya Garg <gargaditya08@live.com>
|
Signed-off-by: Aditya Garg <gargaditya08@live.com>
|
||||||
Reviewed-by: Kees Cook <kees@kernel.org>
|
Reviewed-by: Kees Cook <kees@kernel.org>
|
||||||
---
|
---
|
||||||
Documentation/core-api/printk-formats.rst | 32 +++++++++++++++++++++
|
Documentation/core-api/printk-formats.rst | 32 ++++++++++++++++++
|
||||||
lib/vsprintf.c | 35 +++++++++++++++++++----
|
lib/vsprintf.c | 40 +++++++++++++++++++----
|
||||||
scripts/checkpatch.pl | 2 +-
|
scripts/checkpatch.pl | 2 +-
|
||||||
3 files changed, 62 insertions(+), 7 deletions(-)
|
3 files changed, 67 insertions(+), 7 deletions(-)
|
||||||
|
|
||||||
diff --git a/Documentation/core-api/printk-formats.rst b/Documentation/core-api/printk-formats.rst
|
diff --git a/Documentation/core-api/printk-formats.rst b/Documentation/core-api/printk-formats.rst
|
||||||
index 14e093da3..0cecb822d 100644
|
index 14e093da3..99df8d175 100644
|
||||||
--- a/Documentation/core-api/printk-formats.rst
|
--- a/Documentation/core-api/printk-formats.rst
|
||||||
+++ b/Documentation/core-api/printk-formats.rst
|
+++ b/Documentation/core-api/printk-formats.rst
|
||||||
@@ -630,6 +630,38 @@ Examples::
|
@@ -630,6 +630,38 @@ Examples::
|
||||||
@@ -46,7 +46,7 @@ index 14e093da3..0cecb822d 100644
|
|||||||
+-------------------
|
+-------------------
|
||||||
+
|
+
|
||||||
+::
|
+::
|
||||||
+ %p4c[hnlb] gP00 (0x67503030)
|
+ %p4c[h[R]lb] gP00 (0x67503030)
|
||||||
+
|
+
|
||||||
+Print a generic FourCC code, as both ASCII characters and its numerical
|
+Print a generic FourCC code, as both ASCII characters and its numerical
|
||||||
+value as hexadecimal.
|
+value as hexadecimal.
|
||||||
@@ -54,23 +54,23 @@ index 14e093da3..0cecb822d 100644
|
|||||||
+The generic FourCC code is always printed in the big-endian format,
|
+The generic FourCC code is always printed in the big-endian format,
|
||||||
+the most significant byte first. This is the opposite of V4L/DRM FourCCs.
|
+the most significant byte first. This is the opposite of V4L/DRM FourCCs.
|
||||||
+
|
+
|
||||||
+The additional ``h``, ``n``, ``l``, and ``b`` specifiers define what
|
+The additional ``h``, ``hR``, ``l``, and ``b`` specifiers define what
|
||||||
+endianness is used to load the stored bytes. The data might be interpreted
|
+endianness is used to load the stored bytes. The data might be interpreted
|
||||||
+using the host byte order, network byte order, little-endian, or big-endian.
|
+using the host, reversed host byte order, little-endian, or big-endian.
|
||||||
+
|
+
|
||||||
+Passed by reference.
|
+Passed by reference.
|
||||||
+
|
+
|
||||||
+Examples for a little-endian machine, given &(u32)0x67503030::
|
+Examples for a little-endian machine, given &(u32)0x67503030::
|
||||||
+
|
+
|
||||||
+ %p4ch gP00 (0x67503030)
|
+ %p4ch gP00 (0x67503030)
|
||||||
+ %p4cn 00Pg (0x30305067)
|
+ %p4chR 00Pg (0x30305067)
|
||||||
+ %p4cl gP00 (0x67503030)
|
+ %p4cl gP00 (0x67503030)
|
||||||
+ %p4cb 00Pg (0x30305067)
|
+ %p4cb 00Pg (0x30305067)
|
||||||
+
|
+
|
||||||
+Examples for a big-endian machine, given &(u32)0x67503030::
|
+Examples for a big-endian machine, given &(u32)0x67503030::
|
||||||
+
|
+
|
||||||
+ %p4ch gP00 (0x67503030)
|
+ %p4ch gP00 (0x67503030)
|
||||||
+ %p4cn 00Pg (0x30305067)
|
+ %p4chR 00Pg (0x30305067)
|
||||||
+ %p4cl 00Pg (0x30305067)
|
+ %p4cl 00Pg (0x30305067)
|
||||||
+ %p4cb gP00 (0x67503030)
|
+ %p4cb gP00 (0x67503030)
|
||||||
+
|
+
|
||||||
@@ -78,10 +78,10 @@ index 14e093da3..0cecb822d 100644
|
|||||||
----
|
----
|
||||||
|
|
||||||
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
|
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
|
||||||
index a69e71a1c..6853d47a6 100644
|
index c5e2ec930..af0fd89cb 100644
|
||||||
--- a/lib/vsprintf.c
|
--- a/lib/vsprintf.c
|
||||||
+++ b/lib/vsprintf.c
|
+++ b/lib/vsprintf.c
|
||||||
@@ -1760,27 +1760,50 @@ char *fourcc_string(char *buf, char *end, const u32 *fourcc,
|
@@ -1760,27 +1760,49 @@ char *fourcc_string(char *buf, char *end, const u32 *fourcc,
|
||||||
char output[sizeof("0123 little-endian (0x01234567)")];
|
char output[sizeof("0123 little-endian (0x01234567)")];
|
||||||
char *p = output;
|
char *p = output;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
@@ -99,8 +99,7 @@ index a69e71a1c..6853d47a6 100644
|
|||||||
- val = orig & ~BIT(31);
|
- val = orig & ~BIT(31);
|
||||||
+ switch (fmt[2]) {
|
+ switch (fmt[2]) {
|
||||||
+ case 'h':
|
+ case 'h':
|
||||||
+ break;
|
+ if (fmt[3] == 'R')
|
||||||
+ case 'n':
|
|
||||||
+ orig = swab32(orig);
|
+ orig = swab32(orig);
|
||||||
+ break;
|
+ break;
|
||||||
+ case 'l':
|
+ case 'l':
|
||||||
@@ -138,6 +137,19 @@ index a69e71a1c..6853d47a6 100644
|
|||||||
|
|
||||||
*p++ = ' ';
|
*p++ = ' ';
|
||||||
*p++ = '(';
|
*p++ = '(';
|
||||||
|
@@ -2334,6 +2356,12 @@ char *rust_fmt_argument(char *buf, char *end, void *ptr);
|
||||||
|
* read the documentation (path below) first.
|
||||||
|
* - 'NF' For a netdev_features_t
|
||||||
|
* - '4cc' V4L2 or DRM FourCC code, with endianness and raw numerical value.
|
||||||
|
+ * - '4c[h[R]lb]' For generic FourCC code with raw numerical value. Both are
|
||||||
|
+ * displayed in the big-endian format. This is the opposite of V4L2 or
|
||||||
|
+ * DRM FourCCs.
|
||||||
|
+ * The additional specifiers define what endianness is used to load
|
||||||
|
+ * the stored bytes. The data might be interpreted using the host,
|
||||||
|
+ * reversed host byte order, little-endian, or big-endian.
|
||||||
|
* - 'h[CDN]' For a variable-length buffer, it prints it as a hex string with
|
||||||
|
* a certain separator (' ' by default):
|
||||||
|
* C colon
|
||||||
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
|
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
|
||||||
index b03d526e4..e6d854f56 100755
|
index b03d526e4..e6d854f56 100755
|
||||||
--- a/scripts/checkpatch.pl
|
--- a/scripts/checkpatch.pl
|
||||||
|
|||||||
Reference in New Issue
Block a user