Commit 75504e9592745021006cb8905b5ff5a51d9d1cb3

Authored by Mateusz Zalega
Committed by Lukasz Majewski
1 parent 6b423b752b

usb: dfu: fix boards wo USB cable detection

Former usb_cable_connected() patch broke compilation of boards which do
not support this feature.

I've renamed usb_cable_connected() to g_dnl_usb_cable_connected() and added
its default implementation to gadget downloader driver code. There's
only one driver of this kind and it's unlikely there'll be another, so
there's no point in keeping it in /common.

Previously this function was declared in usb.h. I've moved it, since
it's more appropriate to keep it in g_dnl.h - usb.h seems to be intended
for USB host implementation.

Existing code, confronted with default -EOPNOTSUPP return value,
continues as if the cable was connected.

CONFIG_USB_CABLE_CHECK was removed.

Change-Id: Ib9198621adee2811b391c64512f14646cefd0369
Signed-off-by: Mateusz Zalega <m.zalega@samsung.com>
Acked-by: Marek Vasut <marex@denx.de>
Acked-by: Lukasz Majewski <l.majewski@samsung.com>

Showing 11 changed files with 18 additions and 44 deletions Side-by-side Diff

... ... @@ -1484,13 +1484,6 @@
1484 1484 for your device
1485 1485 - CONFIG_USBD_PRODUCTID 0xFFFF
1486 1486  
1487   - Some USB device drivers may need to check USB cable attachment.
1488   - In this case you can enable following config in BoardName.h:
1489   - CONFIG_USB_CABLE_CHECK
1490   - This enables function definition:
1491   - - usb_cable_connected() in include/usb.h
1492   - Implementation of this function is board-specific.
1493   -
1494 1487 - ULPI Layer Support:
1495 1488 The ULPI (UTMI Low Pin (count) Interface) PHYs are supported via
1496 1489 the generic ULPI layer. The generic layer accesses the ULPI PHY
board/samsung/origen/origen.c
... ... @@ -30,13 +30,6 @@
30 30 return 0;
31 31 }
32 32  
33   -#ifdef CONFIG_USB_CABLE_CHECK
34   -int usb_cable_connected(void)
35   -{
36   - return 0;
37   -}
38   -#endif
39   -
40 33 #ifdef CONFIG_BOARD_EARLY_INIT_F
41 34 int exynos_early_init_f(void)
42 35 {
board/samsung/trats/trats.c
... ... @@ -430,8 +430,7 @@
430 430 return s3c_udc_probe(&s5pc210_otg_data);
431 431 }
432 432  
433   -#ifdef CONFIG_USB_CABLE_CHECK
434   -int usb_cable_connected(void)
  433 +int g_dnl_board_usb_cable_connected(void)
435 434 {
436 435 struct pmic *muic = pmic_get("MAX8997_MUIC");
437 436 if (!muic)
... ... @@ -439,7 +438,6 @@
439 438  
440 439 return !!muic->chrg->chrg_type(muic);
441 440 }
442   -#endif
443 441 #endif
444 442  
445 443 static void pmic_reset(void)
board/samsung/trats2/trats2.c
... ... @@ -312,8 +312,7 @@
312 312 return s3c_udc_probe(&s5pc210_otg_data);
313 313 }
314 314  
315   -#ifdef CONFIG_USB_CABLE_CHECK
316   -int usb_cable_connected(void)
  315 +int g_dnl_board_usb_cable_connected(void)
