~ubuntu-branches/debian/experimental/linux-tools/experimental

« back to all changes in this revision

Viewing changes to include/linux/extcon.h

  • Committer: Package Import Robot
  • Author(s): Ben Hutchings
  • Date: 2014-02-02 16:57:49 UTC
  • mfrom: (1.1.10) (0.1.21 sid)
  • Revision ID: package-import@ubuntu.com-20140202165749-tw94o9t1t0a8txk6
Tags: 3.13-1~exp2
Merge changes from sid up to 3.12.6-3

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
enum extcon_cable_name {
52
52
        EXTCON_USB = 0,
53
53
        EXTCON_USB_HOST,
54
 
        EXTCON_TA, /* Travel Adaptor */
 
54
        EXTCON_TA,                      /* Travel Adaptor */
55
55
        EXTCON_FAST_CHARGER,
56
56
        EXTCON_SLOW_CHARGER,
57
 
        EXTCON_CHARGE_DOWNSTREAM, /* Charging an external device */
 
57
        EXTCON_CHARGE_DOWNSTREAM,       /* Charging an external device */
58
58
        EXTCON_HDMI,
59
59
        EXTCON_MHL,
60
60
        EXTCON_DVI,
76
76
 
77
77
/**
78
78
 * struct extcon_dev - An extcon device represents one external connector.
79
 
 * @name:       The name of this extcon device. Parent device name is used
80
 
 *              if NULL.
 
79
 * @name:               The name of this extcon device. Parent device name is
 
80
 *                      used if NULL.
81
81
 * @supported_cable:    Array of supported cable names ending with NULL.
82
82
 *                      If supported_cable is NULL, cable name related APIs
83
83
 *                      are disabled.
89
89
 *                      be attached simulataneously. {0x7, 0} is equivalent to
90
90
 *                      {0x3, 0x6, 0x5, 0}. If it is {0xFFFFFFFF, 0}, there
91
91
 *                      can be no simultaneous connections.
92
 
 * @print_name: An optional callback to override the method to print the
93
 
 *              name of the extcon device.
 
92
 * @print_name:         An optional callback to override the method to print the
 
93
 *                      name of the extcon device.
94
94
 * @print_state:        An optional callback to override the method to print the
95
 
 *              status of the extcon device.
96
 
 * @dev:        Device of this extcon. Do not provide at register-time.
97
 
 * @state:      Attach/detach state of this extcon. Do not provide at
98
 
 *              register-time
99
 
 * @nh: Notifier for the state change events from this extcon
100
 
 * @entry:      To support list of extcon devices so that users can search
101
 
 *              for extcon devices based on the extcon name.
 
95
 *                      status of the extcon device.
 
96
 * @dev:                Device of this extcon.
 
97
 * @state:              Attach/detach state of this extcon. Do not provide at
 
98
 *                      register-time.
 
99
 * @nh:                 Notifier for the state change events from this extcon
 
100
 * @entry:              To support list of extcon devices so that users can search
 
101
 *                      for extcon devices based on the extcon name.
102
102
 * @lock:
103
103
 * @max_supported:      Internal value to store the number of cables.
104
104
 * @extcon_dev_type:    Device_type struct to provide attribute_groups
105
105
 *                      customized for each extcon device.
106
 
 * @cables:     Sysfs subdirectories. Each represents one cable.
 
106
 * @cables:             Sysfs subdirectories. Each represents one cable.
107
107
 *
108
108
 * In most cases, users only need to provide "User initializing data" of
109
109
 * this struct when registering an extcon. In some exceptional cases,
111
111
 * are overwritten by register function.
112
112
 */
113
113
struct extcon_dev {
114
 
        /* --- Optional user initializing data --- */
115
 
        const char      *name;
 
114
        /* Optional user initializing data */
 
115
        const char *name;
116
116
        const char **supported_cable;
117
 
