Merge branch 'overlayfs-next' of git://git.kernel.org/pub/scm/linux/kernel/git/mszere...
[firefly-linux-kernel-4.4.55.git] / drivers / extcon / extcon-usb-gpio.c
index e45d1f13f4458e9130d8f052494b33b1a11a9c60..a2a44536a608c2c1e300c8c02b40cd1e96bc5f0e 100644 (file)
@@ -15,6 +15,7 @@
  */
 
 #include <linux/extcon.h>
+#include <linux/gpio/consumer.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
@@ -38,18 +39,10 @@ struct usb_extcon_info {
        struct delayed_work wq_detcable;
 };
 
-/* List of detectable cables */
-enum {
-       EXTCON_CABLE_USB = 0,
-       EXTCON_CABLE_USB_HOST,
-
-       EXTCON_CABLE_END,
-};
-
-static const char *usb_extcon_cable[] = {
-       [EXTCON_CABLE_USB] = "USB",
-       [EXTCON_CABLE_USB_HOST] = "USB-HOST",
-       NULL,
+static const unsigned int usb_extcon_cable[] = {
+       EXTCON_USB,
+       EXTCON_USB_HOST,
+       EXTCON_NONE,
 };
 
 static void usb_extcon_detect_cable(struct work_struct *work)
@@ -67,24 +60,16 @@ static void usb_extcon_detect_cable(struct work_struct *work)
                 * As we don't have event for USB peripheral cable attached,
                 * we simulate USB peripheral attach here.
                 */
-               extcon_set_cable_state(info->edev,
-                                      usb_extcon_cable[EXTCON_CABLE_USB_HOST],
-                                      false);
-               extcon_set_cable_state(info->edev,
-                                      usb_extcon_cable[EXTCON_CABLE_USB],
-                                      true);
+               extcon_set_cable_state_(info->edev, EXTCON_USB_HOST, false);
+               extcon_set_cable_state_(info->edev, EXTCON_USB, true);
        } else {
                /*
                 * ID = 0 means USB HOST cable attached.
                 * As we don't have event for USB peripheral cable detached,
                 * we simulate USB peripheral detach here.
                 */
-               extcon_set_cable_state(info->edev,
-                                      usb_extcon_cable[EXTCON_CABLE_USB],
-                                      false);
-               extcon_set_cable_state(info->edev,
-                                      usb_extcon_cable[EXTCON_CABLE_USB_HOST],
-                                      true);
+               extcon_set_cable_state_(info->edev, EXTCON_USB, false);
+               extcon_set_cable_state_(info->edev, EXTCON_USB_HOST, true);
        }
 }
 
@@ -113,7 +98,7 @@ static int usb_extcon_probe(struct platform_device *pdev)
                return -ENOMEM;
 
        info->dev = dev;
-       info->id_gpiod = devm_gpiod_get(&pdev->dev, "id");
+       info->id_gpiod = devm_gpiod_get(&pdev->dev, "id", GPIOD_IN);
        if (IS_ERR(info->id_gpiod)) {
                dev_err(dev, "failed to get ID GPIO\n");
                return PTR_ERR(info->id_gpiod);