Skip to Content
Linux Device Drivers Development
book

Linux Device Drivers Development

by John Madieu
October 2017
Intermediate to advanced
586 pages
14h 8m
English
Packt Publishing
Content preview from Linux Device Drivers Development

The probe() function

Its prototype is as follows:

static int probe(struct spi_device *spi) 

You may refer to Chapter 7, I2C Client Drivers, in order to see what is to be done in a probe function. The same steps apply here. Therefore, unlike an I2C driver, which has no capability to change the controller bus parameters (CS state, bit per word, clock) at runtime, an SPI driver can. You can set up the bus according to your device properties.

A typical SPI probe function would look like the following:

static int my_probe(struct spi_device *spi) { [...] /* declare your variable/structures */ /* bits_per_word cannot be configured in platform data */ spi->mode = SPI_MODE_0; /* SPI mode */ spi->max_speed_hz = 20000000; /* Max clock for the device ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Linux Device Drivers, Second Edition

Linux Device Drivers, Second Edition

Jonathan Corbet, Alessandro Rubini
Linux Device Drivers, 3rd Edition

Linux Device Drivers, 3rd Edition

Jonathan Corbet, Alessandro Rubini, Greg Kroah-Hartman

Publisher Resources

ISBN: 9781785280009Supplemental Content