gpiod 2.4.2__tar.gz → 2.4.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. {gpiod-2.4.2/gpiod.egg-info → gpiod-2.4.3}/PKG-INFO +1 -1
  2. {gpiod-2.4.2 → gpiod-2.4.3}/gpiod/ext/chip.c +2 -0
  3. {gpiod-2.4.2 → gpiod-2.4.3}/gpiod/ext/line-config.c +4 -0
  4. {gpiod-2.4.2 → gpiod-2.4.3}/gpiod/ext/request.c +2 -3
  5. {gpiod-2.4.2 → gpiod-2.4.3}/gpiod/version.py +1 -1
  6. {gpiod-2.4.2 → gpiod-2.4.3/gpiod.egg-info}/PKG-INFO +1 -1
  7. {gpiod-2.4.2 → gpiod-2.4.3}/lib/chip-info.c +2 -0
  8. {gpiod-2.4.2 → gpiod-2.4.3}/lib/edge-event.c +5 -0
  9. {gpiod-2.4.2 → gpiod-2.4.3}/lib/line-config.c +42 -3
  10. {gpiod-2.4.2 → gpiod-2.4.3}/lib/line-info.c +2 -0
  11. {gpiod-2.4.2 → gpiod-2.4.3}/lib/line-request.c +1 -1
  12. gpiod-2.4.3/libgpiod-version.txt +1 -0
  13. gpiod-2.4.2/libgpiod-version.txt +0 -1
  14. {gpiod-2.4.2 → gpiod-2.4.3}/LICENSE +0 -0
  15. {gpiod-2.4.2 → gpiod-2.4.3}/MANIFEST.in +0 -0
  16. {gpiod-2.4.2 → gpiod-2.4.3}/README.md +0 -0
  17. {gpiod-2.4.2 → gpiod-2.4.3}/build_tests.py +0 -0
  18. {gpiod-2.4.2 → gpiod-2.4.3}/gpiod/__init__.py +0 -0
  19. {gpiod-2.4.2 → gpiod-2.4.3}/gpiod/_ext.pyi +0 -0
  20. {gpiod-2.4.2 → gpiod-2.4.3}/gpiod/_internal.py +0 -0
  21. {gpiod-2.4.2 → gpiod-2.4.3}/gpiod/chip.py +0 -0
  22. {gpiod-2.4.2 → gpiod-2.4.3}/gpiod/chip_info.py +0 -0
  23. {gpiod-2.4.2 → gpiod-2.4.3}/gpiod/edge_event.py +0 -0
  24. {gpiod-2.4.2 → gpiod-2.4.3}/gpiod/exception.py +0 -0
  25. {gpiod-2.4.2 → gpiod-2.4.3}/gpiod/ext/common.c +0 -0
  26. {gpiod-2.4.2 → gpiod-2.4.3}/gpiod/ext/internal.h +0 -0
  27. {gpiod-2.4.2 → gpiod-2.4.3}/gpiod/ext/line-settings.c +0 -0
  28. {gpiod-2.4.2 → gpiod-2.4.3}/gpiod/ext/module.c +0 -0
  29. {gpiod-2.4.2 → gpiod-2.4.3}/gpiod/info_event.py +0 -0
  30. {gpiod-2.4.2 → gpiod-2.4.3}/gpiod/line.py +0 -0
  31. {gpiod-2.4.2 → gpiod-2.4.3}/gpiod/line_info.py +0 -0
  32. {gpiod-2.4.2 → gpiod-2.4.3}/gpiod/line_request.py +0 -0
  33. {gpiod-2.4.2 → gpiod-2.4.3}/gpiod/line_settings.py +0 -0
  34. {gpiod-2.4.2 → gpiod-2.4.3}/gpiod/py.typed +0 -0
  35. {gpiod-2.4.2 → gpiod-2.4.3}/gpiod.egg-info/SOURCES.txt +0 -0
  36. {gpiod-2.4.2 → gpiod-2.4.3}/gpiod.egg-info/dependency_links.txt +0 -0
  37. {gpiod-2.4.2 → gpiod-2.4.3}/gpiod.egg-info/top_level.txt +0 -0
  38. {gpiod-2.4.2 → gpiod-2.4.3}/include/gpiod.h +0 -0
  39. {gpiod-2.4.2 → gpiod-2.4.3}/lib/chip.c +0 -0
  40. {gpiod-2.4.2 → gpiod-2.4.3}/lib/info-event.c +0 -0
  41. {gpiod-2.4.2 → gpiod-2.4.3}/lib/internal.c +0 -0
  42. {gpiod-2.4.2 → gpiod-2.4.3}/lib/internal.h +0 -0
  43. {gpiod-2.4.2 → gpiod-2.4.3}/lib/line-settings.c +0 -0
  44. {gpiod-2.4.2 → gpiod-2.4.3}/lib/misc.c +0 -0
  45. {gpiod-2.4.2 → gpiod-2.4.3}/lib/request-config.c +0 -0
  46. {gpiod-2.4.2 → gpiod-2.4.3}/lib/uapi/gpio.h +0 -0
  47. {gpiod-2.4.2 → gpiod-2.4.3}/pyproject.toml +0 -0
  48. {gpiod-2.4.2 → gpiod-2.4.3}/setup.cfg +0 -0
  49. {gpiod-2.4.2 → gpiod-2.4.3}/setup.py +0 -0
  50. {gpiod-2.4.2 → gpiod-2.4.3}/tests/__init__.py +0 -0
  51. {gpiod-2.4.2 → gpiod-2.4.3}/tests/__main__.py +0 -0
  52. {gpiod-2.4.2 → gpiod-2.4.3}/tests/gpiosim/__init__.py +0 -0
  53. {gpiod-2.4.2 → gpiod-2.4.3}/tests/gpiosim/chip.py +0 -0
  54. {gpiod-2.4.2 → gpiod-2.4.3}/tests/gpiosim/ext.c +0 -0
  55. {gpiod-2.4.2 → gpiod-2.4.3}/tests/helpers.py +0 -0
  56. {gpiod-2.4.2 → gpiod-2.4.3}/tests/system/__init__.py +0 -0
  57. {gpiod-2.4.2 → gpiod-2.4.3}/tests/system/ext.c +0 -0
  58. {gpiod-2.4.2 → gpiod-2.4.3}/tests/tests_chip.py +0 -0
  59. {gpiod-2.4.2 → gpiod-2.4.3}/tests/tests_chip_info.py +0 -0
  60. {gpiod-2.4.2 → gpiod-2.4.3}/tests/tests_edge_event.py +0 -0
  61. {gpiod-2.4.2 → gpiod-2.4.3}/tests/tests_info_event.py +0 -0
  62. {gpiod-2.4.2 → gpiod-2.4.3}/tests/tests_line.py +0 -0
  63. {gpiod-2.4.2 → gpiod-2.4.3}/tests/tests_line_info.py +0 -0
  64. {gpiod-2.4.2 → gpiod-2.4.3}/tests/tests_line_request.py +0 -0
  65. {gpiod-2.4.2 → gpiod-2.4.3}/tests/tests_line_settings.py +0 -0
  66. {gpiod-2.4.2 → gpiod-2.4.3}/tests/tests_module.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gpiod
