2022-05-09 05:13:34

by José Expósito

[permalink] [raw]
Subject: [PATCH for-5.19/uclogic 1/7] HID: uclogic: Move param printing to a function

From: Nikolai Kondrashov <[email protected]>

Move parameter printing from a format string/argument list to a function
to allow printing the full parameters, which now wouldn't fit into a
single print call.

Signed-off-by: Nikolai Kondrashov <[email protected]>
Signed-off-by: José Expósito <[email protected]>
---
drivers/hid/hid-uclogic-core.c | 4 +-
drivers/hid/hid-uclogic-params.c | 89 +++++++++++++++++++++++-
drivers/hid/hid-uclogic-params.h | 116 ++-----------------------------
3 files changed, 93 insertions(+), 116 deletions(-)

diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c
index 8ef3d1830052..8cac5944e63f 100644
--- a/drivers/hid/hid-uclogic-core.c
+++ b/drivers/hid/hid-uclogic-core.c
@@ -209,8 +209,8 @@ static int uclogic_probe(struct hid_device *hdev,
goto failure;
}
params_initialized = true;
- hid_dbg(hdev, "parameters:\n" UCLOGIC_PARAMS_FMT_STR,
- UCLOGIC_PARAMS_FMT_ARGS(&drvdata->params));
+ hid_dbg(hdev, "parameters:\n");
+ uclogic_params_hid_dbg(hdev, &drvdata->params);
if (drvdata->params.invalid) {
hid_info(hdev, "interface is invalid, ignoring\n");
rc = -ENODEV;
diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c
index 22f9c4f9da8a..1d9168cc7dc0 100644
--- a/drivers/hid/hid-uclogic-params.c
+++ b/drivers/hid/hid-uclogic-params.c
@@ -29,8 +29,8 @@
* Returns:
* The string representing the type, or NULL if the type is unknown.
*/
-const char *uclogic_params_pen_inrange_to_str(
- enum uclogic_params_pen_inrange inrange)
+static const char *uclogic_params_pen_inrange_to_str(
+ enum uclogic_params_pen_inrange inrange)
{
switch (inrange) {
case UCLOGIC_PARAMS_PEN_INRANGE_NORMAL:
@@ -44,6 +44,91 @@ const char *uclogic_params_pen_inrange_to_str(
}
}

+/**
+ * Dump tablet interface pen parameters with hid_dbg(), indented with one tab.
+ *
+ * @hdev: The HID device the pen parameters describe.
+ * @pen: The pen parameters to dump.
+ */
+static void uclogic_params_pen_hid_dbg(const struct hid_device *hdev,
+ const struct uclogic_params_pen *pen)
+{
+ size_t i;
+
+ hid_dbg(hdev, "\t.usage_invalid = %s\n",
+ (pen->usage_invalid ? "true" : "false"));
+ hid_dbg(hdev, "\t.desc_ptr = %p\n", pen->desc_ptr);
+ hid_dbg(hdev, "\t.desc_size = %u\n", pen->desc_size);
+ hid_dbg(hdev, "\t.id = %u\n", pen->id);
+ hid_dbg(hdev, "\t.subreport_list = {\n");
+ for (i = 0; i < ARRAY_SIZE(pen->subreport_list); i++) {
+ hid_dbg(hdev, "\t\t{0x%02hhx, %hhu}%s\n",
+ pen->subreport_list[i].value,
+ pen->subreport_list[i].id,
+ i < (ARRAY_SIZE(pen->subreport_list) - 1) ? "," : "");
+ }
+ hid_dbg(hdev, "\t}\n");
+ hid_dbg(hdev, "\t.inrange = %s\n",
+ uclogic_params_pen_inrange_to_str(pen->inrange));
+ hid_dbg(hdev, "\t.fragmented_hires = %s\n",
+ (pen->fragmented_hires ? "true" : "false"));
+ hid_dbg(hdev, "\t.tilt_y_flipped = %s\n",
+ (pen->tilt_y_flipped ? "true" : "false"));
+}
+
+/**
+ * Dump tablet interface frame parameters with hid_dbg(), indented with two
+ * tabs.
+ *
+ * @hdev: The HID device the pen parameters describe.
+ * @frame: The frame parameters to dump.
+ */
+static void uclogic_params_frame_hid_dbg(
+ const struct hid_device *hdev,
+ const struct uclogic_params_frame *frame)
+{
+ hid_dbg(hdev, "\t\t.desc_ptr = %p\n", frame->desc_ptr);
+ hid_dbg(hdev, "\t\t.desc_size = %u\n", frame->desc_size);
+ hid_dbg(hdev, "\t\t.id = %u\n", frame->id);
+ hid_dbg(hdev, "\t\t.suffix = %s\n", frame->suffix);
+ hid_dbg(hdev, "\t\t.re_lsb = %u\n", frame->re_lsb);
+ hid_dbg(hdev, "\t\t.dev_id_byte = %u\n", frame->dev_id_byte);
+ hid_dbg(hdev, "\t\t.touch_ring_byte = %u\n", frame->touch_ring_byte);
+ hid_dbg(hdev, "\t\t.touch_ring_max = %hhd\n", frame->touch_ring_max);
+ hid_dbg(hdev, "\t\t.touch_ring_flip_at = %hhd\n",
+ frame->touch_ring_flip_at);
+ hid_dbg(hdev, "\t\t.bitmap_dial_byte = %u\n",
+ frame->bitmap_dial_byte);
+}
+
+/**
+ * Dump tablet interface parameters with hid_dbg().
+ *
+ * @hdev: The HID device the parameters describe.
+ * @params: The parameters to dump.
+ */
+void uclogic_params_hid_dbg(const struct hid_device *hdev,
+ const struct uclogic_params *params)
+{
+ size_t i;
+
+ hid_dbg(hdev, ".invalid = %s\n",
+ params->invalid ? "true" : "false");
+ hid_dbg(hdev, ".desc_ptr = %p\n", params->desc_ptr);
+ hid_dbg(hdev, ".desc_size = %u\n", params->desc_size);
+ hid_dbg(hdev, ".pen = {\n");
+ uclogic_params_pen_hid_dbg(hdev, &params->pen);
+ hid_dbg(hdev, "\t}\n");
+ hid_dbg(hdev, ".frame_list = {\n");
+ for (i = 0; i < ARRAY_SIZE(params->frame_list); i++) {
+ hid_dbg(hdev, "\t{\n");
+ uclogic_params_frame_hid_dbg(hdev, &params->frame_list[i]);
+ hid_dbg(hdev, "\t}%s\n",
+ i < (ARRAY_SIZE(params->frame_list) - 1) ? "," : "");
+ }
+ hid_dbg(hdev, "}\n");
+}
+
/**
* uclogic_params_get_str_desc - retrieve a string descriptor from a HID
* device interface, putting it into a kmalloc-allocated buffer as is, without
diff --git a/drivers/hid/hid-uclogic-params.h b/drivers/hid/hid-uclogic-params.h
index fb2001018c46..c7573f70d35c 100644
--- a/drivers/hid/hid-uclogic-params.h
+++ b/drivers/hid/hid-uclogic-params.h
@@ -29,11 +29,6 @@ enum uclogic_params_pen_inrange {
UCLOGIC_PARAMS_PEN_INRANGE_NONE,
};

-/* Convert a pen in-range reporting type to a string */
-extern const char *uclogic_params_pen_inrange_to_str(
- enum uclogic_params_pen_inrange inrange);
-
-
/*
* Pen report's subreport data.
*/
@@ -213,113 +208,6 @@ struct uclogic_params {
extern int uclogic_params_init(struct uclogic_params *params,
struct hid_device *hdev);

-/* Tablet interface parameters *printf format string */
-#define UCLOGIC_PARAMS_FMT_STR \
- ".invalid = %s\n" \
- ".desc_ptr = %p\n" \
- ".desc_size = %u\n" \
- ".pen = {\n" \
- "\t.usage_invalid = %s\n" \
- "\t.desc_ptr = %p\n" \
- "\t.desc_size = %u\n" \
- "\t.id = %u\n" \
- "\t.subreport_list = {\n" \
- "\t\t{0x%02hhx, %hhu},\n" \
- "\t\t{0x%02hhx, %hhu},\n" \
- "\t\t{0x%02hhx, %hhu},\n" \
- "\t}\n" \
- "\t.inrange = %s\n" \
- "\t.fragmented_hires = %s\n" \
- "\t.tilt_y_flipped = %s\n" \
- "}\n" \
- ".frame_list = {\n" \
- "\t{\n" \
- "\t\t.desc_ptr = %p\n" \
- "\t\t.desc_size = %u\n" \
- "\t\t.id = %u\n" \
- "\t\t.suffix = %s\n" \
- "\t\t.re_lsb = %u\n" \
- "\t\t.dev_id_byte = %u\n" \
- "\t\t.touch_ring_byte = %u\n" \
- "\t\t.touch_ring_max = %hhd\n" \
- "\t\t.touch_ring_flip_at = %hhd\n" \
- "\t\t.bitmap_dial_byte = %u\n" \
- "\t},\n" \
- "\t{\n" \
- "\t\t.desc_ptr = %p\n" \
- "\t\t.desc_size = %u\n" \
- "\t\t.id = %u\n" \
- "\t\t.suffix = %s\n" \
- "\t\t.re_lsb = %u\n" \
- "\t\t.dev_id_byte = %u\n" \
- "\t\t.touch_ring_byte = %u\n" \
- "\t\t.touch_ring_max = %hhd\n" \
- "\t\t.touch_ring_flip_at = %hhd\n" \
- "\t\t.bitmap_dial_byte = %u\n" \
- "\t},\n" \
- "\t{\n" \
- "\t\t.desc_ptr = %p\n" \
- "\t\t.desc_size = %u\n" \
- "\t\t.id = %u\n" \
- "\t\t.suffix = %s\n" \
- "\t\t.re_lsb = %u\n" \
- "\t\t.dev_id_byte = %u\n" \
- "\t\t.touch_ring_byte = %u\n" \
- "\t\t.touch_ring_max = %hhd\n" \
- "\t\t.touch_ring_flip_at = %hhd\n" \
- "\t\t.bitmap_dial_byte = %u\n" \
- "\t},\n" \
- "}\n"
-
-/* Tablet interface parameters *printf format arguments */
-#define UCLOGIC_PARAMS_FMT_ARGS(_params) \
- ((_params)->invalid ? "true" : "false"), \
- (_params)->desc_ptr, \
- (_params)->desc_size, \
- ((_params)->pen.usage_invalid ? "true" : "false"), \
- (_params)->pen.desc_ptr, \
- (_params)->pen.desc_size, \
- (_params)->pen.id, \
- (_params)->pen.subreport_list[0].value, \
- (_params)->pen.subreport_list[0].id, \
- (_params)->pen.subreport_list[1].value, \
- (_params)->pen.subreport_list[1].id, \
- (_params)->pen.subreport_list[2].value, \
- (_params)->pen.subreport_list[2].id, \
- uclogic_params_pen_inrange_to_str((_params)->pen.inrange), \
- ((_params)->pen.fragmented_hires ? "true" : "false"), \
- ((_params)->pen.tilt_y_flipped ? "true" : "false"), \
- (_params)->frame_list[0].desc_ptr, \
- (_params)->frame_list[0].desc_size, \
- (_params)->frame_list[0].id, \
- (_params)->frame_list[0].suffix, \
- (_params)->frame_list[0].re_lsb, \
- (_params)->frame_list[0].dev_id_byte, \
- (_params)->frame_list[0].touch_ring_byte, \
- (_params)->frame_list[0].touch_ring_max, \
- (_params)->frame_list[0].touch_ring_flip_at, \
- (_params)->frame_list[0].bitmap_dial_byte, \
- (_params)->frame_list[1].desc_ptr, \
- (_params)->frame_list[1].desc_size, \
- (_params)->frame_list[1].id, \
- (_params)->frame_list[1].suffix, \
- (_params)->frame_list[1].re_lsb, \
- (_params)->frame_list[1].dev_id_byte, \
- (_params)->frame_list[1].touch_ring_byte, \
- (_params)->frame_list[1].touch_ring_max, \
- (_params)->frame_list[1].touch_ring_flip_at, \
- (_params)->frame_list[1].bitmap_dial_byte, \
- (_params)->frame_list[2].desc_ptr, \
- (_params)->frame_list[2].desc_size, \
- (_params)->frame_list[2].id, \
- (_params)->frame_list[2].suffix, \
- (_params)->frame_list[2].re_lsb, \
- (_params)->frame_list[2].dev_id_byte, \
- (_params)->frame_list[2].touch_ring_byte, \
- (_params)->frame_list[2].touch_ring_max, \
- (_params)->frame_list[2].touch_ring_flip_at, \
- (_params)->frame_list[2].bitmap_dial_byte
-
/* Get a replacement report descriptor for a tablet's interface. */
extern int uclogic_params_get_desc(const struct uclogic_params *params,
__u8 **pdesc,
@@ -328,4 +216,8 @@ extern int uclogic_params_get_desc(const struct uclogic_params *params,
/* Free resources used by tablet interface's parameters */
extern void uclogic_params_cleanup(struct uclogic_params *params);

+/* Dump tablet interface parameters with hid_dbg() */
+extern void uclogic_params_hid_dbg(const struct hid_device *hdev,
+ const struct uclogic_params *params);
+
#endif /* _HID_UCLOGIC_PARAMS_H */
--
2.25.1



2022-05-09 06:55:48

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH for-5.19/uclogic 1/7] HID: uclogic: Move param printing to a function

Hi "Jos?,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on hid/for-next]
[cannot apply to v5.18-rc5 next-20220506]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/intel-lab-lkp/linux/commits/Jos-Exp-sito/DIGImend-patches-part-VI/20220509-000510
base: https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git for-next
config: x86_64-randconfig-a003-20220509 (https://download.01.org/0day-ci/archive/20220509/[email protected]/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project a385645b470e2d3a1534aae618ea56b31177639f)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/4c0671e4ce0687136ff71aa65539cd3a2798d99d
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Jos-Exp-sito/DIGImend-patches-part-VI/20220509-000510
git checkout 4c0671e4ce0687136ff71aa65539cd3a2798d99d
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/hid/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

>> drivers/hid/hid-uclogic-params.c:48: warning: This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst
* Dump tablet interface pen parameters with hid_dbg(), indented with one tab.
drivers/hid/hid-uclogic-params.c:80: warning: This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst
* Dump tablet interface frame parameters with hid_dbg(), indented with two
drivers/hid/hid-uclogic-params.c:105: warning: This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst
* Dump tablet interface parameters with hid_dbg().


vim +48 drivers/hid/hid-uclogic-params.c

46
47 /**
> 48 * Dump tablet interface pen parameters with hid_dbg(), indented with one tab.
49 *
50 * @hdev: The HID device the pen parameters describe.
51 * @pen: The pen parameters to dump.
52 */
53 static void uclogic_params_pen_hid_dbg(const struct hid_device *hdev,
54 const struct uclogic_params_pen *pen)
55 {
56 size_t i;
57
58 hid_dbg(hdev, "\t.usage_invalid = %s\n",
59 (pen->usage_invalid ? "true" : "false"));
60 hid_dbg(hdev, "\t.desc_ptr = %p\n", pen->desc_ptr);
61 hid_dbg(hdev, "\t.desc_size = %u\n", pen->desc_size);
62 hid_dbg(hdev, "\t.id = %u\n", pen->id);
63 hid_dbg(hdev, "\t.subreport_list = {\n");
64 for (i = 0; i < ARRAY_SIZE(pen->subreport_list); i++) {
65 hid_dbg(hdev, "\t\t{0x%02hhx, %hhu}%s\n",
66 pen->subreport_list[i].value,
67 pen->subreport_list[i].id,
68 i < (ARRAY_SIZE(pen->subreport_list) - 1) ? "," : "");
69 }
70 hid_dbg(hdev, "\t}\n");
71 hid_dbg(hdev, "\t.inrange = %s\n",
72 uclogic_params_pen_inrange_to_str(pen->inrange));
73 hid_dbg(hdev, "\t.fragmented_hires = %s\n",
74 (pen->fragmented_hires ? "true" : "false"));
75 hid_dbg(hdev, "\t.tilt_y_flipped = %s\n",
76 (pen->tilt_y_flipped ? "true" : "false"));
77 }
78

--
0-DAY CI Kernel Test Service
https://01.org/lkp