Main Page | Class List | File List | Class Members | File Members

spi-core.c File Reference

SPI ( Serial Periphereal Interface ) subsystem core module. This module is responsible to registering and controlling spi algorithm drivers, adapters and target drivers. More...

#include <linux/module.h>
#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/proc_fs.h>
#include <linux/kmod.h>
#include <linux/init.h>
#include <linux/spi.h>
#include <asm/uaccess.h>

Include dependency graph for spi-core.c:

Include dependency graph

Defines

#define SPI_DATE   "20041011"
#define SPI_VERSION   "0.0.1"

Functions

 DECLARE_MUTEX (adapter_lock)
 LIST_HEAD (adapter_list)
 DECLARE_MUTEX (driver_lock)
 LIST_HEAD (driver_list)
int spiproc_init (void)
 initialize spi sybsystems entries in proc filesystem

int spiproc_cleanup (void)
ssize_t spiproc_bus_read (struct file *file, char *buf, size_t count, loff_t *ppos)
int read_bus_spi (char *buf, char **start, off_t offset, int len, int *eof, void *private)
int spi_add_adapter (struct spi_adapter *adap)
 Make the adapter available for use by clients using name adap->name. The adap->adapters list is initialised by this function.

int spi_del_adapter (struct spi_adapter *adap)
 Remove an adapter from the list of available SPI Bus adapters.

spi_adapter__spi_get_adapter (const char *name)
spi_adapterspi_get_adapter (const char *name)
 Obtain a spi_adapter structure for the specified adapter. If the adapter is not currently load, then load it. The adapter will be locked in core until all references are released via spi_put_adapter.

void spi_put_adapter (struct spi_adapter *adap)
int spi_add_driver (struct spi_driver *driver)
int spi_del_driver (struct spi_driver *driver)
spi_driver__spi_get_driver (const char *name)
spi_driverspi_get_driver (const char *name)
void spi_put_driver (struct spi_driver *drv)
int spi_attach_client (struct spi_client *client, const char *adap, const char *drv)
int spi_detach_client (struct spi_client *client)
int spi_transfer (struct spi_adapter *adap, struct spi_msg msgs[], int num)
int spi_write (struct spi_client *client, int addr, const char *buf, int len)
int spi_read (struct spi_client *client, int addr, char *buf, int len)
int spi_adapter_id (struct spi_adapter *adap)
int __init spi_init (void)
 EXPORT_SYMBOL (spi_add_adapter)
 EXPORT_SYMBOL (spi_del_adapter)
 EXPORT_SYMBOL (spi_get_adapter)
 EXPORT_SYMBOL (spi_put_adapter)
 EXPORT_SYMBOL (spi_add_driver)
 EXPORT_SYMBOL (spi_del_driver)
 EXPORT_SYMBOL (spi_get_driver)
 EXPORT_SYMBOL (spi_put_driver)
 EXPORT_SYMBOL (spi_attach_client)
 EXPORT_SYMBOL (spi_detach_client)
 EXPORT_SYMBOL (spi_transfer)
 EXPORT_SYMBOL (spi_write)
 EXPORT_SYMBOL (spi_read)
 EXPORT_SYMBOL (spi_adapter_id)

Variables

file_operations spiproc_operations
int spiproc_initialized = 0
int adap_id = 0

Detailed Description

SPI ( Serial Periphereal Interface ) subsystem core module. This module is responsible to registering and controlling spi algorithm drivers, adapters and target drivers.


Function Documentation

int read_bus_spi char *  buf,
char **  start,
off_t  offset,
int  len,
int *  eof,
void *  private
[static]
 

read_bus_spi - generates the output for /proc/bus/spi

Parameters:
buf: buffer for bytes to send
offset: offset from begining of the file
len: number of bytes to send
eof: end of file flag ( not used in current version )
private: not user
This function generates the output for /proc/bus/spi

Returns the number of bytes transferred, or negative error code.

int spi_adapter_id struct spi_adapter adap  ) 
 

spi_adapter_id This call returns a unique low identifier for each registered adapter

Parameters:
adap:spi_adapter 
Returns:
unique id or -1 if the adapter was not registered.

int spi_add_adapter struct spi_adapter adap  ) 
 

Make the adapter available for use by clients using name adap->name. The adap->adapters list is initialised by this function.

spi_add_adapter - register a new SPI bus adapter

Parameters:
adap: spi_adapter structure for the registering adapter

Returns:
0;

int spi_add_driver struct spi_driver driver  ) 
 

spi_add_driver - register a new SPI device driver

