Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef __LINUX_EXTCON_INTERNAL_H__
0003 #define __LINUX_EXTCON_INTERNAL_H__
0004 
0005 #include <linux/extcon-provider.h>
0006 
0007 /**
0008  * struct extcon_dev - An extcon device represents one external connector.
0009  * @name:       The name of this extcon device. Parent device name is
0010  *          used if NULL.
0011  * @supported_cable:    Array of supported cable names ending with EXTCON_NONE.
0012  *          If supported_cable is NULL, cable name related APIs
0013  *          are disabled.
0014  * @mutually_exclusive: Array of mutually exclusive set of cables that cannot
0015  *          be attached simultaneously. The array should be
0016  *          ending with NULL or be NULL (no mutually exclusive
0017  *          cables). For example, if it is { 0x7, 0x30, 0}, then,
0018  *          {0, 1}, {0, 1, 2}, {0, 2}, {1, 2}, or {4, 5} cannot
0019  *          be attached simulataneously. {0x7, 0} is equivalent to
0020  *          {0x3, 0x6, 0x5, 0}. If it is {0xFFFFFFFF, 0}, there
0021  *          can be no simultaneous connections.
0022  * @dev:        Device of this extcon.
0023  * @state:      Attach/detach state of this extcon. Do not provide at
0024  *          register-time.
0025  * @nh_all:     Notifier for the state change events for all supported
0026  *          external connectors from this extcon.
0027  * @nh:         Notifier for the state change events from this extcon
0028  * @entry:      To support list of extcon devices so that users can
0029  *          search for extcon devices based on the extcon name.
0030  * @lock:
0031  * @max_supported:  Internal value to store the number of cables.
0032  * @extcon_dev_type:    Device_type struct to provide attribute_groups
0033  *          customized for each extcon device.
0034  * @cables:     Sysfs subdirectories. Each represents one cable.
0035  *
0036  * In most cases, users only need to provide "User initializing data" of
0037  * this struct when registering an extcon. In some exceptional cases,
0038  * optional callbacks may be needed. However, the values in "internal data"
0039  * are overwritten by register function.
0040  */
0041 struct extcon_dev {
0042     /* Optional user initializing data */
0043     const char *name;
0044     const unsigned int *supported_cable;
0045     const u32 *mutually_exclusive;
0046 
0047     /* Internal data. Please do not set. */
0048     struct device dev;
0049     struct raw_notifier_head nh_all;
0050     struct raw_notifier_head *nh;
0051     struct list_head entry;
0052     int max_supported;
0053     spinlock_t lock;    /* could be called by irq handler */
0054     u32 state;
0055 
0056     /* /sys/class/extcon/.../cable.n/... */
0057     struct device_type extcon_dev_type;
0058     struct extcon_cable *cables;
0059 
0060     /* /sys/class/extcon/.../mutually_exclusive/... */
0061     struct attribute_group attr_g_muex;
0062     struct attribute **attrs_muex;
0063     struct device_attribute *d_attrs_muex;
0064 };
0065 
0066 #endif /* __LINUX_EXTCON_INTERNAL_H__ */