---
name: "spi_alloc_master"
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_alloc_master"
---

# spi\_alloc\_master(9)

allocate SPI master controller

## NAME

spi\_alloc\_master - allocate SPI master controller

## SYNOPSIS

**struct spi\_master \* spi\_alloc\_master(struct device \*** *dev***, unsigned** *size***);**

## ARGUMENTS

*dev*

the controller, possibly using the platform\_bus

*size*

how much zeroed driver-private data to allocate; the pointer to this memory is in the driver\_data field of the returned device, accessible with **spi\_master\_get\_devdata**.

## CONTEXT

can sleep

## DESCRIPTION

This call is used only by SPI master controller drivers, which are the only ones directly touching chip registers. It's how they allocate an spi\_master structure, prior to calling **spi\_register\_master**.

This must be called from context that can sleep. It returns the SPI master structure on success, else NULL.

The caller is responsible for assigning the bus number and initializing the master's methods before calling **spi\_register\_master**; and (after errors adding the device) calling **spi\_master\_put** to prevent a memory leak.

## COPYRIGHT
