On Mon, Feb 14, 2011 at 8:33 PM, Dmitry Eremin-Solenikov <dbaryshkov@xxxxxxxxx> wrote: > Stop handling gpio-vbus internally. All boards that depended on this > functionality have been converted to use gpio-vbus tranceiver. All > new boards can use it right from the start. Drop unused code. > > Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@xxxxxxxxx> I'm good with the change below. The original intention of is_vbus_present() is actually to detect if it's connected. A name of is_connected() would be better, and I'm fine using gadget.speed for this. David or any other USB people please have a review and give an Ack-by? I'd like this being merged through the ARM tree as the other four patches better go there as well. Thanks > --- > Âdrivers/usb/gadget/pxa25x_udc.c |  76 ++++----------------------------------- > Â1 files changed, 7 insertions(+), 69 deletions(-) > > diff --git a/drivers/usb/gadget/pxa25x_udc.c b/drivers/usb/gadget/pxa25x_udc.c > index b37f92c..444b60a 100644 > --- a/drivers/usb/gadget/pxa25x_udc.c > +++ b/drivers/usb/gadget/pxa25x_udc.c > @@ -139,24 +139,6 @@ static const char ep0name [] = "ep0"; > Âstatic void pxa25x_ep_fifo_flush (struct usb_ep *ep); > Âstatic void nuke (struct pxa25x_ep *, int status); > > -/* one GPIO should be used to detect VBUS from the host */ > -static int is_vbus_present(void) > -{ > -    struct pxa2xx_udc_mach_info       *mach = the_controller->mach; > - > -    if (gpio_is_valid(mach->gpio_vbus)) { > -        int value = gpio_get_value(mach->gpio_vbus); > - > -        if (mach->gpio_vbus_inverted) > -            return !value; > -        else > -            return !!value; > -    } > -    if (mach->udc_is_connected) > -        return mach->udc_is_connected(); > -    return 1; > -} > - > Â/* one GPIO should control a D+ pullup, so host sees this device (or not) */ > Âstatic void pullup_off(void) > Â{ > @@ -1055,7 +1037,7 @@ udc_seq_show(struct seq_file *m, void *_d) >        Â"%s version: %s\nGadget driver: %s\nHost %s\n\n", >        Âdriver_name, DRIVER_VERSION SIZE_STR "(pio)", >        Âdev->driver ? dev->driver->driver.name : "(none)", > -        is_vbus_present() ? "full speed" : "disconnected"); > +        dev->gadget.speed == USB_SPEED_FULL ? "full speed" : "disconnected"); > >    Â/* registers for device and ep0 */ >    Âseq_printf(m, > @@ -1094,7 +1076,7 @@ udc_seq_show(struct seq_file *m, void *_d) >            Â(tmp & UDCCFR_ACM) ? " acm" : ""); >    Â} > > -    if (!is_vbus_present() || !dev->driver) > +    if (dev->gadget.speed != USB_SPEED_FULL || !dev->driver) >        Âgoto done; > >    Âseq_printf(m, "ep0 IN %lu/%lu, OUT %lu/%lu\nirqs %lu\n\n", > @@ -1435,14 +1417,6 @@ lubbock_vbus_irq(int irq, void *_dev) > > Â#endif > > -static irqreturn_t udc_vbus_irq(int irq, void *_dev) > -{ > -    struct pxa25x_udc    *dev = _dev; > - > -    pxa25x_udc_vbus_session(&dev->gadget, is_vbus_present()); > -    return IRQ_HANDLED; > -} > - > > Â/*-------------------------------------------------------------------------*/ > > @@ -1766,12 +1740,9 @@ pxa25x_udc_irq(int irq, void *_dev) >        Âif (unlikely(udccr & UDCCR_SUSIR)) { >            Âudc_ack_int_UDCCR(UDCCR_SUSIR); >            Âhandled = 1; > -            DBG(DBG_VERBOSE, "USB suspend%s\n", is_vbus_present() > -                ? "" : "+disconnect"); > +            DBG(DBG_VERBOSE, "USB suspend\n"); > > -            if (!is_vbus_present()) > -                stop_activity(dev, dev->driver); > -            else if (dev->gadget.speed != USB_SPEED_UNKNOWN > +            if (dev->gadget.speed != USB_SPEED_UNKNOWN >                    Â&& dev->driver >                    Â&& dev->driver->suspend) >                Âdev->driver->suspend(&dev->gadget); > @@ -1786,8 +1757,7 @@ pxa25x_udc_irq(int irq, void *_dev) > >            Âif (dev->gadget.speed != USB_SPEED_UNKNOWN >                    Â&& dev->driver > -                    && dev->driver->resume > -                    && is_vbus_present()) > +                    && dev->driver->resume) >                Âdev->driver->resume(&dev->gadget); >        Â} > > @@ -2137,7 +2107,7 @@ static struct pxa25x_udc memory = { > Âstatic int __init pxa25x_udc_probe(struct platform_device *pdev) > Â{ >    Âstruct pxa25x_udc *dev = &memory; > -    int retval, vbus_irq, irq; > +    int retval, irq; >    Âu32 chiprev; > >    Â/* insist on Intel/ARM/XScale */ > @@ -2199,19 +2169,6 @@ static int __init pxa25x_udc_probe(struct platform_device *pdev) > >    Âdev->transceiver = otg_get_transceiver(); > > -    if (gpio_is_valid(dev->mach->gpio_vbus)) { > -        if ((retval = gpio_request(dev->mach->gpio_vbus, > -                "pxa25x_udc GPIO VBUS"))) { > -            dev_dbg(&pdev->dev, > -                "can't get vbus gpio %d, err: %d\n", > -                dev->mach->gpio_vbus, retval); > -            goto err_gpio_vbus; > -        } > -        gpio_direction_input(dev->mach->gpio_vbus); > -        vbus_irq = gpio_to_irq(dev->mach->gpio_vbus); > -    } else > -        vbus_irq = 0; > - >    Âif (gpio_is_valid(dev->mach->gpio_pullup)) { >        Âif ((retval = gpio_request(dev->mach->gpio_pullup, >                Â"pca25x_udc GPIO PULLUP"))) { > @@ -2237,7 +2194,7 @@ static int __init pxa25x_udc_probe(struct platform_device *pdev) >    Âudc_disable(dev); >    Âudc_reinit(dev); > > -    dev->vbus = !!is_vbus_present(); > +    dev->vbus = 0; > >    Â/* irq setup after old hardware state is cleaned up */ >    Âretval = request_irq(irq, pxa25x_udc_irq, > @@ -2273,22 +2230,10 @@ lubbock_fail0: >        Â} >    Â} else > Â#endif > -    if (vbus_irq) { > -        retval = request_irq(vbus_irq, udc_vbus_irq, > -                IRQF_DISABLED | IRQF_SAMPLE_RANDOM | > -                IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, > -                driver_name, dev); > -        if (retval != 0) { > -            pr_err("%s: can't get irq %i, err %d\n", > -                driver_name, vbus_irq, retval); > -            goto err_vbus_irq; > -        } > -    } >    Âcreate_debug_files(dev); > >    Âreturn 0; > > - err_vbus_irq: > Â#ifdef CONFIG_ARCH_LUBBOCK >    Âfree_irq(LUBBOCK_USB_DISC_IRQ, dev); > Âerr_irq_lub: > @@ -2298,9 +2243,6 @@ lubbock_fail0: >    Âif (gpio_is_valid(dev->mach->gpio_pullup)) >        Âgpio_free(dev->mach->gpio_pullup); > Âerr_gpio_pullup: > -    if (gpio_is_valid(dev->mach->gpio_vbus)) > -        gpio_free(dev->mach->gpio_vbus); > - err_gpio_vbus: >    Âif (dev->transceiver) { >        Âotg_put_transceiver(dev->transceiver); >        Âdev->transceiver = NULL; > @@ -2337,10 +2279,6 @@ static int __exit pxa25x_udc_remove(struct platform_device *pdev) >        Âfree_irq(LUBBOCK_USB_IRQ, dev); >    Â} > Â#endif > -    if (gpio_is_valid(dev->mach->gpio_vbus)) { > -        free_irq(gpio_to_irq(dev->mach->gpio_vbus), dev); > -        gpio_free(dev->mach->gpio_vbus); > -    } >    Âif (gpio_is_valid(dev->mach->gpio_pullup)) >        Âgpio_free(dev->mach->gpio_pullup); > > -- > 1.7.2.3 > > ÿô.nÇ·®+%˱é¥wÿº{.nÇ·¥{±þë)íèjg¬±¨¶Ýjÿ¾«þG«é¸¢·¦j:+v¨wèm¶ÿþø®w¥þ࣢·hâÿÙ