aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAnatolij Gustschin <agust@denx.de>2011-04-15 10:18:38 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-05-02 19:39:09 -0400
commit3dacdf11f1f82b98d301d5e1d42cdaea9a39968a (patch)
tree8a7b6d46b91fbc51d6e78ff436fc51e7c63aaced /drivers
parent67e7d64bcece93c84fd6e3832e7c6d91e57c06dc (diff)
usb: factor out state_string() on otg drivers
Provide common otg_state_string() and use it in drivers. Signed-off-by: Anatolij Gustschin <agust@denx.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/otg/isp1301_omap.c26
-rw-r--r--drivers/usb/otg/langwell_otg.c40
-rw-r--r--drivers/usb/otg/otg.c35
3 files changed, 41 insertions, 60 deletions
diff --git a/drivers/usb/otg/isp1301_omap.c b/drivers/usb/otg/isp1301_omap.c
index e25700f44b6f..8c282258e1bd 100644
--- a/drivers/usb/otg/isp1301_omap.c
+++ b/drivers/usb/otg/isp1301_omap.c
@@ -234,29 +234,9 @@ isp1301_clear_bits(struct isp1301 *isp, u8 reg, u8 bits)
234 234
235/*-------------------------------------------------------------------------*/ 235/*-------------------------------------------------------------------------*/
236 236
237static const char *state_string(enum usb_otg_state state)
238{
239 switch (state) {
240 case OTG_STATE_A_IDLE: return "a_idle";
241 case OTG_STATE_A_WAIT_VRISE: return "a_wait_vrise";
242 case OTG_STATE_A_WAIT_BCON: return "a_wait_bcon";
243 case OTG_STATE_A_HOST: return "a_host";
244 case OTG_STATE_A_SUSPEND: return "a_suspend";
245 case OTG_STATE_A_PERIPHERAL: return "a_peripheral";
246 case OTG_STATE_A_WAIT_VFALL: return "a_wait_vfall";
247 case OTG_STATE_A_VBUS_ERR: return "a_vbus_err";
248 case OTG_STATE_B_IDLE: return "b_idle";
249 case OTG_STATE_B_SRP_INIT: return "b_srp_init";
250 case OTG_STATE_B_PERIPHERAL: return "b_peripheral";
251 case OTG_STATE_B_WAIT_ACON: return "b_wait_acon";
252 case OTG_STATE_B_HOST: return "b_host";
253 default: return "UNDEFINED";
254 }
255}
256
257static inline const char *state_name(struct isp1301 *isp) 237static inline const char *state_name(struct isp1301 *isp)
258{ 238{
259 return state_string(isp->otg.state); 239 return otg_state_string(isp->otg.state);
260} 240}
261 241
262/*-------------------------------------------------------------------------*/ 242/*-------------------------------------------------------------------------*/
@@ -501,7 +481,7 @@ static void check_state(struct isp1301 *isp, const char *tag)
501 if (isp->otg.state == state && !extra) 481 if (isp->otg.state == state && !extra)
502 return; 482 return;
503 pr_debug("otg: %s FSM %s/%02x, %s, %06x\n", tag, 483 pr_debug("otg: %s FSM %s/%02x, %s, %06x\n", tag,
504 state_string(state), fsm, state_name(isp), 484 otg_state_string(state), fsm, state_name(isp),
505 omap_readl(OTG_CTRL)); 485 omap_readl(OTG_CTRL));
506} 486}
507 487
@@ -1095,7 +1075,7 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat)
1095 1075
1096 if (state != isp->otg.state) 1076 if (state != isp->otg.state)
1097 pr_debug(" isp, %s -> %s\n", 1077 pr_debug(" isp, %s -> %s\n",
1098 state_string(state), state_name(isp)); 1078 otg_state_string(state), state_name(isp));
1099 1079
1100#ifdef CONFIG_USB_OTG 1080#ifdef CONFIG_USB_OTG
1101 /* update the OTG controller state to match the isp1301; may 1081 /* update the OTG controller state to match the isp1301; may
diff --git a/drivers/usb/otg/langwell_otg.c b/drivers/usb/otg/langwell_otg.c
index e973ff19c55a..f08f784086f7 100644
--- a/drivers/usb/otg/langwell_otg.c
+++ b/drivers/usb/otg/langwell_otg.c
@@ -82,40 +82,6 @@ static struct pci_driver otg_pci_driver = {
82 .resume = langwell_otg_resume, 82 .resume = langwell_otg_resume,
83}; 83};
84 84
85static const char *state_string(enum usb_otg_state state)
86{
87 switch (state) {
88 case OTG_STATE_A_IDLE:
89 return "a_idle";
90 case OTG_STATE_A_WAIT_VRISE:
91 return "a_wait_vrise";
92 case OTG_STATE_A_WAIT_BCON:
93 return "a_wait_bcon";
94 case OTG_STATE_A_HOST:
95 return "a_host";
96 case OTG_STATE_A_SUSPEND:
97 return "a_suspend";
98 case OTG_STATE_A_PERIPHERAL:
99 return "a_peripheral";
100 case OTG_STATE_A_WAIT_VFALL:
101 return "a_wait_vfall";
102 case OTG_STATE_A_VBUS_ERR:
103 return "a_vbus_err";
104 case OTG_STATE_B_IDLE:
105 return "b_idle";
106 case OTG_STATE_B_SRP_INIT:
107 return "b_srp_init";
108 case OTG_STATE_B_PERIPHERAL:
109 return "b_peripheral";
110 case OTG_STATE_B_WAIT_ACON:
111 return "b_wait_acon";
112 case OTG_STATE_B_HOST:
113 return "b_host";
114 default:
115 return "UNDEFINED";
116 }
117}
118
119/* HSM timers */ 85/* HSM timers */
120static inline struct langwell_otg_timer *otg_timer_initializer 86static inline struct langwell_otg_timer *otg_timer_initializer
121(void (*function)(unsigned long), unsigned long expires, unsigned long data) 87(void (*function)(unsigned long), unsigned long expires, unsigned long data)
@@ -968,7 +934,7 @@ static void langwell_otg_work(struct work_struct *work)
968 pdev = to_pci_dev(lnw->dev); 934 pdev = to_pci_dev(lnw->dev);
969 935
970 dev_dbg(lnw->dev, "%s: old state = %s\n", __func__, 936 dev_dbg(lnw->dev, "%s: old state = %s\n", __func__,
971 state_string(iotg->otg.state)); 937 otg_state_string(iotg->otg.state));
972 938
973 switch (iotg->otg.state) { 939 switch (iotg->otg.state) {
974 case OTG_STATE_UNDEFINED: 940 case OTG_STATE_UNDEFINED:
@@ -1703,7 +1669,7 @@ static void langwell_otg_work(struct work_struct *work)
1703 } 1669 }
1704 1670
1705 dev_dbg(lnw->dev, "%s: new state = %s\n", __func__, 1671 dev_dbg(lnw->dev, "%s: new state = %s\n", __func__,
1706 state_string(iotg->otg.state)); 1672 otg_state_string(iotg->otg.state));
1707} 1673}
1708 1674
1709static ssize_t 1675static ssize_t
@@ -1789,7 +1755,7 @@ show_hsm(struct device *_dev, struct device_attribute *attr, char *buf)
1789 "b_bus_req = \t%d\n" 1755 "b_bus_req = \t%d\n"
1790 "b_bus_suspend_tmout = \t%d\n" 1756 "b_bus_suspend_tmout = \t%d\n"
1791 "b_bus_suspend_vld = \t%d\n", 1757 "b_bus_suspend_vld = \t%d\n",
1792 state_string(iotg->otg.state), 1758 otg_state_string(iotg->otg.state),
1793 iotg->hsm.a_bus_resume, 1759 iotg->hsm.a_bus_resume,
1794 iotg->hsm.a_bus_suspend, 1760 iotg->hsm.a_bus_suspend,
1795 iotg->hsm.a_conn, 1761 iotg->hsm.a_conn,
diff --git a/drivers/usb/otg/otg.c b/drivers/usb/otg/otg.c
index 0a43a7db750f..fb7adeff9ffa 100644
--- a/drivers/usb/otg/otg.c
+++ b/drivers/usb/otg/otg.c
@@ -64,3 +64,38 @@ int otg_set_transceiver(struct otg_transceiver *x)
64 return 0; 64 return 0;
65} 65}
66EXPORT_SYMBOL(otg_set_transceiver); 66EXPORT_SYMBOL(otg_set_transceiver);
67
68const char *otg_state_string(enum usb_otg_state state)
69{
70 switch (state) {
71 case OTG_STATE_A_IDLE:
72 return "a_idle";
73 case OTG_STATE_A_WAIT_VRISE:
74 return "a_wait_vrise";
75 case OTG_STATE_A_WAIT_BCON:
76 return "a_wait_bcon";
77 case OTG_STATE_A_HOST:
78 return "a_host";
79 case OTG_STATE_A_SUSPEND:
80 return "a_suspend";
81 case OTG_STATE_A_PERIPHERAL:
82 return "a_peripheral";
83 case OTG_STATE_A_WAIT_VFALL:
84 return "a_wait_vfall";
85 case OTG_STATE_A_VBUS_ERR:
86 return "a_vbus_err";
87 case OTG_STATE_B_IDLE:
88 return "b_idle";
89 case OTG_STATE_B_SRP_INIT:
90 return "b_srp_init";
91 case OTG_STATE_B_PERIPHERAL:
92 return "b_peripheral";
93 case OTG_STATE_B_WAIT_ACON:
94 return "b_wait_acon";
95 case OTG_STATE_B_HOST:
96 return "b_host";
97 default:
98 return "UNDEFINED";
99 }
100}
101EXPORT_SYMBOL(otg_state_string);