Retrieve SPI number (spi_host_device_t) from spi_device_handle_t
Posted: Tue Nov 17, 2020 9:45 pm
Hi,
I'm trying to retrieve the SPI number (spi_host_device_t) from a spi_device_handle_t to free it (spi_bus_free) at closing of a driver.
I've not managed to do it without trying to de-reference the handle...
Any advice?
I'm trying to retrieve the SPI number (spi_host_device_t) from a spi_device_handle_t to free it (spi_bus_free) at closing of a driver.
I've not managed to do it without trying to de-reference the handle...
Code: Select all
int SPI_Close(void *spiHandle)
{
spi_device_handle_t devHandle = *(spi_device_handle_t *)spiHandle;
spi_bus_remove_device(devHandle);
//todo: free spi bus, this fail since I'm dereferencing the pointer...
spi_bus_free((*devHandle)->host->id);
free((spi_device_handle_t *)spiHandle);
return 0;
}