Parameters:
driver - driver structure to make available
Make the driver available for use by clients using name driver->name. The driver->drivers list is initialised by this function.

Returns 0;

int spi_attach_client struct spi_client client,
const char *  adap,
const char *  drv
 

spi_attach_client - attach a client to an adapter and driver

Parameters:
client: client structure to attach
adap: adapter (module) name
drv: driver (module) name
Attempt to attach a client (a user of a device driver) to a particular driver and adapter. If the specified driver or adapter aren't registered, request_module is used to load the relevant modules.

Returns 0 on success, or negative error code.

Here is the call graph for this function:

int spi_del_adapter struct spi_adapter adap  ) 
 

Remove an adapter from the list of available SPI Bus adapters.

spi_del_adapter - unregister a SPI bus adapter

Parameters:
adap: spi_adapter structure to unregister

Returns:
0;

int spi_del_driver struct spi_driver driver  ) 
 

spi_del_driver - unregister a SPI device driver

Parameters:
driver: driver to remove
Remove an driver from the list of available SPI Bus device drivers.

Returns 0;

int spi_detach_client struct spi_client client  ) 
 

spi_detach_client - detach a client from an adapter and driver

Parameters:
client: client structure to detach
Detach the client from the adapter and driver.

Here is the call graph for this function:

struct spi_adapter* spi_get_adapter const char *  name  ) 
 

Obtain a spi_adapter structure for the specified adapter. If the adapter is not currently load, then load it. The adapter will be locked in core until all references are released via spi_put_adapter.

spi_get_adapter - get a reference to an adapter

Parameters:
name: driver name
Returns:
pointer to spi_adapter struct or NULL if no adapter found

struct spi_driver* spi_get_driver const char *  name  ) 
 

spi_get_driver - get a reference to a driver

Parameters:
name: driver name
Obtain a spi_driver structure for the specified driver. If the driver is not currently load, then load it. The driver will be locked in core until all references are released via spi_put_driver.

void spi_put_adapter struct spi_adapter adap  ) 
 

spi_put_adapter - release a reference to an adapter

Parameters:
adap: driver to release reference
Indicate to the SPI core that you no longer require the adapter reference. The adapter module may be unloaded when there are no references to its data structure.

You must not use the reference after calling this function.

void spi_put_driver struct spi_driver drv  ) 
 

spi_put_driver - release a reference to a driver

Parameters:
drv: driver to release reference
Indicate to the SPI core that you no longer require the driver reference. The driver module may be unloaded when there are no references to its data structure.

You must not use the reference after calling this function.

int spi_read struct spi_client client,
int  addr,
char *  buf,
int  len
 

spi_read - receive data from a device on an SPI bus

Parameters:
client: registered client structure
addr: SPI bus address
buf: buffer for bytes to receive
len: number of bytes to receive
Receive len bytes from device address addr on the SPI bus described by client to a buffer pointed to by buf.

Returns the number of bytes transferred, or negative error code.

Here is the call graph for this function:

int spi_transfer struct spi_adapter adap,
struct spi_msg  msgs[],
int  num
 

spi_transfer - transfer information on an SPI bus

Parameters:
adap: adapter structure to perform transfer on
msgs: array of spi_msg structures describing transfer
num: number of spi_msg structures
Transfer the specified messages to/from a device on the SPI bus.

Returns number of messages successfully transferred, otherwise negative error code.

int spi_write struct spi_client client,
int  addr,
const char *  buf,
int  len
 

spi_write - send data to a device on an SPI bus

Parameters:
client: registered client structure
addr: SPI bus address
buf: buffer for bytes to send
len: number of bytes to send
Send len bytes pointed to by buf to device address addr on the SPI bus described by client.

Returns:
the number of bytes transferred, or negative error code.

Here is the call graph for this function:

ssize_t spiproc_bus_read struct file *  file,
char *  buf,
size_t  count,
loff_t *  ppos
[static]
 

spiproc_bus_read - generates the output for /proc/bus/spi-?

Parameters:
file: 
buf: buffer for bytes to send
offser: offset from begining of the file
count: number of bytes to send
ppos: This function generates the output for /proc/bus/spi-?
Returns the number of bytes transferred, or negative error code.

int spiproc_init void   )  [static]
 

initialize spi sybsystems entries in proc filesystem

spiproc_init

Here is the call graph for this function:


Variable Documentation

struct file_operations spiproc_operations [static]
 

Initial value:

 {
        read:           spiproc_bus_read,
}


Generated on Sun Oct 24 20:23:11 2004 for Linux SPI subsystem by doxygen 1.3.6