ali_cr8
ali_cr8

Reputation: 25

How to decode struct pointer with function?

I know how struct pointers work in general. But for struct spi_controller * spi_busnum_to_master(u16 bus_num),

  1. What is holding the address of the struct spi_controller it is pointing towards ?
  2. Can someone decode the logic of this declaration?. ( this style creating struct pointers)

From my understanding, a struct pointer is to enable a variable hold the address of some structure that it points to.

Upvotes: 0

Views: 121

Answers (1)

Eric Postpischil
Eric Postpischil

Reputation: 223389

struct spi_controller * spi_busnum_to_master(u16 bus_num) declares spi_busnum_to_master to be a function taking a parameter of type u16 and returning a pointer to struct spi_controller.

The return value is passed by whatever method is defined by the Application Binary Interface for the target platform. Often it is in a processor register.

Upvotes: 1

Related Questions