3
- Version: 2.4.2
3
+ Version: 2.4.3
4
4
  Summary: Python bindings for libgpiod
5
5
  Author-email: Bartosz Golaszewski <brgl@bgdev.pl>
6
6
  License-Expression: LGPL-2.1-or-later
@@ -79,7 +79,9 @@ static PyObject *chip_get_info(chip_object *self, PyObject *Py_UNUSED(ignored))
79
79
  if (!type)
80
80
  return NULL;
81
81
 
82
+ Py_BEGIN_ALLOW_THREADS;
82
83
  info = gpiod_chip_get_info(self->chip);
84
+ Py_END_ALLOW_THREADS;
83
85
  if (!info) {
84
86
  Py_DECREF(type);
85
87
  return PyErr_SetFromErrno(PyExc_OSError);
@@ -119,6 +119,10 @@ line_config_set_output_values(line_config_object *self, PyObject *args)
119
119
  next = PyIter_Next(iter);
120
120
  if (!next) {
121
121
  Py_DECREF(iter);
122
+ if (PyErr_Occurred()) {
123
+ PyMem_Free(valbuf);
124
+ return NULL;
125
+ }
122
126
  break;
123
127
  }
124
128
 
@@ -82,7 +82,6 @@ static PyObject *request_offsets(request_object *self, void *Py_UNUSED(ignored))
82
82
 
83
83
  ret = PyList_SetItem(lines, i, line);
84
84
  if (ret) {
85
- Py_DECREF(line);
86
85
  Py_DECREF(lines);
87
86
  PyMem_Free(offsets);
88
87
  return NULL;
@@ -165,6 +164,8 @@ static PyObject *request_get_values(request_object *self, PyObject *args)
165
164
  next = PyIter_Next(iter);
166
165
  if (!next) {
167
166
  Py_DECREF(iter);
167
+ if (PyErr_Occurred())
168
+ return NULL;
168
169
  break;
169
170
  }
170
171
 
@@ -198,7 +199,6 @@ static PyObject *request_get_values(request_object *self, PyObject *args)
198
199
 
199
200
  ret = PyList_SetItem(values, pos, val);
200
201
  if (ret) {
201
- Py_DECREF(val);
202
202
  Py_DECREF(type);
203
203
  return NULL;
204
204
  }
@@ -339,7 +339,6 @@ static PyObject *request_read_edge_events(request_object *self, PyObject *args)
339
339
 
340
340
  ret = PyList_SetItem(events, i, event_obj);
341
341
  if (ret) {
342
- Py_DECREF(event_obj);
343
342
  Py_DECREF(events);
344
343
  Py_DECREF(type);
345
344
  return NULL;
@@ -2,4 +2,4 @@
2
2
  # SPDX-FileCopyrightText: 2022 Linaro Ltd.
3
3
  # SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
4
4
 
5
- __version__ = "2.4.2"
5
+ __version__ = "2.4.3"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gpiod
3
- Version: 2.4.2
3
+ Version: 2.4.3
4
4
  Summary: Python bindings for libgpiod
5
5
  Author-email: Bartosz Golaszewski <brgl@bgdev.pl>
6
6
  License-Expression: LGPL-2.1-or-later
@@ -58,6 +58,7 @@ gpiod_chip_info_from_uapi(struct gpiochip_info *uapi_info)
58
58
  * the worst case (would have to be a weird kernel bug) it'll be empty.
59
59
  */
60
60
  strncpy(info->name, uapi_info->name, GPIO_MAX_NAME_SIZE);
61
+ info->name[GPIO_MAX_NAME_SIZE] = '\0';
61
62
 
62
63
  /*
63
64
  * The kernel sets the label of a GPIO device to "unknown" if it
@@ -68,6 +69,7 @@ gpiod_chip_info_from_uapi(struct gpiochip_info *uapi_info)
68
69
  strncpy(info->label, "unknown", GPIO_MAX_NAME_SIZE);
69
70
  else
70
71
  strncpy(info->label, uapi_info->label, GPIO_MAX_NAME_SIZE);
72
+ info->label[GPIO_MAX_NAME_SIZE] = '\0';
71
73
 
72
74
  return info;
73
75
  }
@@ -184,6 +184,11 @@ int gpiod_edge_event_buffer_read_fd(int fd,
184
184
  if (max_events > buffer->capacity)
185
185
  max_events = buffer->capacity;
186
186
 
187
+ if (max_events == 0) {
188
+ buffer->num_events = 0;
189
+ return 0;
190
+ }
191
+
187
192
  rd = read(fd, buffer->event_data,
188
193
  max_events * sizeof(*buffer->event_data));
189
194
  if (rd < 0) {
@@ -90,13 +90,50 @@ static struct per_line_config *find_config(struct gpiod_line_config *config,
90
90
  return &config->line_configs[config->num_configs++];
91
91
  }
92
92
 
93
+ /*
94
+ * Count offsets in the input array that would require a new slot in the
95
+ * config: those not already present in config->line_configs and not repeated
96
+ * earlier in the same offsets array.
97
+ */
98
+ static size_t count_new_offsets(const struct gpiod_line_config *config,
99
+ const unsigned int *offsets, size_t num_offsets)
100
+ {
101
+ size_t i, j, num_new = 0;
102
+ bool existing;
103
+
104
+ for (i = 0; i < num_offsets; i++) {
105
+ existing = false;
106
+
107
+ for (j = 0; j < config->num_configs; j++) {
108
+ if (config->line_configs[j].offset == offsets[i]) {
109
+ existing = true;
110
+ break;
111
+ }
112
+ }
113
+
114
+ if (!existing) {
115
+ for (j = 0; j < i; j++) {
116
+ if (offsets[j] == offsets[i]) {
117
+ existing = true;
118
+ break;
119
+ }
120
+ }
121
+ }
122
+
123
+ if (!existing)
124
+ num_new++;
125
+ }
126
+
127
+ return num_new;
128
+ }
129
+
93
130
  GPIOD_API int gpiod_line_config_add_line_settings(
94
131
  struct gpiod_line_config *config, const unsigned int *offsets,
95
132
  size_t num_offsets, struct gpiod_line_settings *settings)
96
133
  {
97
134
  struct per_line_config *per_line;
98
135
  struct settings_node *node, *old;
99
- size_t i;
136
+ size_t i, new_offsets;
100
137
 
101
138
  assert(config);
102
139
 
@@ -105,7 +142,9 @@ GPIOD_API int gpiod_line_config_add_line_settings(
105
142
  return -1;
106
143
  }
107
144
 
108
- if ((config->num_configs + num_offsets) > LINES_MAX) {
145
+ new_offsets = count_new_offsets(config, offsets, num_offsets);
146
+
147
+ if ((config->num_configs + new_offsets) > LINES_MAX) {
109
148
  errno = E2BIG;
110
149
  return -1;
111
150
  }
@@ -143,7 +182,7 @@ GPIOD_API int gpiod_line_config_add_line_settings(
143
182
  old->prev->next = old->next;
144
183
  if (old->next)
145
184
  old->next->prev = old->prev;
146
- free(old->settings);
185
+ gpiod_line_settings_free(old->settings);
147
186
  free(old);
148
187
  }
149
188
  }
@@ -149,9 +149,11 @@ gpiod_line_info_from_uapi(struct gpio_v2_line_info *uapi_info)
149
149
 
150
150
  info->offset = uapi_info->offset;
151
151
  strncpy(info->name, uapi_info->name, GPIO_MAX_NAME_SIZE);
152
+ info->name[GPIO_MAX_NAME_SIZE] = '\0';
152
153
 
153
154
  info->used = !!(uapi_info->flags & GPIO_V2_LINE_FLAG_USED);
154
155
  strncpy(info->consumer, uapi_info->consumer, GPIO_MAX_NAME_SIZE);
156
+ info->consumer[GPIO_MAX_NAME_SIZE] = '\0';
155
157
 
156
158
  if (uapi_info->flags & GPIO_V2_LINE_FLAG_OUTPUT)
157
159
  info->direction = GPIOD_LINE_DIRECTION_OUTPUT;
@@ -99,7 +99,7 @@ gpiod_line_request_get_value(struct gpiod_line_request *request,
99
99
  unsigned int offset)
100
100
  {
101
101
  enum gpiod_line_value val;
102
- unsigned int ret;
102
+ int ret;
103
103
 
104
104
  assert(request);
105
105
 
@@ -0,0 +1 @@
1
+ 2.2.5
@@ -1 +0,0 @@
1
- 2.2.4
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes