Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
core.c File Reference
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/nfc.h>
#include <net/genetlink.h>
#include "nfc.h"

Go to the source code of this file.

Macros

#define pr_fmt(fmt)   KBUILD_MODNAME ": %s: " fmt, __func__
 
#define VERSION   "0.1"
 
#define NFC_CHECK_PRES_FREQ_MS   2000
 

Functions

 DEFINE_MUTEX (nfc_devlist_mutex)
 
int nfc_dev_up (struct nfc_dev *dev)
 
int nfc_dev_down (struct nfc_dev *dev)
 
int nfc_start_poll (struct nfc_dev *dev, u32 im_protocols, u32 tm_protocols)
 
int nfc_stop_poll (struct nfc_dev *dev)
 
int nfc_dep_link_up (struct nfc_dev *dev, int target_index, u8 comm_mode)
 
int nfc_dep_link_down (struct nfc_dev *dev)
 
int nfc_dep_link_is_up (struct nfc_dev *dev, u32 target_idx, u8 comm_mode, u8 rf_mode)
 
 EXPORT_SYMBOL (nfc_dep_link_is_up)
 
int nfc_activate_target (struct nfc_dev *dev, u32 target_idx, u32 protocol)
 
int nfc_deactivate_target (struct nfc_dev *dev, u32 target_idx)
 
int nfc_data_exchange (struct nfc_dev *dev, u32 target_idx, struct sk_buff *skb, data_exchange_cb_t cb, void *cb_context)
 
int nfc_set_remote_general_bytes (struct nfc_dev *dev, u8 *gb, u8 gb_len)
 
 EXPORT_SYMBOL (nfc_set_remote_general_bytes)
 
u8nfc_get_local_general_bytes (struct nfc_dev *dev, size_t *gb_len)
 
 EXPORT_SYMBOL (nfc_get_local_general_bytes)
 
int nfc_tm_data_received (struct nfc_dev *dev, struct sk_buff *skb)
 
 EXPORT_SYMBOL (nfc_tm_data_received)
 
int nfc_tm_activated (struct nfc_dev *dev, u32 protocol, u8 comm_mode, u8 *gb, size_t gb_len)
 
 EXPORT_SYMBOL (nfc_tm_activated)
 
int nfc_tm_deactivated (struct nfc_dev *dev)
 
 EXPORT_SYMBOL (nfc_tm_deactivated)
 
struct sk_buffnfc_alloc_send_skb (struct nfc_dev *dev, struct sock *sk, unsigned int flags, unsigned int size, unsigned int *err)
 
struct sk_buffnfc_alloc_recv_skb (unsigned int size, gfp_t gfp)
 
 EXPORT_SYMBOL (nfc_alloc_recv_skb)
 
int nfc_targets_found (struct nfc_dev *dev, struct nfc_target *targets, int n_targets)
 
 EXPORT_SYMBOL (nfc_targets_found)
 
int nfc_target_lost (struct nfc_dev *dev, u32 target_idx)
 
 EXPORT_SYMBOL (nfc_target_lost)
 
void nfc_driver_failure (struct nfc_dev *dev, int err)
 
 EXPORT_SYMBOL (nfc_driver_failure)
 
 EXPORT_SYMBOL (nfc_class)
 
struct nfc_devnfc_get_device (unsigned int idx)
 
struct nfc_devnfc_allocate_device (struct nfc_ops *ops, u32 supported_protocols, int tx_headroom, int tx_tailroom)
 
 EXPORT_SYMBOL (nfc_allocate_device)
 
int nfc_register_device (struct nfc_dev *dev)
 
 EXPORT_SYMBOL (nfc_register_device)
 
