Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions | Variables
extcon-class.c File Reference
#include <linux/module.h>
#include <linux/types.h>
#include <linux/init.h>
#include <linux/device.h>
#include <linux/fs.h>
#include <linux/err.h>
#include <linux/extcon.h>
#include <linux/slab.h>
#include <linux/sysfs.h>

Go to the source code of this file.

Functions

int extcon_set_state (struct extcon_dev *edev, u32 state)
 
int extcon_update_state (struct extcon_dev *edev, u32 mask, u32 state)
 
 EXPORT_SYMBOL_GPL (extcon_update_state)
 
 EXPORT_SYMBOL_GPL (extcon_set_state)
 
int extcon_find_cable_index (struct extcon_dev *edev, const char *cable_name)
 
 EXPORT_SYMBOL_GPL (extcon_find_cable_index)
 
int extcon_get_cable_state_ (struct extcon_dev *edev, int index)
 
 EXPORT_SYMBOL_GPL (extcon_get_cable_state_)
 
int extcon_get_cable_state (struct extcon_dev *edev, const char *cable_name)
 
 EXPORT_SYMBOL_GPL (extcon_get_cable_state)
 
int extcon_set_cable_state_ (struct extcon_dev *edev, int index, bool cable_state)
 
 EXPORT_SYMBOL_GPL (extcon_set_cable_state_)
 
int extcon_set_cable_state (struct extcon_dev *edev, const char *cable_name, bool cable_state)
 
 EXPORT_SYMBOL_GPL (extcon_set_cable_state)
 
struct extcon_devextcon_get_extcon_dev (const char *extcon_name)
 
 EXPORT_SYMBOL_GPL (extcon_get_extcon_dev)
 
int extcon_register_interest (struct extcon_specific_cable_nb *obj, const char *extcon_name, const char *cable_name, struct notifier_block *nb)
 
int extcon_unregister_interest (struct extcon_specific_cable_nb *obj)
 
int extcon_register_notifier (struct extcon_dev *edev, struct notifier_block *nb)
 
 EXPORT_SYMBOL_GPL (extcon_register_notifier)
 
int extcon_unregister_notifier (struct extcon_dev *edev, struct notifier_block *nb)
 
 EXPORT_SYMBOL_GPL (extcon_unregister_notifier)
 
int extcon_dev_register (struct extcon_dev *edev, struct device *dev)
 
 EXPORT_SYMBOL_GPL (extcon_dev_register)
 
void extcon_dev_unregister (struct extcon_dev *edev)
 
 EXPORT_SYMBOL_GPL (extcon_dev_unregister)
 
 module_init (extcon_class_init)
 
 module_exit (extcon_class_exit)
 
 MODULE_AUTHOR ("Mike Lockwood <[email protected]>")
 
 MODULE_AUTHOR ("Donggeun Kim <[email protected]>")
 
 MODULE_AUTHOR ("MyungJoo Ham <[email protected]>")
 
 MODULE_DESCRIPTION ("External connector (extcon) class driver")
 
 MODULE_LICENSE ("GPL")
 

Variables

const char extcon_cable_name [][CABLE_NAME_MAX+1]
 

Function Documentation

EXPORT_SYMBOL_GPL ( extcon_update_state  )
EXPORT_SYMBOL_GPL ( extcon_set_state  )
EXPORT_SYMBOL_GPL ( extcon_find_cable_index  )
EXPORT_SYMBOL_GPL ( extcon_get_cable_state_  )
EXPORT_SYMBOL_GPL ( extcon_get_cable_state  )
EXPORT_SYMBOL_GPL ( extcon_set_cable_state_  )
EXPORT_SYMBOL_GPL ( extcon_set_cable_state  )
EXPORT_SYMBOL_GPL ( extcon_get_extcon_dev  )
EXPORT_SYMBOL_GPL ( extcon_register_notifier  )
EXPORT_SYMBOL_GPL ( extcon_unregister_notifier  )
EXPORT_SYMBOL_GPL ( extcon_dev_register  )
EXPORT_SYMBOL_GPL ( extcon_dev_unregister  )
int extcon_dev_register ( struct extcon_dev edev,
struct device dev 
)

extcon_dev_register() - Register a new extcon device : the new extcon device (should be allocated before calling) : the parent device for this extcon device.

Among the members of edev struct, please set the "user initializing data" in any case and set the "optional callbacks" if required. However, please do not set the values of "internal data", which are initialized by this function.

Definition at line 592 of file extcon-class.c.

void extcon_dev_unregister ( struct extcon_dev edev)

extcon_dev_unregister() - Unregister the extcon device. : the extcon device instance to be unregistered.

Note that this does not call kfree(edev) because edev was not allocated by this class.

Definition at line 798 of file extcon-class.c.

int extcon_find_cable_index ( struct extcon_dev edev,
const char cable_name 
)

extcon_find_cable_index() - Get the cable index based on the cable name. : the extcon device that has the cable. : cable name to be searched.

Note that accessing a cable state based on cable_index is faster than cable_name because using cable_name induces a loop with strncmp(). Thus, when get/set_cable_state is repeatedly used, using cable_index is recommended.

Definition at line 314 of file extcon-class.c.

int extcon_get_cable_state ( struct extcon_dev edev,
const char cable_name 
)

extcon_get_cable_state() - Get the status of a specific cable. : the extcon device that has the cable. : cable name.

Note that this is slower than extcon_get_cable_state_.

Definition at line 351 of file extcon-class.c.

int extcon_get_cable_state_ ( struct extcon_dev edev,
int  index 
)

