Fix spidev path mismatch (#216)

Remove unnecessary call to get_spi_bus_path_number()
and use the bus and device passed to SPI_open().

Signed-off-by: Drew Fustini <drew@pdp7.com>
This commit is contained in:
Drew Fustini 2017-12-01 06:36:50 -06:00
parent 2d5e218f4c
commit 8dfbf64c36
No known key found for this signature in database
GPG key ID: 84D44A9317F1138E

View file

@ -703,7 +703,6 @@ static PyObject *
SPI_open(SPI *self, PyObject *args, PyObject *kwds)
{
int bus, device;
int bus_path;
int max_dt_length = 15;
char device_tree_name[max_dt_length];
char path[MAXPATH];
@ -722,14 +721,7 @@ SPI_open(SPI *self, PyObject *args, PyObject *kwds)
return NULL;
}
bus_path = get_spi_bus_path_number(bus);
if (bus_path == -1) {
PyErr_SetString(PyExc_OverflowError,
"Unable to find loaded spi bus path.");
return NULL;
}
if (snprintf(path, MAXPATH, "/dev/spidev%d.%d", bus_path, device) >= MAXPATH) {
if (snprintf(path, MAXPATH, "/dev/spidev%d.%d", bus, device) >= MAXPATH) {
PyErr_SetString(PyExc_OverflowError,
"Bus and/or device number is invalid.");
return NULL;