Skip to content

Commit a228809

Browse files
spbnickJiri Kosina
authored andcommitted
HID: uclogic: Move param printing to a function
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]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 4c60bc7 commit a228809

File tree

3 files changed

+93
-116
lines changed

3 files changed

+93
-116
lines changed

drivers/hid/hid-uclogic-core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ static int uclogic_probe(struct hid_device *hdev,
209209
goto failure;
210210
}
211211
params_initialized = true;
212-
hid_dbg(hdev, "parameters:\n" UCLOGIC_PARAMS_FMT_STR,
213-
UCLOGIC_PARAMS_FMT_ARGS(&drvdata->params));
212+
hid_dbg(hdev, "parameters:\n");
213+
uclogic_params_hid_dbg(hdev, &drvdata->params);
214214
if (drvdata->params.invalid) {
215215
hid_info(hdev, "interface is invalid, ignoring\n");
216216
rc = -ENODEV;

drivers/hid/hid-uclogic-params.c

Lines changed: 87 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
* Returns:
3030
* The string representing the type, or NULL if the type is unknown.
3131
*/
32-
const char *uclogic_params_pen_inrange_to_str(
33-
enum uclogic_params_pen_inrange inrange)
32+
static const char *uclogic_params_pen_inrange_to_str(
33+
enum uclogic_params_pen_inrange inrange)
3434
{
3535
switch (inrange) {
3636
case UCLOGIC_PARAMS_PEN_INRANGE_NORMAL:
@@ -44,6 +44,91 @@ const char *uclogic_params_pen_inrange_to_str(
4444
}
4545
}
4646

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+
79+
/**
80+
* Dump tablet interface frame parameters with hid_dbg(), indented with two
81+
* tabs.
82+
*
83+
* @hdev: The HID device the pen parameters describe.
84+
* @frame: The frame parameters to dump.
85+
*/
86+
static void uclogic_params_frame_hid_dbg(
87+
const struct hid_device *hdev,
88+
const struct uclogic_params_frame *frame)
89+
{
90+
hid_dbg(hdev, "\t\t.desc_ptr = %p\n", frame->desc_ptr);
91+
hid_dbg(hdev, "\t\t.desc_size = %u\n", frame->desc_size);
92+
hid_dbg(hdev, "\t\t.id = %u\n", frame->id);
93+
hid_dbg(hdev, "\t\t.suffix = %s\n", frame->suffix);
94+
hid_dbg(hdev, "\t\t.re_lsb = %u\n", frame->re_lsb);
95+
hid_dbg(hdev, "\t\t.dev_id_byte = %u\n", frame->dev_id_byte);
96+
hid_dbg(hdev, "\t\t.touch_ring_byte = %u\n", frame->touch_ring_byte);
97+
hid_dbg(hdev, "\t\t.touch_ring_max = %hhd\n", frame->touch_ring_max);
98+
hid_dbg(hdev, "\t\t.touch_ring_flip_at = %hhd\n",
99+
frame->touch_ring_flip_at);
100+
hid_dbg(hdev, "\t\t.bitmap_dial_byte = %u\n",
101+
frame->bitmap_dial_byte);
102+
}
103+
104+
/**
105+
* Dump tablet interface parameters with hid_dbg().
106+
*
107+
* @hdev: The HID device the parameters describe.
108+
* @params: The parameters to dump.
109+
*/
110+
void uclogic_params_hid_dbg(const struct hid_device *hdev,
111+
const struct uclogic_params *params)
112+
{
113+
size_t i;
114+
115+
hid_dbg(hdev, ".invalid = %s\n",
116+
params->invalid ? "true" : "false");
117+
hid_dbg(hdev, ".desc_ptr = %p\n", params->desc_ptr);
118+
hid_dbg(hdev, ".desc_size = %u\n", params->desc_size);
119+
hid_dbg(hdev, ".pen = {\n");
120+
uclogic_params_pen_hid_dbg(hdev, &params->pen);
121+
hid_dbg(hdev, "\t}\n");
122+
hid_dbg(hdev, ".frame_list = {\n");
123+
for (i = 0; i < ARRAY_SIZE(params->frame_list); i++) {
124+
hid_dbg(hdev, "\t{\n");
125+
uclogic_params_frame_hid_dbg(hdev, &params->frame_list[i]);
126+
hid_dbg(hdev, "\t}%s\n",
127+
i < (ARRAY_SIZE(params->frame_list) - 1) ? "," : "");
128+
}
129+
hid_dbg(hdev, "}\n");
130+
}
131+
47132
/**
48133
* uclogic_params_get_str_desc - retrieve a string descriptor from a HID
49134
* device interface, putting it into a kmalloc-allocated buffer as is, without

drivers/hid/hid-uclogic-params.h

Lines changed: 4 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ enum uclogic_params_pen_inrange {
2929
UCLOGIC_PARAMS_PEN_INRANGE_NONE,
3030
};
3131

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

216-
/* Tablet interface parameters *printf format string */
217-
#define UCLOGIC_PARAMS_FMT_STR \
218-
".invalid = %s\n" \
219-
".desc_ptr = %p\n" \
220-
".desc_size = %u\n" \
221-
".pen = {\n" \
222-
"\t.usage_invalid = %s\n" \
223-
"\t.desc_ptr = %p\n" \
224-
"\t.desc_size = %u\n" \
225-
"\t.id = %u\n" \
226-
"\t.subreport_list = {\n" \
227-
"\t\t{0x%02hhx, %hhu},\n" \
228-
"\t\t{0x%02hhx, %hhu},\n" \
229-
"\t\t{0x%02hhx, %hhu},\n" \
230-
"\t}\n" \
231-
"\t.inrange = %s\n" \
232-
"\t.fragmented_hires = %s\n" \
233-
"\t.tilt_y_flipped = %s\n" \
234-
"}\n" \
235-
".frame_list = {\n" \
236-
"\t{\n" \
237-
"\t\t.desc_ptr = %p\n" \
238-
"\t\t.desc_size = %u\n" \
239-
"\t\t.id = %u\n" \
240-
"\t\t.suffix = %s\n" \
241-
"\t\t.re_lsb = %u\n" \
242-
"\t\t.dev_id_byte = %u\n" \
243-
"\t\t.touch_ring_byte = %u\n" \
244-
"\t\t.touch_ring_max = %hhd\n" \
245-
"\t\t.touch_ring_flip_at = %hhd\n" \
246-
"\t\t.bitmap_dial_byte = %u\n" \
247-
"\t},\n" \
248-
"\t{\n" \
249-
"\t\t.desc_ptr = %p\n" \
250-
"\t\t.desc_size = %u\n" \
251-
"\t\t.id = %u\n" \
252-
"\t\t.suffix = %s\n" \
253-
"\t\t.re_lsb = %u\n" \
254-
"\t\t.dev_id_byte = %u\n" \
255-
"\t\t.touch_ring_byte = %u\n" \
256-
"\t\t.touch_ring_max = %hhd\n" \
257-
"\t\t.touch_ring_flip_at = %hhd\n" \
258-
"\t\t.bitmap_dial_byte = %u\n" \
259-
"\t},\n" \
260-
"\t{\n" \
261-
"\t\t.desc_ptr = %p\n" \
262-
"\t\t.desc_size = %u\n" \
263-
"\t\t.id = %u\n" \
264-
"\t\t.suffix = %s\n" \
265-
"\t\t.re_lsb = %u\n" \
266-
"\t\t.dev_id_byte = %u\n" \
267-
"\t\t.touch_ring_byte = %u\n" \
268-
"\t\t.touch_ring_max = %hhd\n" \
269-
"\t\t.touch_ring_flip_at = %hhd\n" \
270-
"\t\t.bitmap_dial_byte = %u\n" \
271-
"\t},\n" \
272-
"}\n"
273-
274-
/* Tablet interface parameters *printf format arguments */
275-
#define UCLOGIC_PARAMS_FMT_ARGS(_params) \
276-
((_params)->invalid ? "true" : "false"), \
277-
(_params)->desc_ptr, \
278-
(_params)->desc_size, \
279-
((_params)->pen.usage_invalid ? "true" : "false"), \
280-
(_params)->pen.desc_ptr, \
281-
(_params)->pen.desc_size, \
282-
(_params)->pen.id, \
283-
(_params)->pen.subreport_list[0].value, \
284-
(_params)->pen.subreport_list[0].id, \
285-
(_params)->pen.subreport_list[1].value, \
286-
(_params)->pen.subreport_list[1].id, \
287-
(_params)->pen.subreport_list[2].value, \
288-
(_params)->pen.subreport_list[2].id, \
289-
uclogic_params_pen_inrange_to_str((_params)->pen.inrange), \
290-
((_params)->pen.fragmented_hires ? "true" : "false"), \
291-
((_params)->pen.tilt_y_flipped ? "true" : "false"), \
292-
(_params)->frame_list[0].desc_ptr, \
293-
(_params)->frame_list[0].desc_size, \
294-
(_params)->frame_list[0].id, \
295-
(_params)->frame_list[0].suffix, \
296-
(_params)->frame_list[0].re_lsb, \
297-
(_params)->frame_list[0].dev_id_byte, \
298-
(_params)->frame_list[0].touch_ring_byte, \
299-
(_params)->frame_list[0].touch_ring_max, \
300-
(_params)->frame_list[0].touch_ring_flip_at, \
301-
(_params)->frame_list[0].bitmap_dial_byte, \
302-
(_params)->frame_list[1].desc_ptr, \
303-
(_params)->frame_list[1].desc_size, \
304-
(_params)->frame_list[1].id, \
305-
(_params)->frame_list[1].suffix, \
306-
(_params)->frame_list[1].re_lsb, \
307-
(_params)->frame_list[1].dev_id_byte, \
308-
(_params)->frame_list[1].touch_ring_byte, \
309-
(_params)->frame_list[1].touch_ring_max, \
310-
(_params)->frame_list[1].touch_ring_flip_at, \
311-
(_params)->frame_list[1].bitmap_dial_byte, \
312-
(_params)->frame_list[2].desc_ptr, \
313-
(_params)->frame_list[2].desc_size, \
314-
(_params)->frame_list[2].id, \
315-
(_params)->frame_list[2].suffix, \
316-
(_params)->frame_list[2].re_lsb, \
317-
(_params)->frame_list[2].dev_id_byte, \
318-
(_params)->frame_list[2].touch_ring_byte, \
319-
(_params)->frame_list[2].touch_ring_max, \
320-
(_params)->frame_list[2].touch_ring_flip_at, \
321-
(_params)->frame_list[2].bitmap_dial_byte
322-
323211
/* Get a replacement report descriptor for a tablet's interface. */
324212
extern int uclogic_params_get_desc(const struct uclogic_params *params,
325213
__u8 **pdesc,
@@ -328,4 +216,8 @@ extern int uclogic_params_get_desc(const struct uclogic_params *params,
328216
/* Free resources used by tablet interface's parameters */
329217
extern void uclogic_params_cleanup(struct uclogic_params *params);
330218

219+
/* Dump tablet interface parameters with hid_dbg() */
220+
extern void uclogic_params_hid_dbg(const struct hid_device *hdev,
221+
const struct uclogic_params *params);
222+
331223
#endif /* _HID_UCLOGIC_PARAMS_H */

0 commit comments

Comments
 (0)