Debian Codegraph @

lib/chip-info.c

raw symbols SCIP
1 // SPDX-License-Identifier: LGPL-2.1-or-latercxx . . $ `<file>/lib/chip-info.c`/
2 // SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <[email protected]>
3
4 #include <assert.h>
5 #include <gpiod.h>cxx . . $ `<file>/include/gpiod.h`/
6 #include <stdlib.h>
7 #include <string.h>
8
9 #include "internal.h"cxx . . $ `<file>/lib/internal.h`/
10
11 struct gpiod_chip_infocxx . . $ gpiod_chip_info# {
12 size_t num_linescxx . . $ gpiod_chip_info#num_lines.;
13 char namecxx . . $ gpiod_chip_info#name.[GPIO_MAX_NAME_SIZEcxx . . $ `lib/uapi/gpio.h:23:9`! + 1];
14 char labelcxx . . $ gpiod_chip_info#label.[GPIO_MAX_NAME_SIZEcxx . . $ `lib/uapi/gpio.h:23:9`! + 1];
15 };
16
17 GPIOD_APIcxx . . $ `lib/internal.h:15:9`! void gpiod_chip_info_freecxx . . $ gpiod_chip_info_free(9a024ec8679f143e).(struct gpiod_chip_infocxx . . $ gpiod_chip_info# *info)
18 {
19 freecxx . . $ free(5d22bdacc48458e8).(info);
20 }
21
22 GPIOD_APIcxx . . $ `lib/internal.h:15:9`! const char *gpiod_chip_info_get_namecxx . . $ gpiod_chip_info_get_name(71af00a57ff665b).(struct gpiod_chip_infocxx . . $ gpiod_chip_info# *info)
23 {
24 assertcxx . . $ `<external>/4398592474888995393/assert.h:156:12`!(info);
25
26 return info->namecxx . . $ gpiod_chip_info#name.;
27 }
28
29 GPIOD_APIcxx . . $ `lib/internal.h:15:9`! const char *gpiod_chip_info_get_labelcxx . . $ gpiod_chip_info_get_label(71af00a57ff665b).(struct gpiod_chip_infocxx . . $ gpiod_chip_info# *info)
30 {
31 assertcxx . . $ `<external>/4398592474888995393/assert.h:156:12`!(info);
32
33 return info->labelcxx . . $ gpiod_chip_info#label.;
34 }
35
36 GPIOD_APIcxx . . $ `lib/internal.h:15:9`! size_t gpiod_chip_info_get_num_linescxx . . $ gpiod_chip_info_get_num_lines(57ee55e61bf1dbf4).(struct gpiod_chip_infocxx . . $ gpiod_chip_info# *info)
37 {
38 assertcxx . . $ `<external>/4398592474888995393/assert.h:156:12`!(info);
39
40 return info->num_linescxx . . $ gpiod_chip_info#num_lines.;
41 }
42
43 struct gpiod_chip_infocxx . . $ gpiod_chip_info# *
44 gpiod_chip_info_from_uapicxx . . $ gpiod_chip_info_from_uapi(d34692967859f3f7).(struct gpiochip_infocxx . . $ gpiochip_info# *uapi_info)
45 {
46 struct gpiod_chip_infocxx . . $ gpiod_chip_info# *info;
47
48 info = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(*info));
49 if (!info)
50 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
51
52 memsetcxx . . $ memset(d1de1e4fb215f1c6).(info, 0, sizeof(*info));
53
54 info->num_linescxx . . $ gpiod_chip_info#num_lines. = uapi_info->linescxx . . $ gpiochip_info#lines.;
55
56 /*
57 * GPIO device must have a name - don't bother checking this field. In
58 * the worst case (would have to be a weird kernel bug) it'll be empty.
59 */
60 strncpycxx . . $ strncpy(255158a415b673b0).(info->namecxx . . $ gpiod_chip_info#name., uapi_info->namecxx . . $ gpiochip_info#name., GPIO_MAX_NAME_SIZEcxx . . $ `lib/uapi/gpio.h:23:9`!);
61 info->namecxx . . $ gpiod_chip_info#name.[GPIO_MAX_NAME_SIZEcxx . . $ `lib/uapi/gpio.h:23:9`!] = '\0';
62
63 /*
64 * The kernel sets the label of a GPIO device to "unknown" if it
65 * hasn't been defined in DT, board file etc. On the off-chance that
66 * we got an empty string, do the same.
67 */
68 if (uapi_info->labelcxx . . $ gpiochip_info#label.[0] == '\0')
69 strncpycxx . . $ strncpy(255158a415b673b0).(info->labelcxx . . $ gpiod_chip_info#label., "unknown", GPIO_MAX_NAME_SIZEcxx . . $ `lib/uapi/gpio.h:23:9`!);
70 else
71 strncpycxx . . $ strncpy(255158a415b673b0).(info->labelcxx . . $ gpiod_chip_info#label., uapi_info->labelcxx . . $ gpiochip_info#label., GPIO_MAX_NAME_SIZEcxx . . $ `lib/uapi/gpio.h:23:9`!);
72 info->labelcxx . . $ gpiod_chip_info#label.[GPIO_MAX_NAME_SIZEcxx . . $ `lib/uapi/gpio.h:23:9`!] = '\0';
73
74 return info;
75 }