@@ -30,11 +30,6 @@ namespace {
return ::gpiod_chip_open_by_name(device.c_str());
}
-::gpiod_chip* open_by_label(const ::std::string& device)
-{
- return ::gpiod_chip_open_by_label(device.c_str());
-}
-
::gpiod_chip* open_by_number(const ::std::string& device)
{
return ::gpiod_chip_open_by_number(::std::stoul(device));
@@ -46,7 +41,6 @@ const ::std::map<int, open_func> open_funcs = {
{ chip::OPEN_LOOKUP, open_lookup, },
{ chip::OPEN_BY_PATH, open_by_path, },
{ chip::OPEN_BY_NAME, open_by_name, },
- { chip::OPEN_BY_LABEL, open_by_label, },
{ chip::OPEN_BY_NUMBER, open_by_number, },
};
@@ -190,8 +190,6 @@ public:
/**< Assume the string is a path to the GPIO chardev. */
OPEN_BY_NAME,
/**< Assume the string is the name of the chip */
- OPEN_BY_LABEL,
- /**< Assume the string is the label of the GPIO chip. */
OPEN_BY_NUMBER,
/**< Assume the string is the number of the GPIO chip. */
};
@@ -28,11 +28,6 @@ TEST_CASE("GPIO chip device can be opened in different modes", "[chip]")
::gpiod::chip::OPEN_BY_PATH));
}
- SECTION("open by label")
- {
- REQUIRE_NOTHROW(::gpiod::chip("gpio-mockup-B", ::gpiod::chip::OPEN_BY_LABEL));
- }
-
SECTION("open by number")
{
REQUIRE_NOTHROW(::gpiod::chip(::std::to_string(mockup::instance().chip_num(1)),
@@ -54,11 +49,6 @@ TEST_CASE("GPIO chip device can be opened with implicit lookup", "[chip]")
REQUIRE_NOTHROW(::gpiod::chip(mockup::instance().chip_path(1)));
}
- SECTION("lookup by label")
- {
- REQUIRE_NOTHROW(::gpiod::chip("gpio-mockup-B"));
- }
-
SECTION("lookup by number")
{
REQUIRE_NOTHROW(::gpiod::chip(::std::to_string(mockup::instance().chip_num(1))));
@@ -84,11 +74,6 @@ TEST_CASE("GPIO chip can be opened with the open() method in different modes", "
::gpiod::chip::OPEN_BY_PATH));
}
- SECTION("open by label")
- {
- REQUIRE_NOTHROW(chip.open("gpio-mockup-B", ::gpiod::chip::OPEN_BY_LABEL));
- }
-
SECTION("open by number")
{
REQUIRE_NOTHROW(chip.open(::std::to_string(mockup::instance().chip_num(1)),
@@ -126,11 +111,6 @@ TEST_CASE("GPIO chip can be opened with the open() method with implicit lookup",
REQUIRE_NOTHROW(chip.open(mockup::instance().chip_path(1)));
}
- SECTION("lookup by label")
- {
- REQUIRE_NOTHROW(chip.open("gpio-mockup-B"));
- }
-
SECTION("lookup by number")
{
REQUIRE_NOTHROW(chip.open(::std::to_string(mockup::instance().chip_num(1))));
@@ -1961,7 +1961,6 @@ enum {
gpiod_OPEN_LOOKUP = 1,
gpiod_OPEN_BY_NAME,
gpiod_OPEN_BY_PATH,
- gpiod_OPEN_BY_LABEL,
gpiod_OPEN_BY_NUMBER,
};
@@ -1987,9 +1986,6 @@ static int gpiod_Chip_init(gpiod_ChipObject *self,
case gpiod_OPEN_BY_PATH:
self->chip = gpiod_chip_open(descr);
break;
- case gpiod_OPEN_BY_LABEL:
- self->chip = gpiod_chip_open_by_label(descr);
- break;
case gpiod_OPEN_BY_NUMBER:
self->chip = gpiod_chip_open_by_number(atoi(descr));
break;
@@ -2503,10 +2499,10 @@ PyDoc_STRVAR(gpiod_ChipType_doc,
"The Chip object's constructor takes a description string as argument the\n"
"meaning of which depends on the second, optional parameter which defines\n"
"the way the description string should be interpreted. The available\n"
-"options are: OPEN_BY_LABEL, OPEN_BY_NAME, OPEN_BY_NUMBER, OPEN_BY_PATH,\n"
-"and OPEN_LOOKUP. The last option means that libgpiod should open the chip\n"
-"based on the best guess what the path is. This is also the default if the\n"
-"second argument is missing.\n"
+"options are: OPEN_BY_NAME, OPEN_BY_NUMBER, OPEN_BY_PATH and OPEN_LOOKUP.\n"
+"The last option means that libgpiod should open the chip based on the best\n"
+"guess what the path is. This is also the default if the second argument is\n"
+"missing.\n"
"\n"
"Callers must close the chip by calling the close() method when it's no\n"
"longer used.\n"
@@ -2786,11 +2782,6 @@ static gpiod_ConstDescr gpiod_ConstList[] = {
.name = "OPEN_BY_NAME",
.val = gpiod_OPEN_BY_NAME,
},
- {
- .typeobj = &gpiod_ChipType,
- .name = "OPEN_BY_LABEL",
- .val = gpiod_OPEN_BY_LABEL,
- },
{
.typeobj = &gpiod_ChipType,
.name = "OPEN_BY_NUMBER",
@@ -96,10 +96,6 @@ class ChipOpen(MockupTestCase):
gpiod.Chip.OPEN_BY_NUMBER) as chip:
self.assertEqual(chip.name(), mockup.chip_name(1))
- def test_open_chip_by_label(self):
- with gpiod.Chip('gpio-mockup-B', gpiod.Chip.OPEN_BY_LABEL) as chip:
- self.assertEqual(chip.name(), mockup.chip_name(1))
-
def test_lookup_chip_by_name(self):
with gpiod.Chip(mockup.chip_name(1)) as chip:
self.assertEqual(chip.name(), mockup.chip_name(1))
@@ -112,10 +108,6 @@ class ChipOpen(MockupTestCase):
with gpiod.Chip('{}'.format(mockup.chip_num(1))) as chip:
self.assertEqual(chip.name(), mockup.chip_name(1))
- def test_lookup_chip_by_label(self):
- with gpiod.Chip('gpio-mockup-B') as chip:
- self.assertEqual(chip.name(), mockup.chip_name(1))
-
def test_nonexistent_chip(self):
with self.assertRaises(FileNotFoundError):
chip = gpiod.Chip('nonexistent-chip')
@@ -103,24 +103,14 @@ struct gpiod_chip *gpiod_chip_open_by_name(const char *name) GPIOD_API;
*/
struct gpiod_chip *gpiod_chip_open_by_number(unsigned int num) GPIOD_API;
-/**
- * @brief Open a gpiochip by label.
- * @param label Label of the gpiochip to open.
- * @return GPIO chip handle or NULL if the chip with given label was not found
- * or an error occured.
- * @note If the chip cannot be found but no other error occurred, errno is set
- * to ENOENT.
- */
-struct gpiod_chip *gpiod_chip_open_by_label(const char *label) GPIOD_API;
-
/**
* @brief Open a gpiochip based on the best guess what the path is.
* @param descr String describing the gpiochip.
* @return GPIO chip handle or NULL if an error occurred.
*
* This routine tries to figure out whether the user passed it the path to the
- * GPIO chip, its name, label or number as a string. Then it tries to open it
- * using one of the gpiod_chip_open** variants.
+ * GPIO chip, its name or number as a string. Then it tries to open it using
+ * one of the gpiod_chip_open** variants.
*/
struct gpiod_chip *gpiod_chip_open_lookup(const char *descr) GPIOD_API;
@@ -56,28 +56,6 @@ struct gpiod_chip *gpiod_chip_open_by_number(unsigned int num)
return chip;
}
-struct gpiod_chip *gpiod_chip_open_by_label(const char *label)
-{
- struct gpiod_chip_iter *iter;
- struct gpiod_chip *chip;
-
- iter = gpiod_chip_iter_new();
- if (!iter)
- return NULL;
-
- gpiod_foreach_chip(iter, chip) {
- if (strcmp(label, gpiod_chip_label(chip)) == 0) {
- gpiod_chip_iter_free_noclose(iter);
- return chip;
- }
- }
-
- errno = ENOENT;
- gpiod_chip_iter_free(iter);
-
- return NULL;
-}
-
struct gpiod_chip *gpiod_chip_open_lookup(const char *descr)
{
struct gpiod_chip *chip;
@@ -85,13 +63,10 @@ struct gpiod_chip *gpiod_chip_open_lookup(const char *descr)
if (isuint(descr)) {
chip = gpiod_chip_open_by_number(strtoul(descr, NULL, 10));
} else {
- chip = gpiod_chip_open_by_label(descr);
- if (!chip) {
- if (strncmp(descr, "/dev/", 5))
- chip = gpiod_chip_open_by_name(descr);
- else
- chip = gpiod_chip_open(descr);
- }
+ if (strncmp(descr, "/dev/", 5))
+ chip = gpiod_chip_open_by_name(descr);
+ else
+ chip = gpiod_chip_open(descr);
}
return chip;
@@ -68,28 +68,8 @@ GPIOD_TEST_CASE(open_by_number_good, 0, { 8 })
g_assert_nonnull(chip);
}
-GPIOD_TEST_CASE(open_by_label_good, 0, { 4, 4, 4, 4, 4 })
-{
- g_autoptr(gpiod_chip_struct) chip = NULL;
-
- chip = gpiod_chip_open_by_label("gpio-mockup-D");
- g_assert_nonnull(chip);
- gpiod_test_return_if_failed();
- g_assert_cmpstr(gpiod_chip_name(chip), ==, gpiod_test_chip_name(3));
-}
-
-GPIOD_TEST_CASE(open_by_label_bad, 0, { 4, 4, 4, 4, 4 })
-{
- struct gpiod_chip *chip;
-
- chip = gpiod_chip_open_by_label("nonexistent_gpio_chip");
- g_assert_null(chip);
- g_assert_cmpint(errno, ==, ENOENT);
-}
-
GPIOD_TEST_CASE(open_lookup_good, 0, { 8, 8, 8})
{
- g_autoptr(gpiod_chip_struct) chip_by_label = NULL;
g_autoptr(gpiod_chip_struct) chip_by_name = NULL;
g_autoptr(gpiod_chip_struct) chip_by_path = NULL;
g_autoptr(gpiod_chip_struct) chip_by_num = NULL;
@@ -99,12 +79,10 @@ GPIOD_TEST_CASE(open_lookup_good, 0, { 8, 8, 8})
chip_by_name = gpiod_chip_open_lookup(gpiod_test_chip_name(1));
chip_by_path = gpiod_chip_open_lookup(gpiod_test_chip_path(1));
chip_by_num = gpiod_chip_open_lookup(chip_num_str);
- chip_by_label = gpiod_chip_open_lookup("gpio-mockup-B");
g_assert_nonnull(chip_by_name);
g_assert_nonnull(chip_by_path);
g_assert_nonnull(chip_by_num);
- g_assert_nonnull(chip_by_label);
gpiod_test_return_if_failed();
g_assert_cmpstr(gpiod_chip_name(chip_by_name),
@@ -113,8 +91,6 @@ GPIOD_TEST_CASE(open_lookup_good, 0, { 8, 8, 8})
==, gpiod_test_chip_name(1));
g_assert_cmpstr(gpiod_chip_name(chip_by_num),
==, gpiod_test_chip_name(1));
- g_assert_cmpstr(gpiod_chip_name(chip_by_label),
- ==, gpiod_test_chip_name(1));
}
GPIOD_TEST_CASE(get_name, 0, { 8, 8, 8})