Retrieve SPI number (spi_host_device_t) from spi_device_handle_t

AloyseTech
Posts: 22
Joined: Mon Jul 22, 2019 2:29 pm

Retrieve SPI number (spi_host_device_t) from spi_device_handle_t

Postby AloyseTech » 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...

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;
}
Any advice?

Who is online

Users browsing this forum: Google [Bot] and 111 guests