@@ -342,12 +342,6 @@ public:
*/
GPIOD_API void release(void) const;
- /**
- * @brief Check if this user has ownership of this line.
- * @return True if the user has ownership of this line, false otherwise.
- */
- GPIOD_API bool is_requested(void) const;
-
/**
* @brief Read the line value.
* @return Current value (0 or 1).
@@ -127,14 +127,6 @@ void line::release(void) const
bulk.release();
}
-bool line::is_requested(void) const
-{
- this->throw_if_null();
- line::chip_guard lock_chip(*this);
-
- return ::gpiod_line_is_requested(this->_m_line);
-}
-
/*
* REVISIT: Check the performance of get/set_value & event_wait compared to
* the C API. Creating a line_bulk object involves a memory allocation every
@@ -27,7 +27,6 @@ TEST_CASE("Line information can be correctly retrieved", "[line]")
REQUIRE(line.direction() == ::gpiod::line::DIRECTION_INPUT);
REQUIRE_FALSE(line.is_active_low());
REQUIRE(line.consumer().empty());
- REQUIRE_FALSE(line.is_requested());
REQUIRE_FALSE(line.is_used());
REQUIRE(line.drive() == ::gpiod::line::DRIVE_PUSH_PULL);
REQUIRE(line.bias() == ::gpiod::line::BIAS_UNKNOWN);
@@ -45,7 +44,6 @@ TEST_CASE("Line information can be correctly retrieved", "[line]")
REQUIRE(line.name() == "gpio-mockup-A-4");
REQUIRE(line.direction() == ::gpiod::line::DIRECTION_OUTPUT);
REQUIRE_FALSE(line.is_active_low());
- REQUIRE(line.is_requested());
REQUIRE(line.is_used());
REQUIRE(line.drive() == ::gpiod::line::DRIVE_PUSH_PULL);
REQUIRE(line.bias() == ::gpiod::line::BIAS_UNKNOWN);
@@ -65,7 +63,6 @@ TEST_CASE("Line information can be correctly retrieved", "[line]")
REQUIRE(line.name() == "gpio-mockup-A-4");
REQUIRE(line.direction() == ::gpiod::line::DIRECTION_OUTPUT);
REQUIRE(line.is_active_low());
- REQUIRE(line.is_requested());
REQUIRE(line.is_used());
REQUIRE(line.drive() == ::gpiod::line::DRIVE_OPEN_DRAIN);
REQUIRE(line.bias() == ::gpiod::line::BIAS_UNKNOWN);
@@ -84,7 +81,6 @@ TEST_CASE("Line information can be correctly retrieved", "[line]")
REQUIRE(line.name() == "gpio-mockup-A-4");
REQUIRE(line.direction() == ::gpiod::line::DIRECTION_OUTPUT);
REQUIRE_FALSE(line.is_active_low());
- REQUIRE(line.is_requested());
REQUIRE(line.is_used());
REQUIRE(line.drive() == ::gpiod::line::DRIVE_OPEN_SOURCE);
REQUIRE(line.bias() == ::gpiod::line::BIAS_UNKNOWN);
@@ -103,7 +99,6 @@ TEST_CASE("Line information can be correctly retrieved", "[line]")
REQUIRE(line.name() == "gpio-mockup-A-4");
REQUIRE(line.direction() == ::gpiod::line::DIRECTION_OUTPUT);
REQUIRE_FALSE(line.is_active_low());
- REQUIRE(line.is_requested());
REQUIRE(line.is_used());
REQUIRE(line.drive() == ::gpiod::line::DRIVE_PUSH_PULL);
REQUIRE(line.bias() == ::gpiod::line::BIAS_DISABLED);
@@ -122,7 +117,6 @@ TEST_CASE("Line information can be correctly retrieved", "[line]")
REQUIRE(line.name() == "gpio-mockup-A-4");
REQUIRE(line.direction() == ::gpiod::line::DIRECTION_OUTPUT);
REQUIRE_FALSE(line.is_active_low());;
- REQUIRE(line.is_requested());
REQUIRE(line.is_used());
REQUIRE(line.drive() == ::gpiod::line::DRIVE_PUSH_PULL);
REQUIRE(line.bias() == ::gpiod::line::BIAS_PULL_DOWN);
@@ -141,7 +135,6 @@ TEST_CASE("Line information can be correctly retrieved", "[line]")
REQUIRE(line.name() == "gpio-mockup-A-4");
REQUIRE(line.direction() == ::gpiod::line::DIRECTION_OUTPUT);
REQUIRE_FALSE(line.is_active_low());
- REQUIRE(line.is_requested());
REQUIRE(line.is_used());
REQUIRE(line.drive() == ::gpiod::line::DRIVE_PUSH_PULL);
REQUIRE(line.bias() == ::gpiod::line::BIAS_PULL_UP);
@@ -383,12 +376,10 @@ TEST_CASE("Exported line can be released", "[line]")
line.request(config);
- REQUIRE(line.is_requested());
REQUIRE(line.get_value() == 0);
line.release();
- REQUIRE_FALSE(line.is_requested());
REQUIRE_THROWS_AS(line.get_value(), ::std::system_error);
}
@@ -501,23 +501,6 @@ static PyObject *gpiod_Line_request(gpiod_LineObject *self,
return ret;
}
-PyDoc_STRVAR(gpiod_Line_is_requested_doc,
-"is_requested() -> boolean\n"
-"\n"
-"Check if this user has ownership of this line.");
-
-static PyObject *gpiod_Line_is_requested(gpiod_LineObject *self,
- PyObject *Py_UNUSED(ignored))
-{
- if (gpiod_ChipIsClosed(self->owner))
- return NULL;
-
- if (gpiod_line_is_requested(self->line))
- Py_RETURN_TRUE;
-
- Py_RETURN_FALSE;
-}
-
PyDoc_STRVAR(gpiod_Line_get_value_doc,
"get_value() -> integer\n"
"\n"
@@ -983,12 +966,6 @@ static PyMethodDef gpiod_Line_methods[] = {
.ml_flags = METH_VARARGS | METH_KEYWORDS,
.ml_doc = gpiod_Line_request_doc,
},
- {
- .ml_name = "is_requested",
- .ml_meth = (PyCFunction)gpiod_Line_is_requested,
- .ml_flags = METH_NOARGS,
- .ml_doc = gpiod_Line_is_requested_doc,
- },
{
.ml_name = "get_value",
.ml_meth = (PyCFunction)gpiod_Line_get_value,
@@ -204,7 +204,6 @@ class LineInfo(MockupTestCase):
self.assertFalse(line.is_active_low())
self.assertEqual(line.consumer(), None)
self.assertFalse(line.is_used())
- self.assertFalse(line.is_requested())
def test_exported_line(self):
with gpiod.Chip(mockup.chip_path(0)) as chip:
@@ -218,7 +217,6 @@ class LineInfo(MockupTestCase):
self.assertTrue(line.is_active_low())
self.assertEqual(line.consumer(), default_consumer)
self.assertTrue(line.is_used())
- self.assertTrue(line.is_requested())
def test_exported_line_with_flags(self):
with gpiod.Chip(mockup.chip_path(0)) as chip:
@@ -234,7 +232,6 @@ class LineInfo(MockupTestCase):
self.assertTrue(line.is_active_low())
self.assertEqual(line.consumer(), default_consumer)
self.assertTrue(line.is_used())
- self.assertTrue(line.is_requested())
self.assertEqual(line.drive(), gpiod.Line.DRIVE_OPEN_DRAIN)
self.assertEqual(line.bias(), gpiod.Line.BIAS_UNKNOWN)
@@ -251,7 +248,6 @@ class LineInfo(MockupTestCase):
self.assertFalse(line.is_active_low())
self.assertEqual(line.consumer(), default_consumer)
self.assertTrue(line.is_used())
- self.assertTrue(line.is_requested())
self.assertEqual(line.drive(), gpiod.Line.DRIVE_OPEN_DRAIN)
self.assertEqual(line.bias(), gpiod.Line.BIAS_UNKNOWN)
@@ -268,7 +264,6 @@ class LineInfo(MockupTestCase):
self.assertFalse(line.is_active_low())
self.assertEqual(line.consumer(), default_consumer)
self.assertTrue(line.is_used())
- self.assertTrue(line.is_requested())
self.assertEqual(line.drive(), gpiod.Line.DRIVE_OPEN_SOURCE)
self.assertEqual(line.bias(), gpiod.Line.BIAS_UNKNOWN)
@@ -285,7 +280,6 @@ class LineInfo(MockupTestCase):
self.assertFalse(line.is_active_low())
self.assertEqual(line.consumer(), default_consumer)
self.assertTrue(line.is_used())
- self.assertTrue(line.is_requested())
self.assertEqual(line.drive(), gpiod.Line.DRIVE_PUSH_PULL)
self.assertEqual(line.bias(), gpiod.Line.BIAS_DISABLED)
@@ -302,7 +296,6 @@ class LineInfo(MockupTestCase):
self.assertFalse(line.is_active_low())
self.assertEqual(line.consumer(), default_consumer)
self.assertTrue(line.is_used())
- self.assertTrue(line.is_requested())
self.assertEqual(line.drive(), gpiod.Line.DRIVE_PUSH_PULL)
self.assertEqual(line.bias(), gpiod.Line.BIAS_PULL_DOWN)
@@ -319,7 +312,6 @@ class LineInfo(MockupTestCase):
self.assertFalse(line.is_active_low())
self.assertEqual(line.consumer(), default_consumer)
self.assertTrue(line.is_used())
- self.assertTrue(line.is_requested())
self.assertEqual(line.drive(), gpiod.Line.DRIVE_PUSH_PULL)
self.assertEqual(line.bias(), gpiod.Line.BIAS_PULL_UP)
@@ -605,16 +597,6 @@ class LineRequestBehavior(MockupTestCase):
chip_sizes = ( 8, )
- def test_line_export_release(self):
- with gpiod.Chip(mockup.chip_path(0)) as chip:
- line = chip.get_line(3)
- line.request(consumer=default_consumer,
- type=gpiod.LINE_REQ_DIR_IN)
- self.assertTrue(line.is_requested())
- self.assertEqual(line.get_value(), 0)
- line.release()
- self.assertFalse(line.is_requested())
-
def test_line_request_twice_two_calls(self):
with gpiod.Chip(mockup.chip_path(0)) as chip:
line = chip.get_line(3)
@@ -647,10 +629,8 @@ class LineRequestBehavior(MockupTestCase):
with gpiod.Chip(mockup.chip_path(0)) as chip:
line = chip.get_line(2)
line.request(default_consumer)
- self.assertTrue(line.is_requested())
self.assertEqual(line.direction(), gpiod.Line.DIRECTION_INPUT)
line.release()
- self.assertFalse(line.is_requested())
#
# Iterator test cases
@@ -700,21 +700,6 @@ void gpiod_line_release(struct gpiod_line *line) GPIOD_API;
*/
void gpiod_line_release_bulk(struct gpiod_line_bulk *bulk) GPIOD_API;
-/**
- * @brief Check if the calling user has ownership of this line.
- * @param line GPIO line object.
- * @return True if given line was requested, false otherwise.
- */
-bool gpiod_line_is_requested(struct gpiod_line *line) GPIOD_API;
-
-/**
- * @brief Check if the calling user has neither requested ownership of this
- * line nor configured any event notifications.
- * @param line GPIO line object.
- * @return True if given line is free, false otherwise.
- */
-bool gpiod_line_is_free(struct gpiod_line *line) GPIOD_API;
-
/**
* @}
*
@@ -561,13 +561,19 @@ int gpiod_line_update(struct gpiod_line *line)
return 0;
}
+static bool line_is_requested(struct gpiod_line *line)
+{
+ return (line->state == LINE_REQUESTED_VALUES ||
+ line->state == LINE_REQUESTED_EVENTS);
+}
+
static bool line_bulk_all_requested(struct gpiod_line_bulk *bulk)
{
struct gpiod_line *line;
unsigned int idx;
line_bulk_foreach_line(bulk, line, idx) {
- if (!gpiod_line_is_requested(line)) {
+ if (!line_is_requested(line)) {
errno = EPERM;
return false;
}
@@ -591,21 +597,6 @@ static bool line_bulk_all_requested_values(struct gpiod_line_bulk *bulk)
return true;
}
-static bool line_bulk_all_free(struct gpiod_line_bulk *bulk)
-{
- struct gpiod_line *line;
- unsigned int idx;
-
- line_bulk_foreach_line(bulk, line, idx) {
- if (!gpiod_line_is_free(line)) {
- errno = EBUSY;
- return false;
- }
- }
-
- return true;
-}
-
static bool line_request_direction_is_valid(int direction)
{
if ((direction == GPIOD_LINE_REQUEST_DIRECTION_AS_IS) ||
@@ -872,9 +863,6 @@ int gpiod_line_request_bulk(struct gpiod_line_bulk *bulk,
const struct gpiod_line_request_config *config,
const int *vals)
{
- if (!line_bulk_all_free(bulk))
- return -1;
-
if (line_request_is_direction(config->request_type))
return line_request_values(bulk, config, vals);
else if (line_request_is_events(config->request_type))
@@ -904,17 +892,6 @@ void gpiod_line_release_bulk(struct gpiod_line_bulk *bulk)
}
}
-bool gpiod_line_is_requested(struct gpiod_line *line)
-{
- return (line->state == LINE_REQUESTED_VALUES ||
- line->state == LINE_REQUESTED_EVENTS);
-}
-
-bool gpiod_line_is_free(struct gpiod_line *line)
-{
- return line->state == LINE_FREE;
-}
-
int gpiod_line_get_value(struct gpiod_line *line)
{
struct gpiod_line_bulk bulk = BULK_SINGLE_LINE_INIT(line);