Merge branch 'fix/misc' into for-linus
[pandora-kernel.git] / drivers / usb / gadget / s3c2410_udc.c
index c7e2556..a9b452f 100644 (file)
@@ -28,7 +28,6 @@
 #include <linux/ioport.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
-#include <linux/smp_lock.h>
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/timer.h>
@@ -36,6 +35,7 @@
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
 #include <linux/clk.h>
+#include <linux/gpio.h>
 
 #include <linux/debugfs.h>
 #include <linux/seq_file.h>
@@ -51,7 +51,6 @@
 #include <mach/irqs.h>
 
 #include <mach/hardware.h>
-#include <mach/regs-gpio.h>
 
 #include <plat/regs-udc.h>
 #include <plat/udc.h>
@@ -1510,11 +1509,7 @@ static irqreturn_t s3c2410_udc_vbus_irq(int irq, void *_dev)
 
        dprintk(DEBUG_NORMAL, "%s()\n", __func__);
 
-       /* some cpus cannot read from an line configured to IRQ! */
-       s3c2410_gpio_cfgpin(udc_info->vbus_pin, S3C2410_GPIO_INPUT);
-       value = s3c2410_gpio_getpin(udc_info->vbus_pin);
-       s3c2410_gpio_cfgpin(udc_info->vbus_pin, S3C2410_GPIO_SFN2);
-
+       value = gpio_get_value(udc_info->vbus_pin) ? 1 : 0;
        if (udc_info->vbus_pin_inverted)
                value = !value;
 
@@ -1802,7 +1797,7 @@ static int s3c2410_udc_probe(struct platform_device *pdev)
        struct s3c2410_udc *udc = &memory;
        struct device *dev = &pdev->dev;
        int retval;
-       unsigned int irq;
+       int irq;
 
        dev_dbg(dev, "%s()\n", __func__);
 
@@ -1861,7 +1856,7 @@ static int s3c2410_udc_probe(struct platform_device *pdev)
 
        /* irq setup after old hardware state is cleaned up */
        retval = request_irq(IRQ_USBD, s3c2410_udc_irq,
-                       IRQF_DISABLED, gadget_name, udc);
+                            IRQF_DISABLED, gadget_name, udc);
 
        if (retval != 0) {
                dev_err(dev, "cannot get irq %i, err %d\n", IRQ_USBD, retval);
@@ -1872,17 +1867,28 @@ static int s3c2410_udc_probe(struct platform_device *pdev)
        dev_dbg(dev, "got irq %i\n", IRQ_USBD);
 
        if (udc_info && udc_info->vbus_pin > 0) {
-               irq = s3c2410_gpio_getirq(udc_info->vbus_pin);
+               retval = gpio_request(udc_info->vbus_pin, "udc vbus");
+               if (retval < 0) {
+                       dev_err(dev, "cannot claim vbus pin\n");
+                       goto err_int;
+               }
+
+               irq = gpio_to_irq(udc_info->vbus_pin);
+               if (irq < 0) {
+                       dev_err(dev, "no irq for gpio vbus pin\n");
+                       goto err_gpio_claim;
+               }
+
                retval = request_irq(irq, s3c2410_udc_vbus_irq,
                                     IRQF_DISABLED | IRQF_TRIGGER_RISING
                                     | IRQF_TRIGGER_FALLING | IRQF_SHARED,
                                     gadget_name, udc);
 
                if (retval != 0) {
-                       dev_err(dev, "can't get vbus irq %i, err %d\n",
+                       dev_err(dev, "can't get vbus irq %d, err %d\n",
                                irq, retval);
                        retval = -EBUSY;
-                       goto err_int;
+                       goto err_gpio_claim;
                }
 
                dev_dbg(dev, "got irq %i\n", irq);
@@ -1902,6 +1908,9 @@ static int s3c2410_udc_probe(struct platform_device *pdev)
 
        return 0;
 
+err_gpio_claim:
+       if (udc_info && udc_info->vbus_pin > 0)
+               gpio_free(udc_info->vbus_pin);
 err_int:
        free_irq(IRQ_USBD, udc);
 err_map:
@@ -1927,7 +1936,7 @@ static int s3c2410_udc_remove(struct platform_device *pdev)
        debugfs_remove(udc->regs_info);
 
        if (udc_info && udc_info->vbus_pin > 0) {
-               irq = s3c2410_gpio_getirq(udc_info->vbus_pin);
+               irq = gpio_to_irq(udc_info->vbus_pin);
                free_irq(irq, udc);
        }