Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
access.c File Reference
#include <linux/delay.h>
#include <linux/pci.h>
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/ioport.h>
#include <linux/wait.h>
#include "pci.h"

Go to the source code of this file.

Data Structures

struct  pci_vpd_pci22
 

Macros

#define PCI_byte_BAD   0
 
#define PCI_word_BAD   (pos & 1)
 
#define PCI_dword_BAD   (pos & 3)
 
#define PCI_OP_READ(size, type, len)
 
#define PCI_OP_WRITE(size, type, len)
 
#define PCI_USER_READ_CONFIG(size, type)
 
#define PCI_USER_WRITE_CONFIG(size, type)
 
#define PCI_VPD_PCI22_SIZE   (PCI_VPD_ADDR_MASK + 1)
 

Functions

 DEFINE_RAW_SPINLOCK (pci_lock)
 
 EXPORT_SYMBOL (pci_bus_read_config_byte)
 
 EXPORT_SYMBOL (pci_bus_read_config_word)
 
 EXPORT_SYMBOL (pci_bus_read_config_dword)
 
 EXPORT_SYMBOL (pci_bus_write_config_byte)
 
 EXPORT_SYMBOL (pci_bus_write_config_word)
 
 EXPORT_SYMBOL (pci_bus_write_config_dword)
 
struct pci_opspci_bus_set_ops (struct pci_bus *bus, struct pci_ops *ops)
 
 EXPORT_SYMBOL (pci_bus_set_ops)
 
ssize_t pci_read_vpd (struct pci_dev *dev, loff_t pos, size_t count, void *buf)
 
 EXPORT_SYMBOL (pci_read_vpd)
 
ssize_t pci_write_vpd (struct pci_dev *dev, loff_t pos, size_t count, const void *buf)
 
 EXPORT_SYMBOL (pci_write_vpd)
 
int pci_vpd_pci22_init (struct pci_dev *dev)
 
int pci_vpd_truncate (struct pci_dev *dev, size_t size)
 
 EXPORT_SYMBOL (pci_vpd_truncate)
 
void pci_cfg_access_lock (struct pci_dev *dev)
 
 EXPORT_SYMBOL_GPL (pci_cfg_access_lock)
 
bool pci_cfg_access_trylock (struct pci_dev *dev)
 
 EXPORT_SYMBOL_GPL (pci_cfg_access_trylock)
 
void pci_cfg_access_unlock (struct pci_dev *dev)
 
 EXPORT_SYMBOL_GPL (pci_cfg_access_unlock)
 
int pcie_capability_read_word (struct pci_dev *dev, int pos, u16 *val)
 
 EXPORT_SYMBOL (pcie_capability_read_word)
 
int pcie_capability_read_dword (struct pci_dev *dev, int pos, u32 *val)
 
 EXPORT_SYMBOL (pcie_capability_read_dword)
 
int pcie_capability_write_word (struct pci_dev *dev, int pos, u16 val)
 
 EXPORT_SYMBOL (pcie_capability_write_word)
 
int pcie_capability_write_dword (struct pci_dev *dev, int pos, u32 val)
 
 EXPORT_SYMBOL (pcie_capability_write_dword)
 
int pcie_capability_clear_and_set_word (struct pci_dev *dev, int pos, u16 clear, u16 set)
 
 EXPORT_SYMBOL (pcie_capability_clear_and_set_word)
 
int pcie_capability_clear_and_set_dword (struct pci_dev *dev, int pos, u32 clear, u32 set)
 
 EXPORT_SYMBOL (pcie_capability_clear_and_set_dword)
 

Macro Definition Documentation

#define PCI_byte_BAD   0

Definition at line 24 of file access.c.

#define PCI_dword_BAD   (pos & 3)

Definition at line 26 of file access.c.

#define PCI_OP_READ (   size,
  type,
  len 
)
Value:
int pci_bus_read_config_##size \
(struct pci_bus *bus, unsigned int devfn, int pos, type *value) \
{ \
int res; \
unsigned long flags; \
u32 data = 0; \
if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \
raw_spin_lock_irqsave(&pci_lock, flags); \
res = bus->ops->read(bus, devfn, pos, len, &data); \
*value = (type)data; \
raw_spin_unlock_irqrestore(&pci_lock, flags); \
return res; \
}

Definition at line 28 of file access.c.

#define PCI_OP_WRITE (   size,
  type,
  len 
)
Value:
int pci_bus_write_config_##size \
(struct pci_bus *bus, unsigned int devfn, int pos, type value) \
{ \
int res; \
unsigned long flags; \
if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \
raw_spin_lock_irqsave(&pci_lock, flags); \
res = bus->ops->write(bus, devfn, pos, len, value); \
raw_spin_unlock_irqrestore(&pci_lock, flags); \
return res; \
}

Definition at line 43 of file access.c.

