extcon: Redefine the unique id of supported external connectors without 'enum extcon...
authorChanwoo Choi <cw00.choi@samsung.com>
Fri, 12 Jun 2015 02:10:06 +0000 (11:10 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 13 Jun 2015 00:01:42 +0000 (17:01 -0700)
This patch just redefine the unique id of supported external connectors without
'enum extcon' type. Because unique id would be used on devictree file(*.dts) to
indicate the specific external connectors like key number of input framework.
So, I have the plan to move this definitions to following header file which
includes the unique id of supported external connectors.
- include/dt-bindings/extcon/extcon.h

Fixes: 2a9de9c0f08d ("extcon: Use the unique id for external connector instead of string")
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
14 files changed:
drivers/extcon/extcon-adc-jack.c
drivers/extcon/extcon-arizona.c
drivers/extcon/extcon-axp288.c
drivers/extcon/extcon-max14577.c
drivers/extcon/extcon-max77693.c
drivers/extcon/extcon-max77843.c
drivers/extcon/extcon-max8997.c
drivers/extcon/extcon-palmas.c
drivers/extcon/extcon-rt8973a.c
drivers/extcon/extcon-sm5502.c
drivers/extcon/extcon-usb-gpio.c
drivers/extcon/extcon.c
drivers/usb/phy/phy-tahvo.c
include/linux/extcon.h

index 5bf08ec1cacfa77e8860f81acafdf28deac3f2af..7fc0ae1912f855c586ef0a9b064ea3bba68ff3b6 100644 (file)
@@ -40,7 +40,7 @@
 struct adc_jack_data {
        struct extcon_dev *edev;
 
-       const char **cable_names;
+       const unsigned int **cable_names;
        struct adc_jack_cond *adc_conditions;
        int num_conditions;
 
index 9262b45a4484f00b3aa6d285b130b09b142460fe..ad87f263056f1f4995dba394af244e829afa2f84 100644 (file)
@@ -118,7 +118,7 @@ static const int arizona_micd_levels[] = {
        1257,
 };
 
-static const enum extcon arizona_cable[] = {
+static const unsigned int arizona_cable[] = {
        EXTCON_MECHANICAL,
        EXTCON_MICROPHONE,
        EXTCON_HEADPHONE,
@@ -552,7 +552,7 @@ static irqreturn_t arizona_hpdet_irq(int irq, void *data)
        struct arizona_extcon_info *info = data;
        struct arizona *arizona = info->arizona;
        int id_gpio = arizona->pdata.hpdet_id_gpio;
-       enum extcon report = EXTCON_HEADPHONE;
+       unsigned int report = EXTCON_HEADPHONE;
        int ret, reading;
        bool mic = false;
 
index 3605aa96c25a92c9c47e3e9b96d591a233a26130..ea962bc547b81c609d37ee5ca6a51f40c613bc1b 100644 (file)
@@ -101,7 +101,7 @@ enum axp288_extcon_irq {
        EXTCON_IRQ_END,
 };
 
-static const enum extcon axp288_extcon_cables[] = {
+static const unsigned int axp288_extcon_cables[] = {
        EXTCON_SLOW_CHARGER,
        EXTCON_CHARGE_DOWNSTREAM,
        EXTCON_FAST_CHARGER,
@@ -157,7 +157,7 @@ static void axp288_extcon_log_rsi(struct axp288_extcon_info *info)
 static int axp288_handle_chrg_det_event(struct axp288_extcon_info *info)
 {
        static bool notify_otg, notify_charger;
-       static enum extcon cable;
+       static unsigned int cable;
        int ret, stat, cfg, pwr_stat;
        u8 chrg_type;
        bool vbus_attach = false;
index e7c3edb5bd4b88ea8707d83444ec9f553fe3b85d..df0659d98e5ac56a3c7de2fa2fd37b8e12c1fa3a 100644 (file)
@@ -148,7 +148,7 @@ enum max14577_muic_acc_type {
        MAX14577_MUIC_ADC_OPEN,
 };
 
-static const enum extcon max14577_extcon_cable[] = {
+static const unsigned int max14577_extcon_cable[] = {
        EXTCON_USB,
        EXTCON_TA,
        EXTCON_FAST_CHARGER,
index 20e796e10e5790a54a30ec8d67f3b8887b727c16..f4f3b3d5392823e145ffa89cf223bd0b45c76892 100644 (file)
@@ -200,7 +200,7 @@ enum max77693_muic_acc_type {
 /*
  * MAX77693 MUIC device support below list of accessories(external connector)
  */
-static const enum extcon max77693_extcon_cable[] = {
+static const unsigned int max77693_extcon_cable[] = {
        EXTCON_USB,
        EXTCON_USB_HOST,
        EXTCON_TA,
@@ -457,7 +457,7 @@ static int max77693_muic_dock_handler(struct max77693_muic_info *info,
        int ret = 0;
        int vbvolt;
        bool cable_attached;
-       enum extcon dock_id;
+       unsigned int dock_id;
 
        dev_info(info->dev,
                "external connector is %s (adc:0x%02x)\n",
index d78a64d7fc207cebfe0e3a7872d4eb07d7c7ca62..fac2f1417a79ca47752839b79ae7a07522cb1ebb 100644 (file)
@@ -118,7 +118,7 @@ enum max77843_muic_charger_type {
        MAX77843_MUIC_CHG_GND,
 };
 
-static const enum extcon max77843_extcon_cable[] = {
+static const unsigned int max77843_extcon_cable[] = {
        EXTCON_USB,
        EXTCON_USB_HOST,
        EXTCON_TA,
index 4d10949c6eb2e814bdf12b57d62305fe59cbcbae..7b1ef200b1219ed0a16a6ea483b19497985e54fa 100644 (file)
@@ -145,7 +145,7 @@ struct max8997_muic_info {
        int path_uart;
 };
 
-static const enum extcon max8997_extcon_cable[] = {
+static const unsigned int max8997_extcon_cable[] = {
        EXTCON_USB,
        EXTCON_USB_HOST,
        EXTCON_TA,
index d68954045a339347632a3e068ee262e6ffd64827..080d5cc2705529962d2a62b17fe3f597b5bc41e3 100644 (file)
@@ -29,7 +29,7 @@
 #include <linux/of.h>
 #include <linux/of_platform.h>
 
-static const enum extcon palmas_extcon_cable[] = {
+static const unsigned int palmas_extcon_cable[] = {
        EXTCON_USB,
        EXTCON_USB_HOST,
        EXTCON_NONE,
index f2a8672cbf82a5d8158fc309af53cf032194ebd9..92c939221a41fa1177bc31395f827d8af2b9b5a7 100644 (file)
@@ -90,7 +90,7 @@ static struct reg_data rt8973a_reg_data[] = {
 };
 
 /* List of detectable cables */
-static const enum extcon rt8973a_extcon_cable[] = {
+static const unsigned int rt8973a_extcon_cable[] = {
        EXTCON_USB,
        EXTCON_USB_HOST,
        EXTCON_TA,
@@ -300,7 +300,7 @@ static int rt8973a_muic_cable_handler(struct rt8973a_muic_info *info,
        static unsigned int prev_cable_type;
        unsigned int con_sw = DM_DP_SWITCH_UART;
        int ret, cable_type;
-       enum extcon id;
+       unsigned int id;
        bool attached = false;
 
        switch (event) {
index 520693d6fa8ab8665012ff359610c9144d0365d4..817dece23b4c2c2048ca190e8b2645de57408dcf 100644 (file)
@@ -92,7 +92,7 @@ static struct reg_data sm5502_reg_data[] = {
 };
 
 /* List of detectable cables */
-static const enum extcon sm5502_extcon_cable[] = {
+static const unsigned int sm5502_extcon_cable[] = {
        EXTCON_USB,
        EXTCON_USB_HOST,
        EXTCON_TA,
@@ -372,7 +372,7 @@ static int sm5502_muic_cable_handler(struct sm5502_muic_info *info,
        unsigned int cable_type = SM5502_MUIC_ADC_GROUND;
        unsigned int con_sw = DM_DP_SWITCH_OPEN;
        unsigned int vbus_sw = VBUSIN_SWITCH_OPEN;
-       enum extcon id;
+       unsigned int id;
        int ret;
 
        /* Get the type of attached or detached cable */
index 14da94cb57faa58aaa6fb6a5900f3ad8a0912b58..a2a44536a608c2c1e300c8c02b40cd1e96bc5f0e 100644 (file)
@@ -39,7 +39,7 @@ struct usb_extcon_info {
        struct delayed_work wq_detcable;
 };
 
-static const enum extcon usb_extcon_cable[] = {
+static const unsigned int usb_extcon_cable[] = {
        EXTCON_USB,
        EXTCON_USB_HOST,
        EXTCON_NONE,
index fafd428cae7f30142b91bc45ff766624d11826ce..76157ab9faf3ad84a16e738a4e338ad1bded8e3c 100644 (file)
@@ -39,6 +39,8 @@
 #define CABLE_NAME_MAX         30
 
 static const char *extcon_name[] =  {
+       [EXTCON_NONE]           = "NONE",
+
        /* USB external connector */
        [EXTCON_USB]            = "USB",
        [EXTCON_USB_HOST]       = "USB-HOST",
@@ -109,7 +111,7 @@ static int check_mutually_exclusive(struct extcon_dev *edev, u32 new_state)
        return 0;
 }
 
-static int find_cable_index_by_id(struct extcon_dev *edev, const enum extcon id)
+static int find_cable_index_by_id(struct extcon_dev *edev, const unsigned int id)
 {
        int i;
 
@@ -124,16 +126,14 @@ static int find_cable_index_by_id(struct extcon_dev *edev, const enum extcon id)
 
 static int find_cable_index_by_name(struct extcon_dev *edev, const char *name)
 {
-       enum extcon id = EXTCON_NONE;
-       int i;
+       unsigned int id = EXTCON_NONE;
+       int i = 0;
 
        if (edev->max_supported == 0)
                return -EINVAL;
 
        /* Find the the number of extcon cable */
-       for (i = 0; i < EXTCON_END; i++) {
-               if (!extcon_name[i])
-                       continue;
+       while (extcon_name[i]) {
                if (!strncmp(extcon_name[i], name, CABLE_NAME_MAX)) {
                        id = i;
                        break;
@@ -337,7 +337,7 @@ EXPORT_SYMBOL_GPL(extcon_set_state);
  * @edev:      the extcon device that has the cable.
  * @id:                the unique id of each external connector in extcon enumeration.
  */
-int extcon_get_cable_state_(struct extcon_dev *edev, const enum extcon id)
+int extcon_get_cable_state_(struct extcon_dev *edev, const unsigned int id)
 {
        int index;
 
@@ -374,7 +374,7 @@ EXPORT_SYMBOL_GPL(extcon_get_cable_state);
  * @state:             the new cable status. The default semantics is
  *                     true: attached / false: detached.
  */
-int extcon_set_cable_state_(struct extcon_dev *edev, enum extcon id,
+int extcon_set_cable_state_(struct extcon_dev *edev, unsigned int id,
                                bool cable_state)
 {
        u32 state;
@@ -539,7 +539,7 @@ EXPORT_SYMBOL_GPL(extcon_unregister_interest);
  * "old_state", not the current state. The current state can be retrieved
  * by looking at the third pameter (edev pointer)'s state value.
  */
-int extcon_register_notifier(struct extcon_dev *edev, enum extcon id,
+int extcon_register_notifier(struct extcon_dev *edev, unsigned int id,
                             struct notifier_block *nb)
 {
        unsigned long flags;
@@ -561,7 +561,7 @@ EXPORT_SYMBOL_GPL(extcon_register_notifier);
  * @id:                the unique id of each external connector in extcon enumeration.
  * @nb:                a notifier block to be registered.
  */
-int extcon_unregister_notifier(struct extcon_dev *edev, enum extcon id,
+int extcon_unregister_notifier(struct extcon_dev *edev, unsigned int id,
                                struct notifier_block *nb)
 {
        unsigned long flags;
@@ -623,7 +623,7 @@ static void dummy_sysfs_dev_release(struct device *dev)
  *
  * Return the pointer of extcon device if success or ERR_PTR(err) if fail
  */
-struct extcon_dev *extcon_dev_allocate(const enum extcon *supported_cable)
+struct extcon_dev *extcon_dev_allocate(const unsigned int *supported_cable)
 {
        struct extcon_dev *edev;
 
@@ -677,7 +677,7 @@ static void devm_extcon_dev_release(struct device *dev, void *res)
  * or ERR_PTR(err) if fail
  */
 struct extcon_dev *devm_extcon_dev_allocate(struct device *dev,
-                                       const enum extcon *supported_cable)
+                                       const unsigned int *supported_cable)
 {
        struct extcon_dev **ptr, *edev;
 
index 1d1bb9ad8ccf07d252245009d11249e19fdc744b..2f777d22184da46aee5686ea32a741311e36b393 100644 (file)
@@ -60,7 +60,7 @@ struct tahvo_usb {
        struct extcon_dev       extcon;
 };
 
-static const enum extcon tahvo_cable[] = {
+static const unsigned int tahvo_cable[] = {
        EXTCON_USB,
        EXTCON_USB_HOST,
 
index a7b224b20eccb74e1fbe8f96a3aea614ee7fc87f..b16d929fa75f811c211d171abb9c2f96d64a930f 100644 (file)
 #include <linux/notifier.h>
 #include <linux/sysfs.h>
 
-enum extcon {
-       EXTCON_NONE             = 0x0,
-
-       /* USB external connector */
-       EXTCON_USB              = 0x1,
-       EXTCON_USB_HOST         = 0x2,
-
-       /* Charger external connector */
-       EXTCON_TA               = 0x10,
-       EXTCON_FAST_CHARGER     = 0x11,
-       EXTCON_SLOW_CHARGER     = 0x12,
-       EXTCON_CHARGE_DOWNSTREAM = 0x13,
-
-       /* Audio/Video external connector */
-       EXTCON_LINE_IN          = 0x20,
-       EXTCON_LINE_OUT         = 0x21,
-       EXTCON_MICROPHONE       = 0x22,
-       EXTCON_HEADPHONE        = 0x23,
-
-       EXTCON_HDMI             = 0x30,
-       EXTCON_MHL              = 0x31,
-       EXTCON_DVI              = 0x32,
-       EXTCON_VGA              = 0x33,
-       EXTCON_SPDIF_IN         = 0x34,
-       EXTCON_SPDIF_OUT        = 0x35,
-       EXTCON_VIDEO_IN         = 0x36,
-       EXTCON_VIDEO_OUT        = 0x37,
-
-       /* Etc external connector */
-       EXTCON_DOCK             = 0x50,
-       EXTCON_JIG              = 0x51,
-       EXTCON_MECHANICAL       = 0x52,
-
-       EXTCON_END,
-};
+/*
+ * Define the unique id of supported external connectors
+ */
+#define EXTCON_NONE                    0
+
+#define EXTCON_USB                     1       /* USB connector */
+#define EXTCON_USB_HOST                        2
+
+#define EXTCON_TA                      3       /* Charger connector */
+#define EXTCON_FAST_CHARGER            4
+#define EXTCON_SLOW_CHARGER            5
+#define EXTCON_CHARGE_DOWNSTREAM       6
+
+#define EXTCON_LINE_IN                 7       /* Audio/Video connector */
+#define EXTCON_LINE_OUT                        8
+#define EXTCON_MICROPHONE              9
+#define EXTCON_HEADPHONE               10
+#define EXTCON_HDMI                    11
+#define EXTCON_MHL                     12
+#define EXTCON_DVI                     13
+#define EXTCON_VGA                     14
+#define EXTCON_SPDIF_IN                        15
+#define EXTCON_SPDIF_OUT               16
+#define EXTCON_VIDEO_IN                        17
+#define EXTCON_VIDEO_OUT               18
+
+#define EXTCON_DOCK                    19      /* Misc connector */
+#define EXTCON_JIG                     20
+#define EXTCON_MECHANICAL              21
 
 struct extcon_cable;
 
@@ -105,7 +99,7 @@ struct extcon_cable;
 struct extcon_dev {
        /* Optional user initializing data */
        const char *name;
-       const enum extcon *supported_cable;
+       const unsigned int *supported_cable;
        const u32 *mutually_exclusive;
 
        /* Optional callbacks to override class functions */
@@ -182,10 +176,10 @@ extern struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name);
 /*
  * Following APIs control the memory of extcon device.
  */
-extern struct extcon_dev *extcon_dev_allocate(const enum extcon *cable);
+extern struct extcon_dev *extcon_dev_allocate(const unsigned int *cable);
 extern void extcon_dev_free(struct extcon_dev *edev);
 extern struct extcon_dev *devm_extcon_dev_allocate(struct device *dev,
-                                                  const enum extcon *cable);
+                                                  const unsigned int *cable);
 extern void devm_extcon_dev_free(struct device *dev, struct extcon_dev *edev);
 
 /*
@@ -206,8 +200,8 @@ extern int extcon_update_state(struct extcon_dev *edev, u32 mask, u32 state);
  * get/set_cable_state access each bit of the 32b encoded state value.
  * They are used to access the status of each cable based on the cable_name.
  */
-extern int extcon_get_cable_state_(struct extcon_dev *edev, enum extcon id);
-extern int extcon_set_cable_state_(struct extcon_dev *edev, enum extcon id,
+extern int extcon_get_cable_state_(struct extcon_dev *edev, unsigned int id);
+extern int extcon_set_cable_state_(struct extcon_dev *edev, unsigned int id,
                                   bool cable_state);
 
 extern int extcon_get_cable_state(struct extcon_dev *edev,
@@ -234,9 +228,9 @@ extern int extcon_unregister_interest(struct extcon_specific_cable_nb *nb);
  * we do not recommend to use this for normal 'notifiee' device drivers who
  * want to be notified by a specific external port of the notifier.
  */
-extern int extcon_register_notifier(struct extcon_dev *edev, enum extcon id,
+extern int extcon_register_notifier(struct extcon_dev *edev, unsigned int id,
                                    struct notifier_block *nb);
-extern int extcon_unregister_notifier(struct extcon_dev *edev, enum extcon id,
+extern int extcon_unregister_notifier(struct extcon_dev *edev, unsigned int id,
                                    struct notifier_block *nb);
 
 /*
@@ -266,7 +260,7 @@ static inline int devm_extcon_dev_register(struct device *dev,
 static inline void devm_extcon_dev_unregister(struct device *dev,
                                              struct extcon_dev *edev) { }
 
-static inline struct extcon_dev *extcon_dev_allocate(const enum extcon *cable)
+static inline struct extcon_dev *extcon_dev_allocate(const unsigned int *cable)
 {
        return ERR_PTR(-ENOSYS);
 }
@@ -274,7 +268,7 @@ static inline struct extcon_dev *extcon_dev_allocate(const enum extcon *cable)
 static inline void extcon_dev_free(struct extcon_dev *edev) { }
 
 static inline struct extcon_dev *devm_extcon_dev_allocate(struct device *dev,
-                                               const enum extcon *cable)
+                                               const unsigned int *cable)
 {
        return ERR_PTR(-ENOSYS);
 }
@@ -298,13 +292,13 @@ static inline int extcon_update_state(struct extcon_dev *edev, u32 mask,
 }
 
 static inline int extcon_get_cable_state_(struct extcon_dev *edev,
-                                         enum extcon id)
+                                         unsigned int id)
 {
        return 0;
 }
 
 static inline int extcon_set_cable_state_(struct extcon_dev *edev,
-                                         enum extcon id, bool cable_state)
+                                         unsigned int id, bool cable_state)
 {
        return 0;
 }
@@ -327,14 +321,14 @@ static inline struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name)
 }
 
 static inline int extcon_register_notifier(struct extcon_dev *edev,
-                                       enum extcon id,
+                                       unsigned int id,
                                        struct notifier_block *nb)
 {
        return 0;
 }
 
 static inline int extcon_unregister_notifier(struct extcon_dev *edev,
-                                       enum extcon id,
+                                       unsigned int id,
                                        struct notifier_block *nb)
 {
        return 0;