xref: /linux/drivers/input/vivaldi-fmap.c (revision 722ecdbce68a87de2d9296f91308f44ea900a039)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Helpers for ChromeOS Vivaldi keyboard function row mapping
4  *
5  * Copyright (C) 2022 Google, Inc
6  */
7 
8 #include <linux/export.h>
9 #include <linux/input/vivaldi-fmap.h>
10 #include <linux/kernel.h>
11 #include <linux/module.h>
12 #include <linux/types.h>
13 
14 /**
15  * vivaldi_function_row_physmap_show - Print vivaldi function row physmap attribute
16  * @data: The vivaldi function row map
17  * @buf: Buffer to print the function row phsymap to
18  */
19 ssize_t vivaldi_function_row_physmap_show(const struct vivaldi_data *data,
20 					  char *buf)
21 {
22 	ssize_t size = 0;
23 	int i;
24 	const u32 *physmap = data->function_row_physmap;
25 
26 	if (!data->num_function_row_keys)
27 		return 0;
28 
29 	for (i = 0; i < data->num_function_row_keys; i++)
30 		size += scnprintf(buf + size, PAGE_SIZE - size,
31 				  "%s%02X", size ? " " : "", physmap[i]);
32 	if (size)
33 		size += scnprintf(buf + size, PAGE_SIZE - size, "\n");
34 
35 	return size;
36 }
37 EXPORT_SYMBOL_GPL(vivaldi_function_row_physmap_show);
38 
39 MODULE_LICENSE("GPL");
40