void nfc_unregister_device (struct nfc_dev *dev)
 
 EXPORT_SYMBOL (nfc_unregister_device)
 
 subsys_initcall (nfc_init)
 
 module_exit (nfc_exit)
 
 MODULE_AUTHOR ("Lauro Ramos Venancio <[email protected]>")
 
 MODULE_DESCRIPTION ("NFC Core ver "VERSION)
 
 MODULE_VERSION (VERSION)
 
 MODULE_LICENSE ("GPL")
 
 MODULE_ALIAS_NETPROTO (PF_NFC)
 
 MODULE_ALIAS_GENL_FAMILY (NFC_GENL_NAME)
 

Variables

int nfc_devlist_generation
 
struct class nfc_class
 

Macro Definition Documentation

#define NFC_CHECK_PRES_FREQ_MS   2000

Definition at line 38 of file core.c.

#define pr_fmt (   fmt)    KBUILD_MODNAME ": %s: " fmt, __func__

Definition at line 24 of file core.c.

#define VERSION   "0.1"

Definition at line 36 of file core.c.

Function Documentation

DEFINE_MUTEX ( nfc_devlist_mutex  )
EXPORT_SYMBOL ( nfc_dep_link_is_up  )
EXPORT_SYMBOL ( nfc_set_remote_general_bytes  )
EXPORT_SYMBOL ( nfc_get_local_general_bytes  )
EXPORT_SYMBOL ( nfc_tm_data_received  )
EXPORT_SYMBOL ( nfc_tm_activated  )
EXPORT_SYMBOL ( nfc_tm_deactivated  )
EXPORT_SYMBOL ( nfc_alloc_recv_skb  )
EXPORT_SYMBOL ( nfc_targets_found  )
EXPORT_SYMBOL ( nfc_target_lost  )
EXPORT_SYMBOL ( nfc_driver_failure  )
EXPORT_SYMBOL ( nfc_class  )
EXPORT_SYMBOL ( nfc_allocate_device  )
EXPORT_SYMBOL ( nfc_register_device  )
EXPORT_SYMBOL ( nfc_unregister_device  )
MODULE_ALIAS_GENL_FAMILY ( NFC_GENL_NAME  )
MODULE_ALIAS_NETPROTO ( PF_NFC  )
MODULE_AUTHOR ( "Lauro Ramos Venancio <[email protected]>"  )
MODULE_DESCRIPTION ( "NFC Core ver VERSION)
module_exit ( nfc_exit  )
MODULE_LICENSE ( "GPL"  )
MODULE_VERSION ( VERSION  )
int nfc_activate_target ( struct nfc_dev dev,
u32  target_idx,
u32  protocol 
)

Definition at line 304 of file core.c.

struct sk_buff* nfc_alloc_recv_skb ( unsigned int  size,
gfp_t  gfp 
)
read

nfc_alloc_recv_skb - allocate a skb for data exchange responses

: size to allocate : gfp flags

Definition at line 540 of file core.c.

struct sk_buff* nfc_alloc_send_skb ( struct nfc_dev dev,
struct sock sk,
unsigned int  flags,
unsigned int  size,
unsigned int err 
)
read

nfc_alloc_send_skb - allocate a skb for data exchange responses

: size to allocate : gfp flags

Definition at line 517 of file core.c.

struct nfc_dev* nfc_allocate_device ( struct nfc_ops ops,
u32  supported_protocols,
int  tx_headroom,
int  tx_tailroom 
)
read

nfc_allocate_device - allocate a new nfc device

: device operations : NFC protocols supported by the device

Definition at line 752 of file core.c.

int nfc_data_exchange ( struct nfc_dev dev,
u32  target_idx,
struct sk_buff skb,
data_exchange_cb_t  cb,
void cb_context 
)

nfc_data_exchange - transceive data

: The nfc device that found the target : index of the target : data to be sent : callback called when the response is received : parameter for the callback function

The user must wait for the callback before calling this function again.

Definition at line 397 of file core.c.

int nfc_deactivate_target ( struct nfc_dev dev,
u32  target_idx 
)

nfc_deactivate_target - deactivate a nfc target

: The nfc device that found the target : index of the target that must be deactivated

Definition at line 351 of file core.c.

int nfc_dep_link_down ( struct nfc_dev dev)

Definition at line 252 of file core.c.

int nfc_dep_link_is_up ( struct nfc_dev dev,
u32  target_idx,
u8  comm_mode,
u8  rf_mode 
)

Definition at line 286 of file core.c.

int nfc_dep_link_up ( struct nfc_dev dev,
int  target_index,
u8  comm_mode 
)

Definition at line 205 of file core.c.

int nfc_dev_down ( struct nfc_dev dev)

nfc_dev_down - turn off the NFC device

: The nfc device to be turned off

Definition at line 84 of file core.c.

int nfc_dev_up ( struct nfc_dev dev)

nfc_dev_up - turn on the NFC device

: The nfc device to be turned on

The device remains up until the nfc_dev_down function is called.

Definition at line 50 of file core.c.

void nfc_driver_failure ( struct nfc_dev dev,
int  err 
)
inline

Definition at line 668 of file core.c.

struct nfc_dev* nfc_get_device ( unsigned int  idx)
read

Definition at line 735 of file core.c.

u8* nfc_get_local_general_bytes ( struct nfc_dev dev,
size_t gb_len 
)

Definition at line 454 of file core.c.

int nfc_register_device ( struct nfc_dev dev)

nfc_register_device - register a nfc device in the nfc subsystem

: The nfc device to register

Definition at line 803 of file core.c.

int nfc_set_remote_general_bytes ( struct nfc_dev dev,
u8 gb,
u8  gb_len 
)

Definition at line 443 of file core.c.

int nfc_start_poll ( struct nfc_dev dev,
u32  im_protocols,
u32  tm_protocols 
)

nfc_start_poll - start polling for nfc targets

: The nfc device that must start polling : bitset of nfc protocols that must be used for polling

The device remains polling for targets until a target is found or the nfc_stop_poll function is called.

Definition at line 126 of file core.c.

int nfc_stop_poll ( struct nfc_dev dev)

nfc_stop_poll - stop polling for nfc targets

: The nfc device that must stop polling

Definition at line 164 of file core.c.

int nfc_target_lost ( struct nfc_dev dev,
u32  target_idx 
)

nfc_target_lost - inform that an activated target went out of field

: The nfc device that had the activated target in field : the nfc index of the target

The device driver must call this function when the activated target goes out of the field. IMPORTANT: this function must not be called from an atomic context. In addition, it must also not be called from a context that would prevent the NFC Core to call other nfc ops entry point concurrently.

Definition at line 628 of file core.c.

int nfc_targets_found ( struct nfc_dev dev,
struct nfc_target targets,
int  n_targets 
)

nfc_targets_found - inform that targets were found

: The nfc device that found the targets : array of nfc targets found : targets array size

The device driver must call this function when one or many nfc targets are found. After calling this function, the device driver must stop polling for targets. NOTE: This function can be called with targets=NULL and n_targets=0 to notify a driver error, meaning that the polling operation cannot complete. IMPORTANT: this function must not be called from an atomic context. In addition, it must also not be called from a context that would prevent the NFC Core to call other nfc ops entry point concurrently.

Definition at line 571 of file core.c.

int nfc_tm_activated ( struct nfc_dev dev,
u32  protocol,
u8  comm_mode,
u8 gb,
size_t  gb_len 
)

Definition at line 474 of file core.c.

int nfc_tm_data_received ( struct nfc_dev dev,
struct sk_buff skb 
)

Definition at line 462 of file core.c.

int nfc_tm_deactivated ( struct nfc_dev dev)

Definition at line 503 of file core.c.

void nfc_unregister_device ( struct nfc_dev dev)

nfc_unregister_device - unregister a nfc device in the nfc subsystem

: The nfc device to unregister

Definition at line 835 of file core.c.

subsys_initcall ( nfc_init  )

Variable Documentation

struct class nfc_class
Initial value:
= {
.name = "nfc",
.dev_release = nfc_release,
}

Definition at line 721 of file core.c.

int nfc_devlist_generation

Definition at line 40 of file core.c.