aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget
diff options
context:
space:
mode:
authorPhilipp Zabel <philipp.zabel@gmail.com>2009-07-01 06:42:45 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-07-12 18:16:37 -0400
commit56a075dcd64b25c828af1752dff0ac1e6833e135 (patch)
tree0a69daccc1bf31fd1b1838dfdbeca2884581d1a2 /drivers/usb/gadget
parent30899ca7f20571c4bd64544dec261171f6ec255b (diff)
USB: gadget: pxa25x uses gpio_is_valid
Use gpio_is_valid instead of assuming that every GPIO number != 0 is valid while 0 is not. Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com> Acked-by: Eric Miao <eric.y.miao@gmail.com> Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/gadget')
-rw-r--r--drivers/usb/gadget/pxa25x_udc.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/drivers/usb/gadget/pxa25x_udc.c b/drivers/usb/gadget/pxa25x_udc.c
index 0ce4e2819847..e51c29a5f84f 100644
--- a/drivers/usb/gadget/pxa25x_udc.c
+++ b/drivers/usb/gadget/pxa25x_udc.c
@@ -139,7 +139,7 @@ static int is_vbus_present(void)
139{ 139{
140 struct pxa2xx_udc_mach_info *mach = the_controller->mach; 140 struct pxa2xx_udc_mach_info *mach = the_controller->mach;
141 141
142 if (mach->gpio_vbus) { 142 if (gpio_is_valid(mach->gpio_vbus)) {
143 int value = gpio_get_value(mach->gpio_vbus); 143 int value = gpio_get_value(mach->gpio_vbus);
144 144
145 if (mach->gpio_vbus_inverted) 145 if (mach->gpio_vbus_inverted)
@@ -158,7 +158,7 @@ static void pullup_off(void)
158 struct pxa2xx_udc_mach_info *mach = the_controller->mach; 158 struct pxa2xx_udc_mach_info *mach = the_controller->mach;
159 int off_level = mach->gpio_pullup_inverted; 159 int off_level = mach->gpio_pullup_inverted;
160 160
161 if (mach->gpio_pullup) 161 if (gpio_is_valid(mach->gpio_pullup))
162 gpio_set_value(mach->gpio_pullup, off_level); 162 gpio_set_value(mach->gpio_pullup, off_level);
163 else if (mach->udc_command) 163 else if (mach->udc_command)
164 mach->udc_command(PXA2XX_UDC_CMD_DISCONNECT); 164 mach->udc_command(PXA2XX_UDC_CMD_DISCONNECT);
@@ -169,7 +169,7 @@ static void pullup_on(void)
169 struct pxa2xx_udc_mach_info *mach = the_controller->mach; 169 struct pxa2xx_udc_mach_info *mach = the_controller->mach;
170 int on_level = !mach->gpio_pullup_inverted; 170 int on_level = !mach->gpio_pullup_inverted;
171 171
172 if (mach->gpio_pullup) 172 if (gpio_is_valid(mach->gpio_pullup))
173 gpio_set_value(mach->gpio_pullup, on_level); 173 gpio_set_value(mach->gpio_pullup, on_level);
174 else if (mach->udc_command) 174 else if (mach->udc_command)
175 mach->udc_command(PXA2XX_UDC_CMD_CONNECT); 175 mach->udc_command(PXA2XX_UDC_CMD_CONNECT);
@@ -1000,7 +1000,7 @@ static int pxa25x_udc_pullup(struct usb_gadget *_gadget, int is_active)
1000 udc = container_of(_gadget, struct pxa25x_udc, gadget); 1000 udc = container_of(_gadget, struct pxa25x_udc, gadget);
1001 1001
1002 /* not all boards support pullup control */ 1002 /* not all boards support pullup control */
1003 if (!udc->mach->gpio_pullup && !udc->mach->udc_command) 1003 if (!gpio_is_valid(udc->mach->gpio_pullup) && !udc->mach->udc_command)
1004 return -EOPNOTSUPP; 1004 return -EOPNOTSUPP;
1005 1005
1006 udc->pullup = (is_active != 0); 1006 udc->pullup = (is_active != 0);
@@ -2160,7 +2160,7 @@ static int __init pxa25x_udc_probe(struct platform_device *pdev)
2160 dev->dev = &pdev->dev; 2160 dev->dev = &pdev->dev;
2161 dev->mach = pdev->dev.platform_data; 2161 dev->mach = pdev->dev.platform_data;
2162 2162
2163 if (dev->mach->gpio_vbus) { 2163 if (gpio_is_valid(dev->mach->gpio_vbus)) {
2164 if ((retval = gpio_request(dev->mach->gpio_vbus, 2164 if ((retval = gpio_request(dev->mach->gpio_vbus,
2165 "pxa25x_udc GPIO VBUS"))) { 2165 "pxa25x_udc GPIO VBUS"))) {
2166 dev_dbg(&pdev->dev, 2166 dev_dbg(&pdev->dev,
@@ -2173,7 +2173,7 @@ static int __init pxa25x_udc_probe(struct platform_device *pdev)
2173 } else 2173 } else
2174 vbus_irq = 0; 2174 vbus_irq = 0;
2175 2175
2176 if (dev->mach->gpio_pullup) { 2176 if (gpio_is_valid(dev->mach->gpio_pullup)) {
2177 if ((retval = gpio_request(dev->mach->gpio_pullup, 2177 if ((retval = gpio_request(dev->mach->gpio_pullup,
2178 "pca25x_udc GPIO PULLUP"))) { 2178 "pca25x_udc GPIO PULLUP"))) {
2179 dev_dbg(&pdev->dev, 2179 dev_dbg(&pdev->dev,
@@ -2256,10 +2256,10 @@ lubbock_fail0:
2256#endif 2256#endif
2257 free_irq(irq, dev); 2257 free_irq(irq, dev);
2258 err_irq1: 2258 err_irq1:
2259 if (dev->mach->gpio_pullup) 2259 if (gpio_is_valid(dev->mach->gpio_pullup))
2260 gpio_free(dev->mach->gpio_pullup); 2260 gpio_free(dev->mach->gpio_pullup);
2261 err_gpio_pullup: 2261 err_gpio_pullup:
2262 if (dev->mach->gpio_vbus) 2262 if (gpio_is_valid(dev->mach->gpio_vbus))
2263 gpio_free(dev->mach->gpio_vbus); 2263 gpio_free(dev->mach->gpio_vbus);
2264 err_gpio_vbus: 2264 err_gpio_vbus:
2265 clk_put(dev->clk); 2265 clk_put(dev->clk);
@@ -2294,11 +2294,11 @@ static int __exit pxa25x_udc_remove(struct platform_device *pdev)
2294 free_irq(LUBBOCK_USB_IRQ, dev); 2294 free_irq(LUBBOCK_USB_IRQ, dev);
2295 } 2295 }
2296#endif 2296#endif
2297 if (dev->mach->gpio_vbus) { 2297 if (gpio_is_valid(dev->mach->gpio_vbus)) {
2298 free_irq(gpio_to_irq(dev->mach->gpio_vbus), dev); 2298 free_irq(gpio_to_irq(dev->mach->gpio_vbus), dev);
2299 gpio_free(dev->mach->gpio_vbus); 2299 gpio_free(dev->mach->gpio_vbus);
2300 } 2300 }
2301 if (dev->mach->gpio_pullup) 2301 if (gpio_is_valid(dev->mach->gpio_pullup))
2302 gpio_free(dev->mach->gpio_pullup); 2302 gpio_free(dev->mach->gpio_pullup);
2303 2303
2304 clk_put(dev->clk); 2304 clk_put(dev->clk);
@@ -2329,7 +2329,7 @@ static int pxa25x_udc_suspend(struct platform_device *dev, pm_message_t state)
2329 struct pxa25x_udc *udc = platform_get_drvdata(dev); 2329 struct pxa25x_udc *udc = platform_get_drvdata(dev);
2330 unsigned long flags; 2330 unsigned long flags;
2331 2331
2332 if (!udc->mach->gpio_pullup && !udc->mach->udc_command) 2332 if (!gpio_is_valid(udc->mach->gpio_pullup) && !udc->mach->udc_command)
2333 WARNING("USB host won't detect disconnect!\n"); 2333 WARNING("USB host won't detect disconnect!\n");
2334 udc->suspended = 1; 2334 udc->suspended = 1;
2335 2335