aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Tikhomirov <av.tikhomirov@samsung.com>2013-10-02 23:42:04 -0400
committerNitin Garg <nitin.garg@freescale.com>2014-04-16 12:02:22 -0400
commit370cdc5e116b4a790358c7f88deb12da9fdaa784 (patch)
tree83bc4947da9eb0cf51b9de3a1fa5d0d0537967d3
parenta6db42388d75bf2fabaf863e09e56b491955477f (diff)
usb: phy: Check OTG FSM callback existance in helper functions
Existence of callback must be checked to avoid NULL pointer dereferncing. Signed-off-by: Anton Tikhomirov <av.tikhomirov@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com> (cherry-picked from commit 737cc66eac350d674c72a3f903541644098ec47e)
-rw-r--r--drivers/usb/phy/phy-fsm-usb.h35
1 files changed, 28 insertions, 7 deletions
diff --git a/drivers/usb/phy/phy-fsm-usb.h b/drivers/usb/phy/phy-fsm-usb.h
index 75344bec4679..0f3f7d87f887 100644
--- a/drivers/usb/phy/phy-fsm-usb.h
+++ b/drivers/usb/phy/phy-fsm-usb.h
@@ -95,48 +95,69 @@ struct otg_fsm_ops {
95}; 95};
96 96
97 97
98static inline void otg_chrg_vbus(struct otg_fsm *fsm, int on) 98static inline int otg_chrg_vbus(struct otg_fsm *fsm, int on)
99{ 99{
100 if (!fsm->ops->chrg_vbus)
101 return -EOPNOTSUPP;
100 fsm->ops->chrg_vbus(fsm, on); 102 fsm->ops->chrg_vbus(fsm, on);
103 return 0;
101} 104}
102 105
103static inline void otg_drv_vbus(struct otg_fsm *fsm, int on) 106static inline int otg_drv_vbus(struct otg_fsm *fsm, int on)
104{ 107{
108 if (!fsm->ops->drv_vbus)
109 return -EOPNOTSUPP;
105 if (fsm->drv_vbus != on) { 110 if (fsm->drv_vbus != on) {
106 fsm->drv_vbus = on; 111 fsm->drv_vbus = on;
107 fsm->ops->drv_vbus(fsm, on); 112 fsm->ops->drv_vbus(fsm, on);
108 } 113 }
114 return 0;
109} 115}
110 116
111static inline void otg_loc_conn(struct otg_fsm *fsm, int on) 117static inline int otg_loc_conn(struct otg_fsm *fsm, int on)
112{ 118{
119 if (!fsm->ops->loc_conn)
120 return -EOPNOTSUPP;
113 if (fsm->loc_conn != on) { 121 if (fsm->loc_conn != on) {
114 fsm->loc_conn = on; 122 fsm->loc_conn = on;
115 fsm->ops->loc_conn(fsm, on); 123 fsm->ops->loc_conn(fsm, on);
116 } 124 }
125 return 0;
117} 126}
118 127
119static inline void otg_loc_sof(struct otg_fsm *fsm, int on) 128static inline int otg_loc_sof(struct otg_fsm *fsm, int on)
120{ 129{
130 if (!fsm->ops->loc_sof)
131 return -EOPNOTSUPP;
121 if (fsm->loc_sof != on) { 132 if (fsm->loc_sof != on) {
122 fsm->loc_sof = on; 133 fsm->loc_sof = on;
123 fsm->ops->loc_sof(fsm, on); 134 fsm->ops->loc_sof(fsm, on);
124 } 135 }
136 return 0;
125} 137}
126 138
127static inline void otg_start_pulse(struct otg_fsm *fsm) 139static inline int otg_start_pulse(struct otg_fsm *fsm)
128{ 140{
141 if (!fsm->ops->start_pulse)
142 return -EOPNOTSUPP;
129 fsm->ops->start_pulse(fsm); 143 fsm->ops->start_pulse(fsm);
144 return 0;
130} 145}
131 146
132static inline void otg_add_timer(struct otg_fsm *fsm, void *timer) 147static inline int otg_add_timer(struct otg_fsm *fsm, void *timer)
133{ 148{
149 if (!fsm->ops->add_timer)
150 return -EOPNOTSUPP;
134 fsm->ops->add_timer(fsm, timer); 151 fsm->ops->add_timer(fsm, timer);
152 return 0;
135} 153}
136 154
137static inline void otg_del_timer(struct otg_fsm *fsm, void *timer) 155static inline int otg_del_timer(struct otg_fsm *fsm, void *timer)
138{ 156{
157 if (!fsm->ops->del_timer)
158 return -EOPNOTSUPP;
139 fsm->ops->del_timer(fsm, timer); 159 fsm->ops->del_timer(fsm, timer);
160 return 0;
140} 161}
141 162
142int otg_statemachine(struct otg_fsm *fsm); 163int otg_statemachine(struct otg_fsm *fsm);