extcon_get_cable_state_() - Get the status of a specific cable. : the extcon device that has the cable. : cable index that can be retrieved by extcon_find_cable_index().

Definition at line 335 of file extcon-class.c.

struct extcon_dev* extcon_get_extcon_dev ( const char extcon_name)
read

extcon_get_extcon_dev() - Get the extcon device instance from the name : The extcon name provided with extcon_dev_register()

Definition at line 399 of file extcon-class.c.

int extcon_register_interest ( struct extcon_specific_cable_nb obj,
const char extcon_name,
const char cable_name,
struct notifier_block nb 
)

extcon_register_interest() - Register a notifier for a state change of a specific cable, not an entier set of cables of a extcon device. : an empty extcon_specific_cable_nb object to be returned. : the name of extcon device. if NULL, extcon_register_interest will register every cable with the target cable_name given. : the target cable name. : the notifier block to get notified.

Provide an empty extcon_specific_cable_nb. extcon_register_interest() sets the struct for you.

extcon_register_interest is a helper function for those who want to get notification for a single specific cable's status change. If a user wants to get notification for any changes of all cables of a extcon device, he/she should use the general extcon_register_notifier().

Note that the second parameter given to the callback of nb (val) is "old_state", not the current state. The current state can be retrieved by looking at the third pameter (edev pointer)'s state value.

Definition at line 461 of file extcon-class.c.

int extcon_register_notifier ( struct extcon_dev edev,
struct notifier_block nb 
)

extcon_register_notifier() - Register a notifiee to get notified by any attach status changes from the extcon. : the extcon device. : a notifier block to be registered.

Note that the second parameter given to the callback of nb (val) is "old_state", not the current state. The current state can be retrieved by looking at the third pameter (edev pointer)'s state value.

Definition at line 529 of file extcon-class.c.

int extcon_set_cable_state ( struct extcon_dev edev,
const char cable_name,
bool  cable_state 
)

extcon_set_cable_state() - Set the status of a specific cable. : the extcon device that has the cable. : cable name. : the new cable status. The default semantics is true: attached / false: detached.

Note that this is slower than extcon_set_cable_state_.

Definition at line 387 of file extcon-class.c.

int extcon_set_cable_state_ ( struct extcon_dev edev,
int  index,
bool  cable_state 
)

extcon_set_cable_state_() - Set the status of a specific cable. : the extcon device that has the cable. : cable index that can be retrieved by extcon_find_cable_index(). : the new cable status. The default semantics is true: attached / false: detached.

Definition at line 365 of file extcon-class.c.

int extcon_set_state ( struct extcon_dev edev,
u32  state 
)

extcon_set_state() - Set the cable attach states of the extcon device. : the extcon device : new cable attach status for

Note that notifier provides which bits are changed in the state variable with the val parameter (second) to the callback.

Definition at line 298 of file extcon-class.c.

int extcon_unregister_interest ( struct extcon_specific_cable_nb obj)

extcon_unregister_interest() - Unregister the notifier registered by extcon_register_interest(). : the extcon_specific_cable_nb object returned by extcon_register_interest().

Definition at line 511 of file extcon-class.c.

int extcon_unregister_notifier ( struct extcon_dev edev,
struct notifier_block nb 
)

extcon_unregister_notifier() - Unregister a notifiee from the extcon device. : the extcon device. : a registered notifier block to be unregistered.

Definition at line 541 of file extcon-class.c.

int extcon_update_state ( struct extcon_dev edev,
u32  mask,
u32  state 
)

extcon_update_state() - Update the cable attach states of the extcon device only for the masked bits. : the extcon device : the bit mask to designate updated bits. : new cable attach status for

Changing the state sends uevent with environment variable containing the name of extcon device (envp[0]) and the state output (envp[1]). Tizen uses this format for extcon device to get events from ports. Android uses this format as well.

Note that the notifier provides which bits are changed in the state variable with the val parameter (second) to the callback.

Definition at line 223 of file extcon-class.c.

MODULE_AUTHOR ( "Mike Lockwood <[email protected]>"  )
MODULE_AUTHOR ( "Donggeun Kim <[email protected]>"  )
MODULE_AUTHOR ( "MyungJoo Ham <[email protected]>"  )
MODULE_DESCRIPTION ( "External connector (extcon) class driver )
module_exit ( extcon_class_exit  )
module_init ( extcon_class_init  )
MODULE_LICENSE ( "GPL"  )

Variable Documentation

Initial value:
= {
[EXTCON_USB] = "USB",
[EXTCON_USB_HOST] = "USB-Host",
[EXTCON_TA] = "TA",
[EXTCON_FAST_CHARGER] = "Fast-charger",
[EXTCON_SLOW_CHARGER] = "Slow-charger",
[EXTCON_CHARGE_DOWNSTREAM] = "Charge-downstream",
[EXTCON_HDMI] = "HDMI",
[EXTCON_MHL] = "MHL",
[EXTCON_DVI] = "DVI",
[EXTCON_VGA] = "VGA",
[EXTCON_DOCK] = "Dock",
[EXTCON_LINE_IN] = "Line-in",
[EXTCON_LINE_OUT] = "Line-out",
[EXTCON_MIC_IN] = "Microphone",
[EXTCON_HEADPHONE_OUT] = "Headphone",
[EXTCON_SPDIF_IN] = "SPDIF-in",
[EXTCON_SPDIF_OUT] = "SPDIF-out",
[EXTCON_VIDEO_IN] = "Video-in",
[EXTCON_VIDEO_OUT] = "Video-out",
[EXTCON_MECHANICAL] = "Mechanical",
}

Definition at line 44 of file extcon-class.c.