#define PCI_USER_READ_CONFIG (   size,
  type 
)
Value:
int pci_user_read_config_##size \
(struct pci_dev *dev, int pos, type *val) \
{ \
int ret = 0; \
u32 data = -1; \
if (PCI_##size##_BAD) \
return -EINVAL; \
raw_spin_lock_irq(&pci_lock); \
pci_wait_cfg(dev); \
ret = dev->bus->ops->read(dev->bus, dev->devfn, \
pos, sizeof(type), &data); \
raw_spin_unlock_irq(&pci_lock); \
*val = (type)data; \
if (ret > 0) \
ret = -EINVAL; \
return ret; \
} \
EXPORT_SYMBOL_GPL(pci_user_read_config_##size);

Definition at line 147 of file access.c.

#define PCI_USER_WRITE_CONFIG (   size,
  type 
)
Value:
int pci_user_write_config_##size \
(struct pci_dev *dev, int pos, type val) \
{ \
int ret = -EIO; \
if (PCI_##size##_BAD) \
return -EINVAL; \
raw_spin_lock_irq(&pci_lock); \
pci_wait_cfg(dev); \
ret = dev->bus->ops->write(dev->bus, dev->devfn, \
pos, sizeof(type), val); \
raw_spin_unlock_irq(&pci_lock); \
if (ret > 0) \
ret = -EINVAL; \
return ret; \
} \
EXPORT_SYMBOL_GPL(pci_user_write_config_##size);

Definition at line 169 of file access.c.

#define PCI_VPD_PCI22_SIZE   (PCI_VPD_ADDR_MASK + 1)

Definition at line 197 of file access.c.

#define PCI_word_BAD   (pos & 1)

Definition at line 25 of file access.c.

Function Documentation

DEFINE_RAW_SPINLOCK ( pci_lock  )
EXPORT_SYMBOL ( pci_bus_read_config_byte  )
EXPORT_SYMBOL ( pci_bus_read_config_word  )
EXPORT_SYMBOL ( pci_bus_read_config_dword  )
EXPORT_SYMBOL ( pci_bus_write_config_byte  )
EXPORT_SYMBOL ( pci_bus_write_config_word  )
EXPORT_SYMBOL ( pci_bus_write_config_dword  )
EXPORT_SYMBOL ( pci_bus_set_ops  )
EXPORT_SYMBOL ( pci_read_vpd  )
EXPORT_SYMBOL ( pci_write_vpd  )
EXPORT_SYMBOL ( pci_vpd_truncate  )
EXPORT_SYMBOL ( pcie_capability_read_word  )
EXPORT_SYMBOL ( pcie_capability_read_dword  )
EXPORT_SYMBOL ( pcie_capability_write_word  )
EXPORT_SYMBOL ( pcie_capability_write_dword  )
EXPORT_SYMBOL_GPL ( pci_cfg_access_lock  )
EXPORT_SYMBOL_GPL ( pci_cfg_access_trylock  )
EXPORT_SYMBOL_GPL ( pci_cfg_access_unlock  )
struct pci_ops* pci_bus_set_ops ( struct pci_bus bus,
struct pci_ops ops 
)
read

pci_bus_set_ops - Set raw operations of pci bus : pci bus struct : new raw operations

Return previous raw operations

Definition at line 77 of file access.c.

void pci_cfg_access_lock ( struct pci_dev dev)

pci_cfg_access_lock - Lock PCI config reads/writes : pci device struct

When access is locked, any userspace reads or writes to config space and concurrent lock requests will sleep until access is allowed via pci_cfg_access_unlocked again.

Definition at line 415 of file access.c.

bool pci_cfg_access_trylock ( struct pci_dev dev)

pci_cfg_access_trylock - try to lock PCI config reads/writes : pci device struct

Same as pci_cfg_access_lock, but will return 0 if access is already locked, 1 otherwise. This function can be used from atomic contexts.

Definition at line 435 of file access.c.

void pci_cfg_access_unlock ( struct pci_dev dev)

pci_cfg_access_unlock - Unlock PCI config reads/writes : pci device struct

This function allows PCI config accesses to resume.

Definition at line 457 of file access.c.

ssize_t pci_read_vpd ( struct pci_dev dev,
loff_t  pos,
size_t  count,
void buf 
)

pci_read_vpd - Read one entry from Vital Product Data : pci device struct : offset in vpd space : number of bytes to read : pointer to where to store result

Definition at line 98 of file access.c.

int pci_vpd_pci22_init ( struct pci_dev dev)

Definition at line 362 of file access.c.

int pci_vpd_truncate ( struct pci_dev dev,
size_t  size 
)

pci_vpd_truncate - Set available Vital Product Data size : pci device struct : available memory in bytes

Adjust size of available VPD area.

Definition at line 390 of file access.c.

ssize_t pci_write_vpd ( struct pci_dev dev,
loff_t  pos,
size_t  count,
const void buf 
)

pci_write_vpd - Write entry to Vital Product Data : pci device struct : offset in vpd space : number of bytes to write : buffer containing write data

Definition at line 114 of file access.c.

int pcie_capability_clear_and_set_dword ( struct pci_dev dev,
int  pos,
u32  clear,
u32  set 
)

Definition at line 658 of file access.c.

int pcie_capability_clear_and_set_word ( struct pci_dev dev,
int  pos,
u16  clear,
u16  set 
)

Definition at line 641 of file access.c.

int pcie_capability_read_dword ( struct pci_dev dev,
int  pos,
u32 val 
)

Definition at line 588 of file access.c.

int pcie_capability_read_word ( struct pci_dev dev,
int  pos,
u16 val 
)

Definition at line 552 of file access.c.

int pcie_capability_write_dword ( struct pci_dev dev,
int  pos,
u32  val 
)

Definition at line 629 of file access.c.

int pcie_capability_write_word ( struct pci_dev dev,
int  pos,
u16  val 
)

Definition at line 617 of file access.c.