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:
parent
2d5e218f4c
commit
8dfbf64c36
1 changed files with 1 additions and 9 deletions
|
|
@ -703,7 +703,6 @@ static PyObject *
|
||||||
SPI_open(SPI *self, PyObject *args, PyObject *kwds)
|
SPI_open(SPI *self, PyObject *args, PyObject *kwds)
|
||||||
{
|
{
|
||||||
int bus, device;
|
int bus, device;
|
||||||
int bus_path;
|
|
||||||
int max_dt_length = 15;
|
int max_dt_length = 15;
|
||||||
char device_tree_name[max_dt_length];
|
char device_tree_name[max_dt_length];
|
||||||
char path[MAXPATH];
|
char path[MAXPATH];
|
||||||
|
|
@ -722,14 +721,7 @@ SPI_open(SPI *self, PyObject *args, PyObject *kwds)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bus_path = get_spi_bus_path_number(bus);
|
if (snprintf(path, MAXPATH, "/dev/spidev%d.%d", bus, device) >= MAXPATH) {
|
||||||
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) {
|
|
||||||
PyErr_SetString(PyExc_OverflowError,
|
PyErr_SetString(PyExc_OverflowError,
|
||||||
"Bus and/or device number is invalid.");
|
"Bus and/or device number is invalid.");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue