---
name: "spi_setup"
section: "9"
platform: "linux"
package: "linux-manual-3.16"
version: "3.16.56-1+deb8u1"
release: "Debian 8 (Jessie)"
platforms: ["linux"]
url: "https://new.carta.tech/spi_setup"
---

# spi\_setup(9)

setup SPI mode and clock rate

## NAME

spi\_setup - setup SPI mode and clock rate

## SYNOPSIS

**int spi\_setup(struct spi\_device \*** *spi***);**

## ARGUMENTS

*spi*

the device whose settings are being modified

## CONTEXT

can sleep, and no requests are queued to the device

## DESCRIPTION

SPI protocol drivers may need to update the transfer mode if the device doesn't work with its default. They may likewise need to update clock rates or word sizes from initial values. This function changes those settings, and must be called from a context that can sleep. Except for SPI\_CS\_HIGH, which takes effect immediately, the changes take effect the next time the device is selected and data is transferred to or from it. When this function returns, the spi device is deselected.

Note that this call will fail if the protocol driver specifies an option that the underlying controller or its driver does not support. For example, not all hardware supports wire transfers using nine bit words, LSB-first wire encoding, or active-high chipselects.

## COPYRIGHT