        const u32       *mutually_exclusive;
 
117
        const u32 *mutually_exclusive;
118
118
 
119
 
        /* --- Optional callbacks to override class functions --- */
 
119
        /* Optional callbacks to override class functions */
120
120
        ssize_t (*print_name)(struct extcon_dev *edev, char *buf);
121
121
        ssize_t (*print_state)(struct extcon_dev *edev, char *buf);
122
122
 
123
 
        /* --- Internal data. Please do not set. --- */
124
 
        struct device   *dev;
125
 
        u32             state;
 
123
        /* Internal data. Please do not set. */
 
124
        struct device dev;
126
125
        struct raw_notifier_head nh;
127
126
        struct list_head entry;
128
 
        spinlock_t lock; /* could be called by irq handler */
129
127
        int max_supported;
 
128
        spinlock_t lock;        /* could be called by irq handler */
 
129
        u32 state;
130
130
 
131
131
        /* /sys/class/extcon/.../cable.n/... */
132
132
        struct device_type extcon_dev_type;
133
133
        struct extcon_cable *cables;
 
134
 
134
135
        /* /sys/class/extcon/.../mutually_exclusive/... */
135
136
        struct attribute_group attr_g_muex;
136
137
        struct attribute **attrs_muex;
138
139
};
139
140
 
140
141
/**
141
 
 * struct extcon_cable  - An internal data for each cable of extcon device.
142
 
 * @edev:       The extcon device
 
142
 * struct extcon_cable - An internal data for each cable of extcon device.
 
143
 * @edev:               The extcon device
143
144
 * @cable_index:        Index of this cable in the edev
144
 
 * @attr_g:     Attribute group for the cable
145
 
 * @attr_name:  "name" sysfs entry
146
 
 * @attr_state: "state" sysfs entry
147
 
 * @attrs:      Array pointing to attr_name and attr_state for attr_g
 
145
 * @attr_g:             Attribute group for the cable
 
146
 * @attr_name:          "name" sysfs entry
 
147
 * @attr_state:         "state" sysfs entry
 
148
 * @attrs:              Array pointing to attr_name and attr_state for attr_g
148
149
 */
149
150
struct extcon_cable {
150
151
        struct extcon_dev *edev;
159
160
 
160
161
/**
161
162
 * struct extcon_specific_cable_nb - An internal data for
162
 
 *                              extcon_register_interest().
163
 
 * @internal_nb:        a notifier block bridging extcon notifier and cable notifier.
164
 
 * @user_nb:    user provided notifier block for events from a specific cable.
 
163
 *                                   extcon_register_interest().
 
164
 * @internal_nb:        A notifier block bridging extcon notifier
 
165
 *                      and cable notifier.
 
166
 * @user_nb:            user provided notifier block for events from
 
167
 *                      a specific cable.
165
168
 * @cable_index:        the target cable.
166
 
 * @edev:       the target extcon device.
 
169
 * @edev:               the target extcon device.
167
170
 * @previous_value:     the saved previous event value.
168
171
 */
169
172
struct extcon_specific_cable_nb {
180
183
 * Following APIs are for notifiers or configurations.
181
184
 * Notifiers are the external port and connection devices.
182
185
 */
183
 
extern int extcon_dev_register(struct extcon_dev *edev, struct device *dev);
 
186
extern int extcon_dev_register(struct extcon_dev *edev);
184
187
extern void extcon_dev_unregister(struct extcon_dev *edev);
185
188
extern struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name);
186
189
 
238
241
extern int extcon_unregister_notifier(struct extcon_dev *edev,
239
242
                                      struct notifier_block *nb);
240
243
#else /* CONFIG_EXTCON */
241
 
static inline int extcon_dev_register(struct extcon_dev *edev,
242
 
                                      struct device *dev)
 
244
static inline int extcon_dev_register(struct extcon_dev *edev)
243
245
{
244
246
        return 0;
245
247
}