317 316 {
318 317 struct pmic *muic = pmic_get("MAX77693_MUIC");
319 318 if (!muic)
... ... @@ -321,7 +320,6 @@
321 320  
322 321 return !!muic->chrg->chrg_type(muic);
323 322 }
324   -#endif
325 323 #endif
326 324  
327 325 static int pmic_init_max77686(void)
board/samsung/universal_c210/universal.c
... ... @@ -197,13 +197,6 @@
197 197 return s3c_udc_probe(&s5pc210_otg_data);
198 198 }
199 199  
200   -#ifdef CONFIG_USB_CABLE_CHECK
201   -int usb_cable_connected(void)
202   -{
203   - return 0;
204   -}
205   -#endif
206   -
207 200 int exynos_early_init_f(void)
208 201 {
209 202 wdt_stop();
common/cmd_usb_mass_storage.c
... ... @@ -45,10 +45,14 @@
45 45 /* Timeout unit: seconds */
46 46 int cable_ready_timeout = UMS_CABLE_READY_TIMEOUT;
47 47  
48   - if (!usb_cable_connected()) {
  48 + if (!g_dnl_board_usb_cable_connected()) {
  49 + /*
  50 + * Won't execute if we don't know whether the cable is
  51 + * connected.
  52 + */
49 53 puts("Please connect USB cable.\n");
50 54  
51   - while (!usb_cable_connected()) {
  55 + while (!g_dnl_board_usb_cable_connected()) {
52 56 if (ctrlc()) {
53 57 puts("\rCTRL+C - Operation aborted.\n");
54 58 goto exit;
drivers/usb/gadget/f_mass_storage.c
... ... @@ -243,7 +243,7 @@
243 243 #include <config.h>
244 244 #include <malloc.h>
245 245 #include <common.h>
246   -#include <usb.h>
  246 +#include <g_dnl.h>
247 247  
248 248 #include <linux/err.h>
249 249 #include <linux/usb/ch9.h>
250 250  
251 251  
... ... @@ -680,11 +680,11 @@
680 680 /* Handle CTRL+C */
681 681 if (ctrlc())
682 682 return -EPIPE;
683   -#ifdef CONFIG_USB_CABLE_CHECK
  683 +
684 684 /* Check cable connection */
685   - if (!usb_cable_connected())
  685 + if (!g_dnl_board_usb_cable_connected())
686 686 return -EIO;
687   -#endif
  687 +
688 688 k = 0;
689 689 }
690 690  
drivers/usb/gadget/g_dnl.c
... ... @@ -152,6 +152,11 @@
152 152 return gcnum;
153 153 }
154 154  
  155 +__weak int g_dnl_board_usb_cable_connected(void)
  156 +{
  157 + return -EOPNOTSUPP;
  158 +}
  159 +
155 160 static int g_dnl_get_bcd_device_number(struct usb_composite_dev *cdev)
156 161 {
157 162 struct usb_gadget *gadget = cdev->gadget;
include/configs/exynos4-dt.h
... ... @@ -127,7 +127,6 @@
127 127 #define CONFIG_USB_GADGET_S3C_UDC_OTG
128 128 #define CONFIG_USB_GADGET_DUALSPEED
129 129 #define CONFIG_USB_GADGET_VBUS_DRAW 2
130   -#define CONFIG_USB_CABLE_CHECK
131 130  
132 131 #define CONFIG_CMD_USB_MASS_STORAGE
133 132 #define CONFIG_USB_GADGET_MASS_STORAGE
... ... @@ -11,6 +11,7 @@
11 11 #include <linux/usb/ch9.h>
12 12 #include <linux/usb/gadget.h>
13 13 int g_dnl_bind_fixup(struct usb_device_descriptor *, const char *);
  14 +int g_dnl_board_usb_cable_connected(void);
14 15 int g_dnl_register(const char *s);
15 16 void g_dnl_unregister(void);
16 17 void g_dnl_set_serialnumber(char *);
... ... @@ -197,16 +197,6 @@
197 197 */
198 198 int board_usb_cleanup(int index, enum usb_init_type init);
199 199  
200   -/*
201   - * If CONFIG_USB_CABLE_CHECK is set then this function
202   - * should be defined in board file.
203   - *
204   - * @return 1 if cable is connected and 0 otherwise.
205   - */
206   -#ifdef CONFIG_USB_CABLE_CHECK
207   -int usb_cable_connected(void);
208   -#endif
209   -
210 200 #ifdef CONFIG_USB_STORAGE
211 201  
212 202 #define USB_MAX_STOR_DEV 5