@@ -62,21 +62,21 @@ GPIOD_CXX_API ::std::string chip::name(void) const
{
this->throw_if_noref();
- return ::std::string(::gpiod_chip_name(this->_m_chip.get()));
+ return ::std::string(::gpiod_chip_get_name(this->_m_chip.get()));
}
GPIOD_CXX_API ::std::string chip::label(void) const
{
this->throw_if_noref();
- return ::std::string(::gpiod_chip_label(this->_m_chip.get()));
+ return ::std::string(::gpiod_chip_get_label(this->_m_chip.get()));
}
GPIOD_CXX_API unsigned int chip::num_lines(void) const
{
this->throw_if_noref();
- return ::gpiod_chip_num_lines(this->_m_chip.get());
+ return ::gpiod_chip_get_num_lines(this->_m_chip.get());
}
GPIOD_CXX_API line chip::get_line(unsigned int offset) const
@@ -1918,9 +1918,9 @@ static PyObject *gpiod_Chip_repr(gpiod_ChipObject *self)
return NULL;
return PyUnicode_FromFormat("'%s /%s/ %u lines'",
- gpiod_chip_name(self->chip),
- gpiod_chip_label(self->chip),
- gpiod_chip_num_lines(self->chip));
+ gpiod_chip_get_name(self->chip),
+ gpiod_chip_get_label(self->chip),
+ gpiod_chip_get_num_lines(self->chip));
}
PyDoc_STRVAR(gpiod_Chip_close_doc,
@@ -1971,7 +1971,7 @@ static PyObject *gpiod_Chip_name(gpiod_ChipObject *self,
if (gpiod_ChipIsClosed(self))
return NULL;
- return PyUnicode_FromFormat("%s", gpiod_chip_name(self->chip));
+ return PyUnicode_FromFormat("%s", gpiod_chip_get_name(self->chip));
}
PyDoc_STRVAR(gpiod_Chip_label_doc,
@@ -1985,7 +1985,7 @@ static PyObject *gpiod_Chip_label(gpiod_ChipObject *self,
if (gpiod_ChipIsClosed(self))
return NULL;
- return PyUnicode_FromFormat("%s", gpiod_chip_label(self->chip));
+ return PyUnicode_FromFormat("%s", gpiod_chip_get_label(self->chip));
}
PyDoc_STRVAR(gpiod_Chip_num_lines_doc,
@@ -1999,7 +1999,7 @@ static PyObject *gpiod_Chip_num_lines(gpiod_ChipObject *self,
if (gpiod_ChipIsClosed(self))
return NULL;
- return Py_BuildValue("I", gpiod_chip_num_lines(self->chip));
+ return Py_BuildValue("I", gpiod_chip_get_num_lines(self->chip));
}
static gpiod_LineObject *
@@ -2381,7 +2381,7 @@ static gpiod_LineObject *gpiod_LineIter_next(gpiod_LineIterObject *self)
{
struct gpiod_line *line;
- if (self->offset == gpiod_chip_num_lines(self->owner->chip))
+ if (self->offset == gpiod_chip_get_num_lines(self->owner->chip))
return NULL; /* Last element. */
line = gpiod_chip_get_line(self->owner->chip, self->offset++);
@@ -94,21 +94,21 @@ void gpiod_chip_unref(struct gpiod_chip *chip);
* @param chip The GPIO chip object.
* @return Pointer to a human-readable string containing the chip name.
*/
-const char *gpiod_chip_name(struct gpiod_chip *chip);
+const char *gpiod_chip_get_name(struct gpiod_chip *chip);
/**
* @brief Get the GPIO chip label as represented in the kernel.
* @param chip The GPIO chip object.
* @return Pointer to a human-readable string containing the chip label.
*/
-const char *gpiod_chip_label(struct gpiod_chip *chip);
+const char *gpiod_chip_get_label(struct gpiod_chip *chip);
/**
* @brief Get the number of GPIO lines exposed by this chip.
* @param chip The GPIO chip object.
* @return Number of GPIO lines.
*/
-unsigned int gpiod_chip_num_lines(struct gpiod_chip *chip);
+unsigned int gpiod_chip_get_num_lines(struct gpiod_chip *chip);
/**
* @brief Get the handle to the GPIO line at given offset.
@@ -335,17 +335,17 @@ GPIOD_API void gpiod_chip_unref(struct gpiod_chip *chip)
free(chip);
}
-GPIOD_API const char *gpiod_chip_name(struct gpiod_chip *chip)
+GPIOD_API const char *gpiod_chip_get_name(struct gpiod_chip *chip)
{
return chip->name;
}
-GPIOD_API const char *gpiod_chip_label(struct gpiod_chip *chip)
+GPIOD_API const char *gpiod_chip_get_label(struct gpiod_chip *chip)
{
return chip->label;
}
-GPIOD_API unsigned int gpiod_chip_num_lines(struct gpiod_chip *chip)
+GPIOD_API unsigned int gpiod_chip_get_num_lines(struct gpiod_chip *chip)
{
return chip->num_lines;
}
@@ -45,11 +45,11 @@ gpiod_chip_get_all_lines(struct gpiod_chip *chip)
struct gpiod_line *line;
unsigned int offset;
- bulk = gpiod_line_bulk_new(gpiod_chip_num_lines(chip));
+ bulk = gpiod_line_bulk_new(gpiod_chip_get_num_lines(chip));
if (!bulk)
return NULL;
- for (offset = 0; offset < gpiod_chip_num_lines(chip); offset++) {
+ for (offset = 0; offset < gpiod_chip_get_num_lines(chip); offset++) {
line = gpiod_chip_get_line(chip, offset);
if (!line) {
gpiod_line_bulk_free(bulk);
@@ -68,7 +68,7 @@ GPIOD_API int gpiod_chip_find_line(struct gpiod_chip *chip, const char *name)
struct gpiod_line *line;
const char *tmp;
- num_lines = gpiod_chip_num_lines(chip);
+ num_lines = gpiod_chip_get_num_lines(chip);
for (offset = 0; offset < num_lines; offset++) {
line = gpiod_chip_get_line(chip, offset);
@@ -63,9 +63,12 @@ GPIOD_TEST_CASE(get_name, 0, { 8, 8, 8})
g_assert_nonnull(chip2);
gpiod_test_return_if_failed();
- g_assert_cmpstr(gpiod_chip_name(chip0), ==, gpiod_test_chip_name(0));
- g_assert_cmpstr(gpiod_chip_name(chip1), ==, gpiod_test_chip_name(1));
- g_assert_cmpstr(gpiod_chip_name(chip2), ==, gpiod_test_chip_name(2));
+ g_assert_cmpstr(gpiod_chip_get_name(chip0), ==,
+ gpiod_test_chip_name(0));
+ g_assert_cmpstr(gpiod_chip_get_name(chip1), ==,
+ gpiod_test_chip_name(1));
+ g_assert_cmpstr(gpiod_chip_get_name(chip2), ==,
+ gpiod_test_chip_name(2));
}
GPIOD_TEST_CASE(get_label, 0, { 8, 8, 8})
@@ -83,9 +86,9 @@ GPIOD_TEST_CASE(get_label, 0, { 8, 8, 8})
g_assert_nonnull(chip2);
gpiod_test_return_if_failed();
- g_assert_cmpstr(gpiod_chip_label(chip0), ==, "gpio-mockup-A");
- g_assert_cmpstr(gpiod_chip_label(chip1), ==, "gpio-mockup-B");
- g_assert_cmpstr(gpiod_chip_label(chip2), ==, "gpio-mockup-C");
+ g_assert_cmpstr(gpiod_chip_get_label(chip0), ==, "gpio-mockup-A");
+ g_assert_cmpstr(gpiod_chip_get_label(chip1), ==, "gpio-mockup-B");
+ g_assert_cmpstr(gpiod_chip_get_label(chip2), ==, "gpio-mockup-C");
}
GPIOD_TEST_CASE(num_lines, 0, { 1, 4, 8, 16, 32 })
@@ -109,11 +112,11 @@ GPIOD_TEST_CASE(num_lines, 0, { 1, 4, 8, 16, 32 })
g_assert_nonnull(chip4);
gpiod_test_return_if_failed();
- g_assert_cmpuint(gpiod_chip_num_lines(chip0), ==, 1);
- g_assert_cmpuint(gpiod_chip_num_lines(chip1), ==, 4);
- g_assert_cmpuint(gpiod_chip_num_lines(chip2), ==, 8);
- g_assert_cmpuint(gpiod_chip_num_lines(chip3), ==, 16);
- g_assert_cmpuint(gpiod_chip_num_lines(chip4), ==, 32);
+ g_assert_cmpuint(gpiod_chip_get_num_lines(chip0), ==, 1);
+ g_assert_cmpuint(gpiod_chip_get_num_lines(chip1), ==, 4);
+ g_assert_cmpuint(gpiod_chip_get_num_lines(chip2), ==, 8);
+ g_assert_cmpuint(gpiod_chip_get_num_lines(chip3), ==, 16);
+ g_assert_cmpuint(gpiod_chip_get_num_lines(chip4), ==, 32);
}
GPIOD_TEST_CASE(get_line, 0, { 16 })
@@ -76,9 +76,9 @@ int main(int argc, char **argv)
}
printf("%s [%s] (%u lines)\n",
- gpiod_chip_name(chip),
- gpiod_chip_label(chip),
- gpiod_chip_num_lines(chip));
+ gpiod_chip_get_name(chip),
+ gpiod_chip_get_label(chip),
+ gpiod_chip_get_num_lines(chip));
gpiod_chip_unref(chip);
free(entries[i]);
@@ -76,7 +76,7 @@ int main(int argc, char **argv)
offset = gpiod_chip_find_line(chip, argv[0]);
if (offset >= 0) {
printf("%s %u\n",
- gpiod_chip_name(chip), offset);
+ gpiod_chip_get_name(chip), offset);
gpiod_chip_unref(chip);
return EXIT_SUCCESS;
}
@@ -130,9 +130,9 @@ static void list_lines(struct gpiod_chip *chip)
int direction;
printf("%s - %u lines:\n",
- gpiod_chip_name(chip), gpiod_chip_num_lines(chip));
+ gpiod_chip_get_name(chip), gpiod_chip_get_num_lines(chip));
- for (offset = 0; offset < gpiod_chip_num_lines(chip); offset++) {
+ for (offset = 0; offset < gpiod_chip_get_num_lines(chip); offset++) {
line = gpiod_chip_get_line(chip, offset);
if (!line)
die_perror("unable to retrieve the line object from chip");
In v2 API all getters will be called using the following pattern: gpiod_<object>_get_<what> Apply this to already existing getters for gpiod_chip. Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl> --- bindings/cxx/chip.cpp | 6 +++--- bindings/python/gpiodmodule.c | 14 +++++++------- include/gpiod.h | 6 +++--- lib/core.c | 6 +++--- lib/helpers.c | 6 +++--- tests/tests-chip.c | 25 ++++++++++++++----------- tools/gpiodetect.c | 6 +++--- tools/gpiofind.c | 2 +- tools/gpioinfo.c | 4 ++-- 9 files changed, 39 insertions(+), 36 deletions(-)