From: Bartosz Golaszewski Date: Fri, 13 Jul 2018 16:34:50 +0000 (+0200) Subject: bindings: python: move gpiod_ChipIsClosed() to the top of gpiodmodule.c X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=150d2ca90b991d426daf51d2981ff79746200bef;p=qemu-gpiodev%2Flibgpiod.git bindings: python: move gpiod_ChipIsClosed() to the top of gpiodmodule.c Unlike the other two helpers that are still declared at the top of the source file - this routine doesn't need to know any gpiod-specific type so move it up and remove the prototype. Signed-off-by: Bartosz Golaszewski --- diff --git a/bindings/python/gpiodmodule.c b/bindings/python/gpiodmodule.c index 0d10814..60f39c6 100644 --- a/bindings/python/gpiodmodule.c +++ b/bindings/python/gpiodmodule.c @@ -46,7 +46,6 @@ typedef struct { static gpiod_LineBulkObject *gpiod_LineToLineBulk(gpiod_LineObject *line); static gpiod_LineObject *gpiod_MakeLineObject(gpiod_ChipObject *owner, struct gpiod_line *line); -static bool gpiod_ChipIsClosed(gpiod_ChipObject *chip); enum { gpiod_LINE_REQ_DIR_AS_IS = 1, @@ -78,6 +77,17 @@ enum { gpiod_FALLING_EDGE, }; +static bool gpiod_ChipIsClosed(gpiod_ChipObject *chip) +{ + if (!chip->chip) { + PyErr_SetString(PyExc_ValueError, + "I/O operation on closed file"); + return true; + } + + return false; +} + static PyObject *gpiod_CallMethodPyArgs(PyObject *obj, const char *method, PyObject *args, PyObject *kwds) { @@ -1342,17 +1352,6 @@ static PyObject *gpiod_Chip_exit(gpiod_ChipObject *chip) return PyObject_CallMethod((PyObject *)chip, "close", ""); } -static bool gpiod_ChipIsClosed(gpiod_ChipObject *chip) -{ - if (!chip->chip) { - PyErr_SetString(PyExc_ValueError, - "I/O operation on closed file"); - return true; - } - - return false; -} - PyDoc_STRVAR(gpiod_Chip_name_doc, "Get the name of the GPIO chip");